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:  reorganizing lists (Bryce Verdier)
   2. Re:  How to unnest "do" (Emmanuel Touzery)
   3. Re:  reorganizing lists (Bryce Verdier)
   4. Re:  reorganizing lists (Sylvain HENRY)
   5.  Looking for a 20/min day study partner (Heath Matlock)
   6. Re:  Looking for a 20/min day study partner (Darren Grant)
   7. Re:  How to interact with a process (Miguel Negrao)


----------------------------------------------------------------------

Message: 1
Date: Mon, 28 Jan 2013 11:51:58 -0800
From: Bryce Verdier <bryceverd...@gmail.com>
Subject: Re: [Haskell-beginners] reorganizing lists
To: beginners@haskell.org
Message-ID: <5106d6de.9050...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 01/28/2013 11:24 AM, Brent Yorgey wrote:
> On Mon, Jan 28, 2013 at 10:37:53AM -0800, Bryce Verdier wrote:
>> 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.
> This can be done using the 'transpose' function from Data.List.
>
> -Brent
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

That was exactly what I was looking for. Thank you Brent!

Bryce



------------------------------

Message: 2
Date: Mon, 28 Jan 2013 21:24:47 +0100
From: Emmanuel Touzery <etouz...@gmail.com>
Subject: Re: [Haskell-beginners] How to unnest "do"
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <cac42rekevflwzjcj6oustte1pkfbmqcmd4r3rpyygvwffqo...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

>
> Sometimes it's hard to tell if Haskell is the most beautiful language
> or the most abstract nonsense. ;)
>

Amen. ;-)


>
> 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]).
>

I will look at this more in depth this week-end, really thank you for the
heads up! This stuff is really a bit crazy, but somehow I still like it ;-)

Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130128/6ef97726/attachment-0001.htm>

------------------------------

Message: 3
Date: Mon, 28 Jan 2013 13:50:34 -0800
From: Bryce Verdier <bryceverd...@gmail.com>
Subject: Re: [Haskell-beginners] reorganizing lists
To: beginners@haskell.org
Message-ID: <5106f2aa.6020...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 01/28/2013 11:32 AM, Martin Drautzburg wrote:
> On Monday, 28. January 2013 19:37:53 Bryce Verdier wrote:
>> 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.
> Something like this?
>       groupMe  = foldl (\[rx,ry] [x,y] -> [x:rx,y:ry]) [[],[]]
>
>
> *Main> groupMe [[1,2],[1,3],[2,3]]
> [[2,1,1],[3,3,2]]
Thank you all for your responses. This is what I ultimately went with 
(pasted below). If anyone would like to share a way to improve this 
(because I know it can be), please share. I'm still learning. :)

module Main where

import qualified Data.Text as T
import qualified Data.Text.IO as TI (readFile)
import Data.List (transpose)
import Numeric.GSL.Fitting.Linear (linear)
import Data.Packed.Vector (fromList)

buildList :: IO [[T.Text]]
buildList = TI.readFile "lin_reg_data.txt" >>= return . transpose . map 
(T.split (=='_')) . T.lines

main :: IO ()
main = do
     values <- buildList
     let values2 = map (fromList . map (\x -> read (T.unpack x):: 
Double)) values
     print [linear (head values2) (last values2)]



Warm regards,
Bryce



------------------------------

Message: 4
Date: Tue, 29 Jan 2013 02:43:31 +0100
From: Sylvain HENRY <hsy...@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:
        <capmptcwquwhe05ggxog6lpbct96bnrowizbf0+rfnagantz...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

What is the point of using Text here?

You may rewrite buildList as follows (using <$> from Control.Applicative):
buildList = transpose . map (T.split (=='_')) . T.lines <$> TI.readFile
"lin_reg_data.txt"

Regards
Sylvain



2013/1/28 Bryce Verdier <bryceverd...@gmail.com>

