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. Re:  Date Time in Haskell (Michael Orlitzky)
   2. Re:  can I have a case statement with a pattern   matching
      (Jonathan Sk?rstedt)
   3. Re:  can I have a case statement with a pattern   matching
      (Alexey Shmalko)
   4.  cabal problem (Roelof Wobben)
   5. Re:  cabal problem (Alex Hammel)


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

Message: 1
Date: Thu, 14 May 2015 11:23:08 -0400
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Date Time in Haskell
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

On 05/14/2015 06:25 AM, Kostiantyn Rybnikov wrote:
> Hi Dananji!
> 
> First of all, for more explicit failure-handling I suggest using "readMay"
> from package "safe" [0] instead of "read" whenever possible.

This is always a good idea, and someone finally added it to the base
library (in 4.6.0.0) as "readMaybe".

  ghci> import Text.Read ( readMaybe )
  ghci> readMaybe "Hello, world!" :: Maybe Integer
  Nothing



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

Message: 2
Date: Thu, 14 May 2015 18:27:57 +0200
From: Jonathan Sk?rstedt <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] can I have a case statement with a
        pattern matching
Message-ID:
        <cad6iywyd+omhi3t1pkodggjh7s_jchrb_cfkcmfvc3rdexf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I'm nitpicking here, but it can be improved a bit

doubleEveryOther :: [Integer] -> [Integer]
doubleEveryOther [] = []
doubleEveryOther [x] = [x]
doubleEveryOther (x:y:xs) = x : 2 * y : doubleEveryOther (xs)

2015-05-14 8:48 GMT+02:00 Nishant <[email protected]>:

> This will double very second digit in list.  To do from right, just
> reverse the list first and then apply doubleEverySecond and then reverse
> back.
>
>
>
> doubleEveryOther :: [Integer] -> [Integer]
>
> doubleEveryOther [] = []
> doubleEveryOther (x : []) = [x]
> doubleEveryOther (x : y : []) = x : (2 * y) : []
> doubleEveryOther (x:y:xs) = x : (2 * y) : doubleEveryOther (xs)
>
>
> On Wed, May 13, 2015 at 10:22 PM, Roelof Wobben <[email protected]> wrote:
>
>> Hello,
>>
>> I try to make make the assignment of CIS194 where I must multiply every
>> second item from the right by 2
>>
>> So I thought this could be working :
>>
>> -- | Convert a digit to a reversed list for example 123 becomes [3,2,1]
>> revtoDigits :: Integer -> [Integer]
>> revtoDigits number
>>   | number <= 0 = []
>>   | number > 0 = number`mod` 10 : revtoDigits (number `div` 10)
>>
>> -- | Convert a digit to a list for example 123 becomes [1,2,3]
>> toDigits :: Integer -> [Integer]
>> toDigits number
>>   | number <= 0 = []
>>   | number > 0 = toDigitsAcc [] number
>>
>> toDigitsAcc:: [Integer] -> Integer -> [Integer]
>> toDigitsAcc acc number
>>   | number <= 0  = acc
>>   | number > 0 =  toDigitsAcc ((number `mod` 10) : acc) (number `div` 10)
>>
>> doubleEveryOther :: [Integer] -> [Integer]
>> doubleEveryOther list  = case (length list) `mod` 2 of 0 ->
>> doubleEveryOther [] = []
>> doubleEveryOther (x:y:xs) = x*2 : y : xs
>>                               (length list) `mod` 2 of 0 ->
>> doubleEveryOther [] = []
>> doubleEveryOther (x:y:xs) = x : y*2 : xs
>>
>>
>> -- | The main entry point.
>> main = print $ doubleEveryOther [1,2,3]
>>
>>
>> but apperantly you cannot have pattern matching after a case statement
>> because I get a error on the =  of a empty list
>>
>> Roelof
>>
>>
>> ---
>> Dit e-mailbericht is gecontroleerd op virussen met Avast
>> antivirussoftware.
>> http://www.avast.com
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
>
> --
> Nishant
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Jonathan Sk?rstedt
Bergsg?rdsg?rdet 39
Lgh 1108
424 32 G?teborg
Mobil: 073 - 76 20 20 7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150514/c6f26999/attachment-0001.html>

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

Message: 3
Date: Thu, 14 May 2015 16:46:48 +0000
From: Alexey Shmalko <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] can I have a case statement with a
        pattern matching
Message-ID:
        <cafc2pc6c7spmcqwbentembgfs8xtmewwg4tag-q8cbmwpu0...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Then it could be:

doubleEveryOther :: [Integer] -> [Integer]
doubleEveryOther (x:y:xs) = x : 2 * y : doubleEveryOther xs
doubleEveryOther x = x

