Previous Up Next

6.3.2  Creating a list by using a function

The makelist command creates lists built from values of a function.

Examples

(In these examples, purge x if x is not symbolic.)

makelist(x->x^2,3,5)

or:

makelist(x->x^2,3,5,1)

or:

h(x):=x^2:; makelist(h,3,5,1)
     

9,16,25
          
makelist(x->x^2,3,6,2)
     

9,25
          
makelist(4,1,3)
     

4,4,4
          

The above command line regards 4 as the constant function, and so creates a list with entries 4, from integers 1 to 3. The command

[4$3]

is an equivalent.


Previous Up Next