[Haskell-beginners] Equivalence (or not) of lists

Francesco Ariis fa-ml at ariis.it
Sat Nov 12 20:29:22 UTC 2016


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:[])


More information about the Beginners mailing list