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:  Unmaybe (Kim-Ee Yeoh)
   2. Re:  How to improve lazyness of a foldl (and memory
      footprint) (Giacomo Tesio)
   3. Re:  Unmaybe (Adrian May)
   4. Re:  Unmaybe (Brent Yorgey)
   5.  find by (Julian Arni)


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

Message: 1
Date: Wed, 15 May 2013 19:22:28 +0700
From: Kim-Ee Yeoh <[email protected]>
Subject: Re: [Haskell-beginners] Unmaybe
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <capy+zdqird26r9f8ozfqndali57wgve27_ipskxvqhoyzo0...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Wed, May 15, 2013 at 9:58 AM, Adrian May
<[email protected]>wrote:

> The list indices ati and bti are used only once: to retrieve the (first)
>> item matching the predicate. Might Data.List.find be a better fit?
>>
>
> No, I use them via t1 and t2 to figure out which row to put the squiggle
> on. The attached picture might put it all in perspective.
>
>>
D'oh. Didn't see the later references, sorry.

Something to think about is: how would you document "my coordinate system"
as you wrote in your comment? Highly visual things like these are
challenging to describe even for verbal-thinking types.

Probably sticking the picture in png/pdf format and linking to it in the
comments is a good a solution as any.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130515/e0c4ee8b/attachment-0001.htm>

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

Message: 2
Date: Wed, 15 May 2013 14:55:43 +0200
From: Giacomo Tesio <[email protected]>
Subject: Re: [Haskell-beginners] How to improve lazyness of a foldl
        (and memory footprint)
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAHL7psE9goobH6ssPGnQKG5wcaS-zhiRrQjmOM=6y-qay35...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Turned out that I didn't need fold at all, just a proper groupBy.

As for these lines

module Main (
>
>     main
>
> ) where
>
>
they were generated by Leksah. Do you suggest to remove them? And what
about Leksah as an IDE: do you use it?


Giacomo


On Wed, May 15, 2013 at 9:35 AM, Giacomo Tesio <[email protected]> wrote:

> Thanks a lot!
>
> Yesterday on freenode's #haskell channel Cane noted how my laziness
> problem reside in the foldl use in foldTradingSample.
> I have to turn it into a foldr (but I'm still unsure how...)
>
>
> Giacomo
>
>
> On Wed, May 15, 2013 at 12:46 AM, Henk-Jan van Tuyl <[email protected]>wrote:
>
>> On Tue, 14 May 2013 11:22:27 +0200, Giacomo Tesio <[email protected]>
>> wrote:
>>
>>  Hi, I'm trying to improve a small haskell program of mine.
>>>
>> :
>>
>> Some remarks:
>>
>> 0) Use hlint (available on Hackage) for improvement suggestions
>> 1) You don't have to write the module heading in Main.hs, it is not a
>> library (why export main?)
>> 2) Change "print" to "putStrLn" if you want to display messages without
>> quotes
>> 2) switchArgs is only partially defined, add something like:
>>      switchArgs [x] = putStrLn $ "Unknown tool: " ++ x
>> 3) Use shorter lines, for example change:
>>
>>   importTrades outDir csvFile = transformFile csvFile (foldTradingSample.
>> **getTickWriteTrades)   (saveTradingSamples outDir)
>>
>> to:
>>
>>   importTrades outDir csvFile =
>>     transformFile
>>       csvFile
>>       (foldTradingSample.**getTickWriteTrades)
>>       (saveTradingSamples outDir)
>> 4) It is considered good practice, to write the function
>>    composition operator between spaces (change f.g to f . g)
>>
>> I have analyze your software further to see how sufficient laziness can
>> be reached.
>>
>> Regards,
>> Henk-Jan van Tuyl
>>
>>
>> --
>> Folding@home
>> What if you could share your unused computer power to help find a cure?
>> In just 5 minutes you can join the world's biggest networked computer and
>> get us closer sooner. Watch the video.
>> http://folding.stanford.edu/
>>
>>
>> http://Van.Tuyl.eu/
>> http://members.chello.nl/**hjgtuyl/tourdemonad.html<http://members.chello.nl/hjgtuyl/tourdemonad.html>
>> Haskell programming
>> --
>>
>> ______________________________**_________________
>> Beginners mailing list
>> [email protected]
>> 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/20130515/acff42af/attachment-0001.htm>

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

