curry function implementaion

curry function implementaion

Post by Rober » Sat, 06 May 2006 04:16:14


Do anyone know tutorials about partially parameterized function
implementation? Currently I evaluate curry function and get an
expression as result(contains variables) then the function apply to
parameters, evaluated the the expression by replacing variable with
actual parameters.
 
 
 

curry function implementaion

Post by Rober » Sat, 06 May 2006 22:24:47

experts, I think it is good virtue to help a beginner!

 
 
 

curry function implementaion

Post by Ian Zimmer » Sun, 07 May 2006 12:22:01


Robert> experts, I think it is good virtue to help a beginner!

Google for "Xavier Leroy" "ZINC"

--
A true pessimist won't be discouraged by a little success.
 
 
 

curry function implementaion

Post by gene » Fri, 26 May 2006 06:39:09

If I am understanding you right, I think a few examples might help in
providing motivation for using partially parameterized functions at
least, and really show that there is not much mystery... I mean after
all you are just NOT supplying a parameter or maybe two..
Anyway here is a function f that is then encapsulated in the function
g with one parameter missing... then g is mapped over a list providing
the missing parameter from the elements of the list and building and
producing the list of the results of the function application as the
result.

Prelude> let f a b = a^b
Prelude> let g = f 2
Prelude> map g [2..7]
[4,8,16,32,64,128]

if you wanted to get the results instead of 2 raised to the incremental
powers from 2 to 7 then ... you could change the definition of function
g to be :
Prelude> let g = (flip f) 2
Prelude> map g [2..7]
[4,9,16,25,36,49]

These is an overly simple example but it might help ... I hope.
gene
 
 
 

curry function implementaion

Post by gene » Fri, 26 May 2006 06:46:11

Just as a follow up although this is bearing on another topic, that of
use of anonymous lambda functions.. it almost always makes more sense
not to muck up things like I did in the example above..
and given the function:
f a b = a^b
to apply (f a) or (flip f a) directly rather than naming another
function.. for use in one spot such as the mapping in the example. So:
Prelude> map ((flip f) 2) [1..12]
[1,4,9,16,25,36,49,64,81,100,121,144]

gene