[Haskell-cafe] Thinking about an unlistN

2008-08-10 Thread Michael Feathers
I wrote this function the other day, and I was wondering if I'm missing something.. whether there is already a function or idiom around to do this. unlist3 :: (a - a - a - b) - [a] - b unlist3 f (x:y:z:xs) = f x y z I was also wondering whether the function can be generalized to N or

Re: [Haskell-cafe] Thinking about an unlistN

2008-08-10 Thread Michael Feathers
system however) Philip Neustrom wrote: I'm no expert, but it looks like the generalization of that would be some f that took a list: f :: [a] - b so what you'd have is a fold, right? foldr1 :: (a - a - a) - [a] - a Best, Philip Neustrom On Sun, Aug 10, 2008 at 11:47 AM, Michael Feathers

Re: [Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-07 Thread Michael Feathers
, Michael Feathers wrote: Decided a while ago to write some code to calculate the Mandelbrot set using the escape iterations algorithm. Discovered after mulling it about that I could just built it as an infinite list of infinite lists and then extract any rectangle of values that I wanted: type

[Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
I have some code that looks like this and I'm having trouble with it: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map windShift headings) (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x - [1..], full x] (nub . nub)

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
, so how about testing each list individually? This will narrow down the problem considerably. Michael Feathers wrote: I have some code that looks like this and I'm having trouble with it: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
considerably. Michael Feathers wrote: I have some code that looks like this and I'm having trouble with it: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map windShift headings) (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x - [1

Re: [Haskell-cafe] Having trouble with zip12..

2008-07-06 Thread Michael Feathers
) Silently makes SQL calls when evaluating a pure function 7) Yields an mile long stack trace Sorry all. Boredom made me do it, Michael Paul Visschers wrote: You're zipping 12 lists here, so how about testing each list individually? This will narrow down the problem considerably. Michael

[Haskell-cafe] Is there a nicer way to do this?

2008-07-06 Thread Michael Feathers
segment :: Int - [a] - [[a]] segment 0 _ = [] segment _ [] = [] segment n x = (take n x) : segment n (drop n x) I did a version of this which used splitAt but I wasn't sure whether it was going to buy me anything re performance that would justify its ugliness. Michael

[Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-06 Thread Michael Feathers
Decided a while ago to write some code to calculate the Mandelbrot set using the escape iterations algorithm. Discovered after mulling it about that I could just built it as an infinite list of infinite lists and then extract any rectangle of values that I wanted: type Point = (Double,

Re: [Haskell-cafe] An ugly zip3 problem..

2008-03-22 Thread Michael Feathers
Thanks! I learned a lot from that. Michael Tillmann Rendel wrote: Michael Feathers wrote: I'm working on something and it's looking rather ugly. essentially, it's an application of a low pass filer to a dataset. I would not consider your code ugly. it can be made shorter, though

Re: [Haskell-cafe] An ugly zip3 problem..

2008-03-22 Thread Michael Feathers
One thing that gets me about this solution.. as I was structuring mine I noticed that I was ending up with types like FilterWindow3 and functions like lowPass3. Inlining does eliminate them, but I wonder whether there is a good way to structure the computation generically so that it can be

[Haskell-cafe] An ugly zip3 problem..

2008-03-20 Thread Michael Feathers
and last elements as necessary. Has anyone done this sort of thing before? Any and all style advice welcome. Thanks, Michael Feathers -- Now Playing: http://www.youtube.com/watch?v=SsnDdq4V8zg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http

Re: [Haskell-cafe] An ugly zip3 problem..

2008-03-20 Thread Michael Feathers
an interesting blog post by Dan Piponi on the subject: http://sigfpe.blogspot.com/2007/01/monads-hidden-behind-every-zipper.html Summary: convolution is comonadic Dan Michael Feathers wrote: I'm working on something and it's looking rather ugly.. essentially, it it's an application of a low pass filer

[Haskell-cafe] Embedded Functions in Algebraic Data Types?

2008-02-10 Thread Michael Feathers
On a lark, I loaded this into Hugs this morning, and it didn't complain: data Thing = Thing (Integer - Integer) But, I've never seen that sort of construct in an example. Do people ever embed functions in ADTs? Michael ___ Haskell-Cafe

Re: [Haskell-cafe] Embedded Functions in Algebraic Data Types?

2008-02-10 Thread Michael Feathers
of a data structure :-) Luke On Feb 10, 2008 1:34 PM, Michael Feathers [EMAIL PROTECTED] wrote: On a lark, I loaded this into Hugs this morning, and it didn't complain: data Thing = Thing (Integer - Integer) But, I've never seen that sort of construct in an example. Do people ever embed

[Haskell-cafe] nub vs. find + (:) Is this abysmal code?

2008-02-10 Thread Michael Feathers
How bad is this: addProduct :: [Product] - Product - [Product] addProduct inventory product = nub (product : inventory) compared to this: addProduct :: [Product] - Product - [Product] addProduct inventory p | isNothing (find (==p) inventory)= p : inventory | otherwise