Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. foldr point free notation (Alexander Chen)
2. Re: foldr point free notation (Bob Ippolito)
3. Re: foldr point free notation (Apoorv Ingle)
4. Why do i need to take out the list for this to work
(Alexander Chen)
5. Re: Why do i need to take out the list for this to work
(Bob Ippolito)
----------------------------------------------------------------------
Message: 1
Date: Wed, 10 Jun 2020 16:49:05 +0200 (CEST)
From: Alexander Chen <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] foldr point free notation
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
hi,
--any function foldr
myAny'' :: (a-> Bool) -> [a] -> Bool
myAny'' f = foldr (\a b -> f a || b) False
this is the foldr notions. How would i make this point free?
best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200610/ae48ec95/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 10 Jun 2020 08:00:34 -0700
From: Bob Ippolito <[email protected]>
To: Alexander Chen <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldr point free notation
Message-ID:
<cacwmpm_n4k9ocesmgf2uvsmkvgvff0lzwo53y-xtaw-j4vw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
The better question is why would you want to? If you could even manage, the
result would be practically incomprehensible.
On Wed, Jun 10, 2020 at 07:49 Alexander Chen <[email protected]> wrote:
> hi,
>
> --any function foldr
> myAny'' :: (a-> Bool) -> [a] -> Bool
> myAny'' f = foldr (\a b -> f a || b) False
>
> this is the foldr notions. How would i make this point free?
>
> best,
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200610/f82d7e70/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 10 Jun 2020 10:50:27 -0500
From: Apoorv Ingle <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldr point free notation
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi Alexander,
I found this tool online[1], that converts your function to a point free style.
myAny'' f = foldr (\a b -> f a || b) False
is transformed to
myAny'' = flip foldr False . ((||) .)
Again as Bob mentions, the point free style comes at a cost of unreadability
and hence unmaintainable.
Cheers!
Apoorv
[1]: http://pointfree.io/ <http://pointfree.io/>
> On Jun 10, 2020, at 10:00, Bob Ippolito <[email protected]> wrote:
>
> The better question is why would you want to? If you could even manage, the
> result would be practically incomprehensible.
>
> On Wed, Jun 10, 2020 at 07:49 Alexander Chen <[email protected]
> <mailto:[email protected]>> wrote:
> hi,
>
> --any function foldr
> myAny'' :: (a-> Bool) -> [a] -> Bool
> myAny'' f = foldr (\a b -> f a || b) False
>
> this is the foldr notions. How would i make this point free?
>
> best,
> _______________________________________________
> Beginners mailing list
> [email protected] <mailto:[email protected]>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> <http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200610/806d3461/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 10 Jun 2020 20:42:12 +0200 (CEST)
From: Alexander Chen <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Why do i need to take out the list for
this to work
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
hi,
assigment: make your own element function with the any function.
--elem with any
myElemAny :: Eq a => a -> [a] -> Bool
myElemAny a = any (== a)
--elem with any
myElemAny' :: Eq a => a -> [a] -> Bool
myElemAny' a [x]= any (== a) [x]
myElemAny' compiles but throws an error because it has a non-exhaustive
pattern. Could somebody tell me why the list gives the function grieveness?
thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200610/051290ca/attachment-0001.html>
------------------------------
Message: 5
Date: Wed, 10 Jun 2020 11:49:48 -0700
From: Bob Ippolito <[email protected]>
To: Alexander Chen <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why do i need to take out the list
for this to work
Message-ID:
<cacwmpm-qpjurnbegexg8n0lm1tyj_pigco0mdit2hrenckx...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Square brackets [] are pattern match syntax for lists. This will only work
for lists of length 1, anything else will be an error. Get rid of the
brackets on both sides of the equation and it will do what you expect.
Typically list variables are given plural names, such as xs instead of x.
On Wed, Jun 10, 2020 at 11:42 Alexander Chen <[email protected]> wrote:
> hi,
>
> assigment: make your own element function with the any function.
>
> --elem with any
> myElemAny :: Eq a => a -> [a] -> Bool
> myElemAny a = any (== a)
>
> --elem with any
> myElemAny' :: Eq a => a -> [a] -> Bool
> myElemAny' a [x]= any (== a) [x]
>
>
> myElemAny' compiles but throws an error because it has a non-exhaustive
> pattern. Could somebody tell me why the list gives the function grieveness?
>
> thanks,
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200610/3b040bed/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 144, Issue 2
*****************************************