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:  Understanding some notation (Jack Henahan)
   2. Re:  Understanding some notation (Benjamin Edwards)


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

Message: 1
Date: Sun, 26 Jun 2011 18:48:00 -0400
From: Jack Henahan <[email protected]>
Subject: Re: [Haskell-beginners] Understanding some notation
To: Mike Meyer <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

I know the type signature of (++), I'm just not seeing `n` as a list, I 
suppose. I'm reading it as being the Int that is passed to splitAt, though 
perhaps my thought process is just wonky.

On Jun 26, 2011, at 6:41 PM, Mike Meyer wrote:

> On Sun, 26 Jun 2011 18:14:44 -0400
> Jack Henahan <[email protected]> wrote:
> 
>> I have this code snippet:
>> 
>>    import Data.List
>> 
>>    aaa x (y:ys) = case splitAt x (y:ys) of
>>      (n, x:xs) -> x:n ++ xs
>>      (n, xs) -> n ++ xs
>> 
>> I understand what it's meant to do (that is, split a list at index `x` and 
>> make a new list with that element at the head, or just return the list when 
>> given a singleton), but my brain is failing me when trying to read the 
>> notation `n ++ xs`.
>> 
>> Is there some obvious explanation that I'm just forgetting?
> 
> Yes. But more importantly, you're forgetting that you can ask the REPL:
> 
> Prelude> :t (++)
> (++) :: [a] -> [a] -> [a]
> 
> So it takes two lists and produces a new one. Trying it:
> 
> Prelude> [1, 2, 3] ++ [4, 5, 6]
> [1,2,3,4,5,6]
> 
> So ++ concatenates it's operands.
> 
>   <mike
> -- 
> Mike Meyer <[email protected]>           http://www.mired.org/
> Independent Software developer/SCM consultant, email for more information.
> 
> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



====
"Computer Science is no more about computers than astronomy is about 
telescopes."
-- Edsger Dijkstra
====

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 398E692F.asc
Type: application/x-apple-msg-attachment
Size: 24295 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110626/a19c9466/attachment-0001.bin>
-------------- next part --------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 881 bytes
Desc: This is a digitally signed message part
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110626/a19c9466/attachment-0001.pgp>

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

Message: 2
Date: Sun, 26 Jun 2011 23:55:53 +0100
From: Benjamin Edwards <[email protected]>
Subject: Re: [Haskell-beginners] Understanding some notation
To: Jack Henahan <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

On 26 June 2011 23:48, Jack Henahan <[email protected]> wrote:

> I know the type signature of (++), I'm just not seeing `n` as a list, I
> suppose. I'm reading it as being the Int that is passed to splitAt, though
> perhaps my thought process is just wonky.
>

Look at the type of splitAt, the answers are all in the types :)

splitAt :: Int -> [a] -> ([a],[a])

So when you do a case match on the result of

splitAt x (y:ys)

you must be matching on a tuple of lists, because that's what the return
type of the list is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110626/9be19b1a/attachment.htm>

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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 36, Issue 67
*****************************************

Reply via email to