> On 01/28/2013 11:32 AM, Martin Drautzburg wrote:
>
>> On Monday, 28. January 2013 19:37:53 Bryce Verdier wrote:
>>
>>> 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.
>>>
>> Something like this?
>>         groupMe  = foldl (\[rx,ry] [x,y] -> [x:rx,y:ry]) [[],[]]
>>
>>
>> *Main> groupMe [[1,2],[1,3],[2,3]]
>> [[2,1,1],[3,3,2]]
>>
> Thank you all for your responses. This is what I ultimately went with
> (pasted below). If anyone would like to share a way to improve this
> (because I know it can be), please share. I'm still learning. :)
>
>
> module Main where
>
> import qualified Data.Text as T
> import qualified Data.Text.IO as TI (readFile)
> import Data.List (transpose)
> import Numeric.GSL.Fitting.Linear (linear)
> import Data.Packed.Vector (fromList)
>
> buildList :: IO [[T.Text]]
> buildList = TI.readFile "lin_reg_data.txt" >>= return . transpose . map
> (T.split (=='_')) . T.lines
>
> main :: IO ()
> main = do
>     values <- buildList
>     let values2 = map (fromList . map (\x -> read (T.unpack x):: Double))
> values
>     print [linear (head values2) (last values2)]
>
>
>
> Warm regards,
> Bryce
>
>
> ______________________________**_________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130129/9fcd4620/attachment-0001.htm>

------------------------------

Message: 5
Date: Mon, 28 Jan 2013 22:00:55 -0600
From: Heath Matlock <lambda.he...@gmail.com>
Subject: [Haskell-beginners] Looking for a 20/min day study partner
To: beginners@haskell.org
Message-ID:
        <CAMd2kOd6cxZNBQ9NFNDgKS3DLZ_YEQ7=U6=J_dwycqQfWSr=c...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Would anyone be willing to spend 20 minutes each learning Haskell and the
concepts surrounding it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130128/667b5a2e/attachment-0001.htm>

------------------------------

Message: 6
Date: Mon, 28 Jan 2013 21:11:59 -0800
From: Darren Grant <therealklu...@gmail.com>
Subject: Re: [Haskell-beginners] Looking for a 20/min day study
        partner
To: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <CA+jD6SgXeb=1k0G-PbM3zrK7QKC_hwa1vfJ+EhmxDn=puz3...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I might be interested. How were you thinking of coordinating?

I am also following along here:

http://ureddit.com/class/69577/introduction-to-haskell

Cheers,
Darren
On 2013-01-28 8:01 PM, "Heath Matlock" <lambda.he...@gmail.com> wrote:

> Would anyone be willing to spend 20 minutes each learning Haskell and the
> concepts surrounding it?
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130128/313267eb/attachment-0001.htm>

------------------------------

Message: 7
Date: Tue, 29 Jan 2013 10:01:30 +0000
From: Miguel Negrao <miguel.negrao-li...@friendlyvirus.org>
Subject: Re: [Haskell-beginners] How to interact with a process
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID: <ee1c0d10-a80c-4f84-9015-d025d6cf6...@friendlyvirus.org>
Content-Type: text/plain; charset=windows-1252


A 28/01/2013, ?s 19:36, Martin Drautzburg escreveu:

> Hello all,
> 
> I know how to play a Midi file. I also know how to read the keyboard. But I 
> don't know how to bring the two together such that I can start and stop 
> playing from the keyboard.
> 
> It is not required (just nice to have) that the console remains responsive 
> while the midi file plays. But it is essential that I can stop the 
> performance.
> 
> Is this difficult?

I?m also a beginner, so take this with a grain of salt:  I suppose the midi 
playing command doesn?t block until finished playing otherwise you couldn?t 
stop midway. If that is the case you can do something like

main =  forever readFromConsole

readFromConsole = do
        in <- getLine
        processInput in

processInput ?start? = startMidi
processInput ?stop? = stopMidi

where startMidi and stopMidi are functions.

best,
Miguel





------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 55, Issue 33
*****************************************

Reply via email to