#haskell - Tue 27 Mar 2007 between 00:00 and 00:03

NY Lost Funds



donssecondly, you'd start by looking at the type of foldl :-)
:t foldl
lambdabotforall a b. (a -> b -> a) -> a -> [b] -> a
gvdm_other> factorial 10
lambdabotNot in scope: `factorial'
tspthat made no sense
dons> product [1..10]
lambdabot3628800
gvdm_other> fact 10
lambdabotNot in scope: `fact'
gvdm_other> 10!
lambdabotParse error
gvdm_other:(
dons:t product
lambdabotforall a. (Num a) => [a] -> a
dmwitgvdm_other: If that was built in, what would people give new Haskellers as an exercise? ;-)
heatsink:t (+)
lambdabotforall a. (Num a) => a -> a -> a
tspI don't get the haskel . syntax as well
donsah well. you'll just have to learn something new :-)
heatsinktsp: The (+) operator works on many types, so it uses type variables.
Caletsp: . syntax?
(.) is composition of functions
heatsinkThe "forall a." declares that there is one type variable in the type of (+).
Caleoh, that dot
monochromIt's a punctuation mark.
heatsinkSo if you plug in "Int" for "a", you get (Num Int) => Int -> Int -> Int
CaleThat's just a separator to indicate where the list of bound variables ends, yeah.
donse.g. \x . x
monochromMost things are punctuation marks.
heatsinkYou can do that?
> (\x . x) 3
lambdabotParse error
tspcan python even do a foldl?
Caleheatsink: no, but that's the traditional notation for lambda terms
tspjust curious
kc5tja_> (\x -> x) 3
Caletsp: yes, I believe it's called reduce
monochrompython can do a foldl
lambdabot3

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 

IrcArchive

NY Lost Funds