
In this case it's not too bad adding parens to make: length' (1:2:3:[]) But in the future sometimes it can get harder, so we have a handy function '$' which is just function application, but it has the lowest precedence. What this means is everything on its right side is evaluated and then applied to the function on its left. Your code would look like this: length' $ 1:2:3:[] In some cases this can be more readable. Best, Chris Francesco Ariis writes:
On Sat, Nov 12, 2016 at 08:20:19PM +0000, Lawrence Wickert wrote:
Hello all,
I am a rank beginner to functional languages. Working through Lipovaca's book, up to Chapter 3.
[...]
*Main> length' 1:2:3:[]
Hello Lawrence, remember that function application has precedence over operators!
So writing:
*Main> length' 1:2:3:[]
is equivalent to writing
*Main> (length' 1) :2:3:[]
(which is not what you want). If you add parentheses, your expression works again!
*Main> length' (1:2:3:[]) _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners