Reputation: 23
I am trying to create a SML function that takes lost of booleans and returns the number of times that "true" appears in the list.
fun truecount(lst) = foldl (fn (x,y) => if x=true then y+1) 0 lst;
I feel like I may be on the right path but I just can't quite seem to get it correct. If anyone sees how to do this please let me know!
Upvotes: 2
Views: 84
Reputation: 4273
Well, what does your anonymous function
fn (x,y) => if x=true then y+1
return when x
is not true
?
What should it?
For that matter, what else do you need in an if ... then ...
to get it to even compile?
Upvotes: 2