Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/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. Re: Question about Ord for lists and multi-dimensional lists
(Kim-Ee Yeoh)
2. Re: foldr problem (akash g)
----------------------------------------------------------------------
Message: 1
Date: Mon, 3 Mar 2014 14:25:12 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question about Ord for lists and
multi-dimensional lists
Message-ID:
<CAPY+ZdThs_=avujrq9nzuuuyfqmy_1oqsadxs4yxhgtqqyc...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
On Mon, Mar 3, 2014 at 12:33 PM, Tyler Huffman <[email protected]>wrote:
> Could anybody shed some light on what I'm seeing?
This is the standard lex order you see in dictionaries.
The word "a" is followed by "aardvark" which is in turn followed by "an".
Similarly [1] is followed by [1,2] which is in turn followed by [1,2,4].
(It's possible to override the order.)
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140303/8c26e7d7/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 3 Mar 2014 16:33:22 +0530
From: akash g <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldr problem
Message-ID:
<caliga_cvtg3tejqsxx3muwogtgdxeck-xszqzn0pmr6npqq...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Or you can try foldr1, which doesn't need a terminating value.
Here's its definition from the Standard Prelude
foldr1 :: (a -> a -> a) -> [a] -> afoldr1 _ [x]
= xfoldr1 f (x:xs) = f x (foldr1 f xs)foldr1 _ []
= errorEmptyList "foldr1"
On Mon, Mar 3, 2014 at 12:21 PM, Roelof Wobben <[email protected]> wrote:
> Thanks,
>
> This did the job:
>
> import Data.Char
>
> x = foldr max 0 [5,10,2,8,1]
>
> -- Note that comments are preceded by two hyphens
> {- or enclosed
> in curly brace/hypens pairs. -}
> main = print x
>
> Roelof
>
>
> Emanuel Koczwara schreef op 2-3-2014 22:51:
>
> Hi,
>
> W dniu 02.03.2014 22:44, Roelof Wobben pisze:
>
> Hello,
>
> I now have to use foldr to find the max value in a list.
>
> So I do this:
>
> import Data.Char
>
> x = foldr max [5,10,2,8.1]
> -- Note that comments are preceded by two hyphens
> {- or enclosed
> in curly brace/hypens pairs. -}
> main = print x
>
> But now I see this error message:
>
> main.hs@7:8-7:13
> No instance for (Show ([[t0]] -> [t0])) arising from a use of `print'
> Possible fix: add an instance declaration for (Show ([[t0]] -> [t0])) In
> the expression: print x In an equation for `main': main = print x
>
>
>
> Please look at foldr type and documentation. There is one argument
> missing in your code.
>
> Regards,
> Emanuel
>
>
>
> _______________________________________________
> Beginners mailing
> [email protected]http://www.haskell.org/mailman/listinfo/beginners
>
>
>
>
> ------------------------------
> <http://www.avast.com/>
>
> Dit e-mailbericht bevat geen virussen en malware omdat avast!
> Antivirus<http://www.avast.com/>actief is.
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140303/27b7c953/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 69, Issue 7
****************************************