Message: 3
Date: Wed, 15 May 2013 22:37:56 +0800
From: Adrian May <[email protected]>
Subject: Re: [Haskell-beginners] Unmaybe
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cad-ubzfnk8sfm8qgr_nuyndjonczq46y-l2ophpaccgmpgd...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I seem to have come up with something:

main = putStrLn $ show $
  "Foo".:.100 |:|
  "Bar".:.10 >:> (
                 "Ket".:.20 >^> "Pod".:.1 |^|
                 "Zig".:.30
                 ) >:> "Erm".:.15
                                          >@> "Nuk".:.50
                            >@> "Din".:.30

says:

1:Foo=0.0->100.0
2:Bar=0.0->10.0
3:Ket=10.0->30.0
4:Pod=30.0->31.0
5:Zig=10.0->40.0
6:Erm=40.0->55.0
7:Nuk=31.0->81.0
8:Din=30.0->60.0

I'd best give names to those forks though otherwise the whole project plan
will break whenever I insert a new one. Can I give a parameter to an
operator? Like:

task1 `fork "name"` taskb

or:

task1 ( >^> "name" ) taskb

Adrian.





On 15 May 2013 20:22, Kim-Ee Yeoh <[email protected]> wrote:

> On Wed, May 15, 2013 at 9:58 AM, Adrian May <
> [email protected]> wrote:
>
>> The list indices ati and bti are used only once: to retrieve the (first)
>>> item matching the predicate. Might Data.List.find be a better fit?
>>>
>>
>> No, I use them via t1 and t2 to figure out which row to put the squiggle
>> on. The attached picture might put it all in perspective.
>>
>>>
> D'oh. Didn't see the later references, sorry.
>
> Something to think about is: how would you document "my coordinate system"
> as you wrote in your comment? Highly visual things like these are
> challenging to describe even for verbal-thinking types.
>
> Probably sticking the picture in png/pdf format and linking to it in the
> comments is a good a solution as any.
>
> -- Kim-Ee
>
> _______________________________________________
> 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/20130515/74b1bbb6/attachment-0001.htm>

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

Message: 4
Date: Wed, 15 May 2013 11:19:54 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Unmaybe
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Wed, May 15, 2013 at 10:37:56PM +0800, Adrian May wrote:
> 
> I'd best give names to those forks though otherwise the whole project plan
> will break whenever I insert a new one. Can I give a parameter to an
> operator? Like:
> 
> task1 `fork "name"` taskb
>
> task1 ( >^> "name" ) taskb

No, unfortunately neither of those is possible.

-Brent



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

Message: 5
Date: Wed, 15 May 2013 12:11:19 -0400
From: Julian Arni <[email protected]>
Subject: [Haskell-beginners] find by
To: [email protected]
Message-ID:
        <CANct4CQyD7-ECb8VK+Dv=T3DRp9P=b4yce_jznm8u0zfkvo...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I have a function that, simplifying a little, looks like this:

  fn :: [a] -> a
  fn = (head .) . takeWhile $ (\_ -> True)

>From this, I want a function with the signature fn' :: [(x,a)] -> (x,a)
such that:

    snd $ fn' (zip [x] [a]) = fn [a]

I can see ways of doing this by altering fn, or by repeating some of fn in
the definition of fn', or (because in this case I know that if fn xs = x,
fn is returning the first x in xs and not any others), by doing something
nasty like:

  fn' xs = xs !! fromMaybe 0 (findIndex (\(_,a) -> a == fn (snd $ unzip
xs)) xs )

But it seems to me like there should be prettier solutions to this (that *do
not* involve changing the definition of fn). After all, this doesn't seem
like a rare pattern.

Anyone know if in fact there's a better way to go about it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130515/35038f5a/attachment.htm>

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

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


End of Beginners Digest, Vol 59, Issue 16
*****************************************

Reply via email to