[Haskell-cafe] Rewrite without parenthesis

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Aug 18 22:26:35 UTC 2016


On 18 August 2016 at 22:29, Theodore Lief Gannon <tanuki at gmail.com> wrote:
> Francesco, you missed a piece. 'head' is part of the expression. :) What
> Carl is looking for is one or the other of these:
>
> head $ tail [1,2,3]
> -- or --
> head . tail $ [1,2,3]

Or for this specific use case, [1,2,3] !! 1 ==> (!!1) [1,2,3]

>
> The first one is shorter and fine for inlining, but I generally prefer the
> second form... it helps intuition about eta reduction, refactoring, and
> additional composition.
>
>
> On Aug 18, 2016 5:19 AM, "Francesco Ariis" <fa-ml at ariis.it> wrote:
>>
>> On Thu, Aug 18, 2016 at 05:03:21AM -0700, Carl Petersen wrote:
>> > How do you rewrite head (tail [1,2,3]) without parenthesis.
>>
>> Hello Carl, simply
>>
>>     λ> tail [1,2,3]
>>     [2,3]
>>
>> will do! Haskell is not a Lisp, no need to wrap expressions
>> around ().
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list