News for hackers. Stuff that matters.
Re:Teaching Haskell to a 10 year old: Day 1 by pbhjpbhj on Wednesday April 08, 2015 @08:59PM (#9345193)
I don't know Haskell at all, the ~"all functions only have one argument" concept interests me.

>"had an easy time explaining how (2 * 3) really is two functions, each with one argument and one result, and he drew it out on paper nicely" //

So, like you pass the multiply function an argument which is a list (2, 3). Or is it more like you pass the multiply function the first operand (2 in this case) and it returns a function multiply-by-2 which you pass the second operand? The latter seems like it would get sub-optimal pretty quickly. Mind you surely here the compiler produces the same sort of assembly [repeated addition here] making it just a way to abstract around an alternate mental model.

I've just looked at https://wiki.haskell.org/Currying, could someone walk through how something like arcsin(0) works - that's probably a bad example - something that takes a single variable input but has multiple solutions (returns n.π in this case, but say sqrt or an anagram function or ...)?

I'm sure you can tell I'm not a computer scientist, not even a programmer ...

Re:Teaching Haskell to a 10 year old: Day 1 by Saavedro on Wednesday April 08, 2015 @09:10PM (#9345226)
> Or is it more like you pass the multiply function the first operand (2 in this case) and it returns a function multiply-by-2 which you pass the second operand

This is exactly it. You can literally write:

multiply_by_2 = (*) 2

Re:Teaching Haskell to a 10 year old: Day 1 by spion on Wednesday April 08, 2015 @09:17PM (#9345250)
It returns the multiply-by-2 function. This turns out to be super useful

  map (* 2) [1, 2, 3]
will take that function and apply it to each element in the list [1,2,3].
Re:Teaching Haskell to a 10 year old: Day 1 by pbhjpbhj on Wednesday April 08, 2015 @09:39PM (#9345342)
That map function looks a lot like it has 2 arguments, a function and an operand array (ie a list)??
Re:Teaching Haskell to a 10 year old: Day 1 by Sniffnoy on Wednesday April 08, 2015 @09:49PM (#9345392)
Again, it works the same way. The map function takes the argument (*2) and returns a function, which is then applied to the list.
Re:Teaching Haskell to a 10 year old: Day 1 by pbhjpbhj on Thursday April 09, 2015 @06:34AM (#9346668)
Seems like a semantic gloss, but then at some level I suppose higher level computing languages are all a semantic gloss.

Thanks for the responses - I'm now almost as knowledgeable as a 10 yo prior to being instructed in the subject at hand.

Re:Teaching Haskell to a 10 year old: Day 1 by Saavedro on Wednesday April 08, 2015 @09:48PM (#9345384)
map takes a function and returns a function that takes a list and returns a list. It has a type like: (a->b) -> [a] -> [b] (I take a function from type a to type b and return a function from list of a to list of b)

define

double_list_elements = map (*2)

and

> double_list_elements [1, 2, 3, 4]

gives you [2, 4, 6, 8]