Categories
Uncategorized

How do I make a generator?

I need to learn how to make generators! How to play a game using a given language? How to create a class? How to use classes and inheritance? How to use inheritance? How to use methods? Which of the several programming languages out there are actually taught by teachers who know enough to make such mistakes?

If you are like most programmers, you have many questions, and you desperately need to know what to ask for help. Let’s take a look at what a beginner programmer may ask:

Is there another language out there with a better feature set?

Are there better compiler tools at their disposal?

Are there better resources for tutorials?
Speech compression using Linear Predictive Coding - File Exchange ...

Do these features come standard with most languages? Or is it all a matter of taste? (See Why C/C++)

How do you solve problems and what are the best approaches to solving problems? (See What is best practices?)

The first question is an easier one to answer with a simple answer. No. Of course there is another language out there with a better feature set. But even if you learn Ruby or Node you don’t have a lot of freedom when compared to a C/C++ programmer. Your options are limited by the choices in C and C++ and how much development time it takes to develop in these types of languages.

The second question is a harder one: Do you know enough to know how to solve problems? Which options are best?

The two primary options are first class functions, as implemented in other languages, and inheritance. And both require a lot of experience.

The first class function is the one described in the book Learning Go with Python by David A. Wheeler and James C. Stewart. It provides a mechanism for the programmer to specify what a function does. Here’s an abstract function:

subfunction :: function -> value

This function returns a new function that takes the same parameters as the previous function and returns the same return value. The function can be used with arguments that follow the same syntax:

subfunction foo () { return “hello”; } foo() // returns “hello” subfunction bar () { print(‘bar’) } bar() // prints “bar” subfunction baz () { print(‘baz’) } baz() // prints “baz”

The second class function is inheritance. For example, if we want to implement a class that encapsulates all of the functionality to a method, I can think of