Send Beginners mailing list submissions to
beginners@haskell.org
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
beginners-requ...@haskell.org
You can reach the person managing the list at
beginners-ow...@haskell.org
When replying, please edit your Subject line so it is more specific
than Re: Contents of Beginners digest...
Today's Topics:
1. Re: How to unnest do (Daniel Trstenjak)
2. reorganizing lists (Bryce Verdier)
3. Re: reorganizing lists (Ozgur Akgun)
4. Re: reorganizing lists (divyanshu ranjan)
5. Re: reorganizing lists (Bryce Verdier)
6. Re: reorganizing lists (Brent Yorgey)
7. Re: reorganizing lists (Martin Drautzburg)
8. How to interact with a process (Martin Drautzburg)
--
Message: 1
Date: Mon, 28 Jan 2013 15:27:44 +0100
From: Daniel Trstenjak daniel.trsten...@gmail.com
Subject: Re: [Haskell-beginners] How to unnest do
To: beginners@haskell.org
Message-ID: 20130128142744.GA16791@machine
Content-Type: text/plain; charset=us-ascii
Hi Emmanuel,
On Sun, Jan 27, 2013 at 09:46:30PM +0100, Emmanuel Touzery wrote:
Thank you. I thought it might be, but it isn't exactly intuitive for me at
this point. I'll read some more about that monad.
Sometimes it's hard to tell if Haskell is the most beautiful language
or the most abstract nonsense. ;)
Let's look at the Monad instance for the function (r - a):
instance Monad ((-) r) where
-- return :: a - (r - a)
return a = \_ - a
-- (=) :: (r - a) - (a - r - b) - (r - b)
left = right = \r - right (left r) r
'return' creates a function ignoring its argument and just returning 'a'.
'=' creates a function with the argument 'r'. The function 'left' is
called with 'r' and the function 'right' is called with the result of
'left' and 'r'.
Now let's look at the 'sequence' function:
sequence ms = foldr k (return []) ms
where
k m ms = do
x - m
xs - ms
return (x : xs)
It's easier to see what happens if we rewrite 'k':
k m ms = m = (\x - (ms = \xs - return (x : xs)))
We saw that '=' creates a function with one argument, that argument
is the String containing the file contents, 'x' is the return value
of one sequenced function which is combined (:) with the previous
ones.
At the end we have the function (String - [String]).
Greetings,
Daniel
--
Message: 2
Date: Mon, 28 Jan 2013 10:37:53 -0800
From: Bryce Verdier bryceverd...@gmail.com
Subject: [Haskell-beginners] reorganizing lists
To: beginners@haskell.org
Message-ID: 5106c581.1050...@gmail.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi All,
At the moment I have a list of lists. The inner list is a coordinate,
like (x,y) but is [x,y] instead. What I would like to do is group all
the x's into one list, and the y's into another. I know I can do this
with calling 2 maps on the container, but I would also like to do this
in one iteration.
Does anyone have any ideas?
Thanks in advance,
Bryce
--
Message: 3
Date: Mon, 28 Jan 2013 18:42:58 +
From: Ozgur Akgun ozgurak...@gmail.com
Subject: Re: [Haskell-beginners] reorganizing lists
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell beginners@haskell.org
Message-ID:
calzazparl9ei5ce_ettvn+2xi9urlwuchmyp11brlza6gvj...@mail.gmail.com
Content-Type: text/plain; charset=utf-8
Hi,
On 28 January 2013 18:37, Bryce Verdier bryceverd...@gmail.com wrote:
I know I can do this with calling 2 maps on the container, but I would
also like to do this in one iteration.
As a learning experience, may I suggest you post the code you would have
written with two maps? Then we can try and improve on that to have only one
map.
Best,
--
Ozgur Akgun
-- next part --
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20130128/f234f5e8/attachment-0001.htm
--
Message: 4
Date: Tue, 29 Jan 2013 00:14:18 +0530
From: divyanshu ranjan idivyanshu.ran...@gmail.com
Subject: Re: [Haskell-beginners] reorganizing lists
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell beginners@haskell.org
Message-ID:
CAL9hw24QC5hJZcPoJdXv=fklaqadu664_u3ey_przf95meb...@mail.gmail.com
Content-Type: text/plain; charset=utf-8
Hi,
You can use foldl (\(fx, fy) [x,y] - (x:fx, y:fy)) ([],[])
Thanks
Divyanshu Ranjan
On Tue, Jan 29, 2013 at 12:07 AM, Bryce Verdier bryceverd...@gmail.comwrote:
Hi All,
At the moment I have a list of lists. The inner list is a coordinate, like
(x,y) but is [x,y] instead. What I would like to do is group all the x's
into one list