prstanley:
> 
> >> Hi
> >> What is the rationale behind currying? is it for breaking subroutines 
> >into
> >> pure one-to-one mappings?
> >
> >We don't have 'subroutines' as such, but otherwise yes. Also, it gives us
> >partial application - we don't have to apply all the parameters at once,
> >and we can do interesting and useful things by applying only some to get a
> >new function.
> >
> >> If f x y = f x -> a function which takes y for
> >> argument then does that mean that the second function already has 
> >value x, as
> >> it were, built into it?
> >
> >Yep, though I can't make sense of what your syntax is supposed to mean.
> >I shouldn't take it too literally. It's just to illustrate the point 
> >that f x returns another function with x already in it and y passed 
> >as argument.
> Could you perhaps demonstrate how you can apply parts of curried 
> functions in other functions in Haskell?

(^) applied to 2, produces a new function, we can map over a list:

    Prelude> let sq = (^2)
    Prelude> map sq [1..10]
    [1,4,9,16,25,36,49,64,81,100]

or more explicitly:

    Prelude> let x `to` y = x ^ y
    Prelude> let sq x = x `to` 2
    Prelude> map sq [1..10]
    [1,4,9,16,25,36,49,64,81,100]

-- Don
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to