>>13
no, >>1 is not a troll.
Trolls have dignity, I've been long enough on usenet son, believe me.
Name:
Anonymous2008-03-30 17:30
Question:
In EMACS, when I want to load a function for the whole session, what hook do I use? 'emacs-startup-hook runs the function, but the effect ceases when I open a new buffer.
I am sorry to pollute your nice haskell ferret thread, but I just started reading YAHT, and I have a question about Exercise 3.4:
Use the functions mentioned in this section (you will need two of them) to compute the number of lower-case letters in a string. For instance, on “aBCde” it should return 3.
Is there a way to write it with foldl/r? I am familiar with perl, and foldl looks a lot like reduce from List::Util, but I tried many combinations and all of them failed (foldl (+1) 0 filter (Char.isLower) "aBCde"foldl (1+) 0 filter (Char.isLower) "aBCde", ie ignoring values and only using item count, in perl that would be reduce{$a+1} 0, @list)
Also, will it be explained in yaht why length(filter (Char.isLower) "aBCde") works, but length filter (Char.isLower) "aBCde" does not?
Name:
Anonymous2008-03-31 7:20
Is there a way to write it with foldl/r? I am familiar with perl, and foldl looks a lot like reduce from List::Util, but I tried many combinations and all of them failed (foldl (+1) 0 filter (Char.isLower) "aBCde" foldl (1+) 0 filter (Char.isLower) "aBCde", ie ignoring values and only using item count, in perl that would be reduce{$a+1} 0, @list)
Sure: foldr (\ c s -> if Char.isLower c then s + 1 else s) 0 "aBCde" Also, will it be explained in yaht why length(filter (Char.isLower) "aBCde") works, but length filter (Char.isLower) "aBCde" does not?
Write Lisp until you are more sure of the precedence and such: (length (filter Char.isLower "aBCde"))
Your failed example calls length with three parameters.
Name:
Anonymous2008-03-31 7:26
Oh, and if you wanted a silly solution for counting lower-case letters: (foldr (const (+1)) 0 (filter Char.isLower "aBCde"))