Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Evalutation of free variables in lambdas' topicStudent Support Forum > General > Archives > "Evalutation of free variables in lambdas"

Next Comment >Help | Reply To Topic
Author Comment/Response
User
10/30/02 09:57am

I want to generate a list of the functions (+1) (+2) (+3)... (haskell syntax). I try:

Table[ (k+#)&, {k,1,10} ]

but the variable k is never bound. For instance,

k=0;
f=Function[t, t+k];
k=1;
f[0] => 1

I can do:

Map[ Function[k, Function[t,k+t]], Range[1,10]]

But is there a less awkward way via Table? In Haskell list comprehensions, for instance, one can simply do:

[ \t->t+k, k<-[1..10] ]

Can you give any references to evaluation rules inside of Mathematica lambdas?

Thanks.


URL: ,

Subject (listing for 'Evalutation of free variables in lambdas')
Author Date Posted
Evalutation of free variables in lambdas User 10/30/02 09:57am
Re: Evalutation of free variables in lambdas User 10/30/02 8:32pm
Next Comment >Help | Reply To Topic