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
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
, 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
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)
, 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
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
) 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
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
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,
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
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
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
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
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
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
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
16 matches
Mail list logo