init $ tail [1,2,3]
= init (tail ([1,2,3])) -- a la Lisp

Now, functional programming is awesomest at abstractions. What if we could abstract out "init (tail"? 

Then we could write 

chopEnds = init (tail

But that looks weird. It's only got the left half of a parens pair!

Does that explain why you should not expect the same result?

A separate question is why the compiler even type-checks "init $ tail" in the first place. What do you think is going on there?

On Tue, Jan 26, 2021 at 1:16 AM Lawrence Bottorff <borgauf@gmail.com> wrote:
I've got this

> init $ tail [1,2,3]
[2]

and this

> chopEnds = init $ tail
> chopEnds [1,2,3]
[1,2]

What happened? Why is it not just init $ tail [1,2,3] ?

This works fine 

> chopEnds2 = init . tail
> chopEnds2 [1,2,3]
[2]

What am I missing?

LB
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
--
-- Kim-Ee