Anyway, it was Haskell time. The idea was to teach the computer who the girls are and then turn them upside down.
So we opened ghci and started teaching. Like last time with Turtle Roy, we used let to define a new thing. I suggested the word "tytöt" (girls) but we chose to use the name "t" because it's shorter and the computer doesn't really care. So,
> let t = ["mila", "elena"]
Then we discussed head and tail a bit and tried them
> head t
"mila"
> tail t
["elena"]
I took a while to make a distinction between a character string and a list and that tail returns a list of strings in this case. I'm quite sure she ignored my talk. But let's see. Maybe she's a natural with types.
Next we tried reverse:
> reverse t
["elena", "mila"]
And finally the funniest thing. I introduced a new function map which takes a list and another function (POW!) and performs the other function for all things on the list. So we applied reverse to all the girls:
> map reverse t
["alim", "anele"]
That was fun. Then we reversed daddy too.
No comments:
Post a Comment