It could also be generalized to Num's ;)

On Thu, May 14, 2015 at 7:28 PM Jonathan Sk?rstedt <
[email protected]> wrote:

> I'm nitpicking here, but it can be improved a bit
>
> doubleEveryOther :: [Integer] -> [Integer]
> doubleEveryOther [] = []
> doubleEveryOther [x] = [x]
> doubleEveryOther (x:y:xs) = x : 2 * y : doubleEveryOther (xs)
>
> 2015-05-14 8:48 GMT+02:00 Nishant <[email protected]>:
>
>> This will double very second digit in list.  To do from right, just
>> reverse the list first and then apply doubleEverySecond and then reverse
>> back.
>>
>>
>>
>> doubleEveryOther :: [Integer] -> [Integer]
>>
>> doubleEveryOther [] = []
>> doubleEveryOther (x : []) = [x]
>> doubleEveryOther (x : y : []) = x : (2 * y) : []
>> doubleEveryOther (x:y:xs) = x : (2 * y) : doubleEveryOther (xs)
>>
>>
>> On Wed, May 13, 2015 at 10:22 PM, Roelof Wobben <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> I try to make make the assignment of CIS194 where I must multiply every
>>> second item from the right by 2
>>>
>>> So I thought this could be working :
>>>
>>> -- | Convert a digit to a reversed list for example 123 becomes [3,2,1]
>>> revtoDigits :: Integer -> [Integer]
>>> revtoDigits number
>>>   | number <= 0 = []
>>>   | number > 0 = number`mod` 10 : revtoDigits (number `div` 10)
>>>
>>> -- | Convert a digit to a list for example 123 becomes [1,2,3]
>>> toDigits :: Integer -> [Integer]
>>> toDigits number
>>>   | number <= 0 = []
>>>   | number > 0 = toDigitsAcc [] number
>>>
>>> toDigitsAcc:: [Integer] -> Integer -> [Integer]
>>> toDigitsAcc acc number
>>>   | number <= 0  = acc
>>>   | number > 0 =  toDigitsAcc ((number `mod` 10) : acc) (number `div` 10)
>>>
>>> doubleEveryOther :: [Integer] -> [Integer]
>>> doubleEveryOther list  = case (length list) `mod` 2 of 0 ->
>>> doubleEveryOther [] = []
>>> doubleEveryOther (x:y:xs) = x*2 : y : xs
>>>                               (length list) `mod` 2 of 0 ->
>>> doubleEveryOther [] = []
>>> doubleEveryOther (x:y:xs) = x : y*2 : xs
>>>
>>>
>>> -- | The main entry point.
>>> main = print $ doubleEveryOther [1,2,3]
>>>
>>>
>>> but apperantly you cannot have pattern matching after a case statement
>>> because I get a error on the =  of a empty list
>>>
>>> Roelof
>>>
>>>
>>> ---
>>> Dit e-mailbericht is gecontroleerd op virussen met Avast
>>> antivirussoftware.
>>> http://www.avast.com
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>
>>
>>
>> --
>> Nishant
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
>
> --
> Jonathan Sk?rstedt
> Bergsg?rdsg?rdet 39
> Lgh 1108
> 424 32 G?teborg
> Mobil: 073 - 76 20 20 7
>  _______________________________________________
> 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/20150514/933561f2/attachment-0001.html>

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

Message: 4
Date: Thu, 14 May 2015 23:14:54 +0200
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] cabal problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hello,,

I want to use the module Digits which according to Hoogle is in Data.Digits

But when I do cabal install Data.Digits I see this error message :

cabal install Data.Digits
cabal: The file does not exist 'Data.Digits'

What do I do wrong ?

Roelof


---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
http://www.avast.com



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

Message: 5
Date: Thu, 14 May 2015 21:25:27 +0000
From: Alex Hammel <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] cabal problem
Message-ID:
        <ca+_xferd9dn-mwzurh96eddqs2bqsjyv76cfdx74dzeg030...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

`Data.Digits` is the name of the module. The name of the package is
`digits`. Therefore: $(cabal install digits)

`cabal` installs packages, which may contain many modules

On Thu, 14 May 2015 at 14:14 Roelof Wobben <[email protected]> wrote:

> Hello,,
>
> I want to use the module Digits which according to Hoogle is in Data.Digits
>
> But when I do cabal install Data.Digits I see this error message :
>
> cabal install Data.Digits
> cabal: The file does not exist 'Data.Digits'
>
> What do I do wrong ?
>
> Roelof
>
>
> ---
> Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
> http://www.avast.com
>
> _______________________________________________
> 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/20150514/23a61899/attachment.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 83, Issue 39
*****************************************

Reply via email to