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. MaximumBy (Alexander Chen)
2. Re: MaximumBy (Daniel van de Ghinste (Lord_Luvat))
3. Re: MaximumBy (Alexander Chen)
4. Re: Understanding types and constructors more thoroughly
(Magnus Therning)
5. Re: MaximumBy (Francesco Ariis)
6. Re: MaximumBy (Ut Primum)
----------------------------------------------------------------------
Message: 1
Date: Fri, 22 May 2020 20:20:38 +0200 (CEST)
From: Alexander Chen <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] MaximumBy
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
I want to re-write a function maximumBy (its an assignment).
However, I don't get how it works.
>maximumBy compare [1,53,9001, 10]
9001
but what does it actually do to get there?
thanks in advance.
best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200522/7b1cdb0d/attachment-0001.html>
------------------------------
Message: 2
Date: Fri, 22 May 2020 20:33:33 +0200
From: "Daniel van de Ghinste (Lord_Luvat)"
<[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] MaximumBy
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
Maybe I’m on a different version, but I don’t see a function called maximumBy
in my base Prelude. Can you give us a type signature for the function? If
you’re not sure how to do that just type:
Prelude> :t maximumBy
In your ghci interpreter and it should return the type signature of whatever
you have after ‘:t ‘ (this works for compound expressions too if you put them
in brackets)
Perhaps maximumBy is what you’re meant to call your rewrite of the existing
function I see called ‘maximum’ (seems to do the same thing). Let me know if
thats the case and I can explain how it works.
Best regards,
Daniel van de Ghinste
> On 22 May 2020, at 20:20, Alexander Chen <[email protected]> wrote:
>
> Hi,
>
> I want to re-write a function maximumBy (its an assignment).
>
> However, I don't get how it works.
>
> >maximumBy compare [1,53,9001, 10]
> 9001
>
> but what does it actually do to get there?
>
> thanks in advance.
>
> 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/20200522/f31e65e2/attachment-0001.html>
------------------------------
Message: 3
Date: Fri, 22 May 2020 20:52:03 +0200 (CEST)
From: Alexander Chen <[email protected]>
To: "Daniel van de Ghinste (Lord_Luvat)"
<[email protected]>, The Haskell-Beginners Mailing List -
Discussion of primarily beginner-level topics related to Haskell
<[email protected]>
Subject: Re: [Haskell-beginners] MaximumBy
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
its in the Data.List
May 22, 2020 8:33:33 PM CEST "Daniel van de Ghinste (Lord_Luvat)"
<[email protected]> wrote:Hi,
Maybe I’m on a different version, but I don’t see a function called maximumBy
in my base Prelude. Can you give us a type signature for the function? If
you’re not sure how to do that just type:
Prelude> :t maximumBy
In your ghci interpreter and it should return the type signature of whatever
you have after ‘:t ‘ (this works for compound expressions too if you put them
in brackets)
Perhaps maximumBy is what you’re meant to call your rewrite of the existing
function I see called ‘maximum’ (seems to do the same thing). Let me know if
thats the case and I can explain how it works.
Best regards,
Daniel van de Ghinste
On 22 May 2020, at 20:20, Alexander Chen <[email protected]> wrote:
Hi,
I want to re-write a function maximumBy (its an assignment).
However, I don't get how it works.
>maximumBy compare [1,53,9001, 10]
9001
but what does it actually do to get there?
thanks in advance.
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/20200522/3da57ad9/attachment-0001.html>
------------------------------
Message: 4
Date: Fri, 22 May 2020 21:02:09 +0200
From: Magnus Therning <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Understanding types and constructors
more thoroughly
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Josh Diamond <[email protected]> writes:
> Actually I worked it out, no need for any help so please ignore
Please consider writing how you solved it.
Sometimes when searching the internet I come upon questions that the
questioner then solve on her/his own, but _I_ don't get to see the
solution. It robs me of an answer to my question, and the questioner is
robbed of feedback and further insights.
/M
--
Magnus Therning OpenPGP: 0x927912051716CE39
email: [email protected]
twitter: magthe http://magnus.therning.org/
You can't depend on your judgement when your imagination is out of focus.
— Mark Twain
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200522/f0972d2d/attachment-0001.sig>
------------------------------
Message: 5
Date: Fri, 22 May 2020 21:10:43 +0200
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] MaximumBy
Message-ID: <20200522191043.GA14834@extensa>
Content-Type: text/plain; charset=iso-8859-1
Hello Alexander,
Il 22 maggio 2020 alle 20:20 Alexander Chen ha scritto:
> Hi,
>
> I want to re-write a function maximumBy (its an assignment).
>
> However, I don't get how it works.
>
> >maximumBy compare [1,53,9001, 10]
> 9001
>
> but what does it actually do to get there?
Do you know how to use foldr and friends?
------------------------------
Message: 6
Date: Fri, 22 May 2020 21:13:49 +0200
From: Ut Primum <[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] MaximumBy
Message-ID:
<canjdmkjw6avdurgsq5x4eq-rciavtwdzrjnotxlcbfb3k1c...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
if it is ok for you to work only with lists (not generic foldables), you
could write it this way:
maximumBy cmp [x] = x
maximumBy cmp (x:y:xs) = if (cmp x y)==GT then maximumBy cmp (x:xs) else
maximumBy cmp (y:xs)
the signature is
maximumBy :: (a -> a -> Ordering) -> [a] -> a
Ut
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Mail
priva di virus. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_-9203042563784922724_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Il giorno ven 22 mag 2020 alle ore 20:53 Alexander Chen <
[email protected]> ha scritto:
> Hi,
>
> maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
>
> its in the Data.List
>
> May 22, 2020 8:33:33 PM CEST "Daniel van de Ghinste (Lord_Luvat)" <
> [email protected]> wrote:
>
> Hi,
>
> Maybe I’m on a different version, but I don’t see a function called
> maximumBy in my base Prelude. Can you give us a type signature for the
> function? If you’re not sure how to do that just type:
> Prelude> :t maximumBy
> In your ghci interpreter and it should return the type signature of
> whatever you have after ‘:t ‘ (this works for compound expressions too if
> you put them in brackets)
>
> Perhaps maximumBy is what you’re meant to call your rewrite of the
> existing function I see called ‘maximum’ (seems to do the same thing). Let
> me know if thats the case and I can explain how it works.
>
>
> Best regards,
> Daniel van de Ghinste
>
> On 22 May 2020, at 20:20, Alexander Chen <[email protected]> wrote:
>
> Hi,
>
> I want to re-write a function maximumBy (its an assignment).
>
> However, I don't get how it works.
>
> >maximumBy compare [1,53,9001, 10]
> 9001
>
> but what does it actually do to get there?
>
> thanks in advance.
>
> best,
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Mail
priva di virus. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20200522/f3157098/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 143, Issue 10
******************************************