Is (^2) really considered currying? As I understand it, this is
syntactic sugar for a section, and might confuse the issue a bit,
since it's distinct from ((^) 2). In this case we would have something
like
Prelude let pow2 = ((^) 2)
Prelude map pow2 [1..10]
[2,4,8,16,32,64,128,256,512,1024]
I
On Wed, 23 May 2007, Chad Scherrer wrote:
Is (^2) really considered currying? As I understand it, this is
syntactic sugar for a section, and might confuse the issue a bit,
since it's distinct from ((^) 2).
Sure, but it's (flip (^)) 2.
--
[EMAIL PROTECTED]
Sometimes you gotta fight fire
PR Stanley wrote:
What is the rationale behind currying?
Given
map :: (a-b) - [a]-[b]
take :: Int - [a] - [a]
I can write map f . take 10 or take 10 map f.
Given
tmap :: (a-b, [a]) - [b]
ttake :: (Int, [a]) - [a]
I have to write \x - tmap(f, ttake(10, x)).
It is not just
On 5/23/07, Philippa Cowderoy [EMAIL PROTECTED] wrote:
On Wed, 23 May 2007, Chad Scherrer wrote:
Is (^2) really considered currying? As I understand it, this is
syntactic sugar for a section, and might confuse the issue a bit,
since it's distinct from ((^) 2).
Sure, but it's (flip (^)) 2.
Disclaimer: I've not read the standard.
Sections are de-sugared depending on which argument you supply:
(x^) == (^) x
(^x) == flip (^) x
I think this is why they are considered special cases.
Prelude map (^2) [1..10]
[1,4,9,16,25,36,49,64,81,100]
Prelude map (flip (^) 2) [1..10]
Chad Scherrer wrote:
On 5/23/07, Philippa Cowderoy [EMAIL PROTECTED] wrote:
On Wed, 23 May 2007, Chad Scherrer wrote:
Is (^2) really considered currying? As I understand it, this is
syntactic sugar for a section, and might confuse the issue a bit,
since it's distinct from ((^) 2).
Sure,
Hi
What is the rationale behind currying? is it for breaking subroutines
into pure one-to-one mappings? 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?
The syntax in Haskell is perfectly lucid
On Wed, 23 May 2007, PR Stanley wrote:
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,
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
On May 22, 2007, at 22:35 , PR Stanley wrote:
Could you perhaps demonstrate how you can apply parts of curried
functions in other functions in Haskell?
A trivial example:
Prelude map (+1) [1..10]
[2,3,4,5,6,7,8,9,10,11]
(Strictly speaking (+1) is a section, but that's just a syntactic
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
11 matches
Mail list logo