Re: [Haskell-cafe] Newbie questions

2004-07-03 Thread Crypt Master
[Snip] People say function application in Haskell is written without brackets but this can be misleading, here you do need brackets to indicate that 'gaSolutionSpace [1,2,3,4,5]' is one argument and not two. So you should write: take 5 (gaSolutionSpace [1,2,3,4,5]) [Snip] Thanks alot, this was

[Haskell-cafe] Re: Newbie questions

2004-07-03 Thread Crypt Master
-- gaSolutionSpace :: [a] - [a] gaSolutionSpace x = x : gaSolutionSpace (evolvepopulation x) -Stop deceiving yourself until it's too late. -Why did you comment out the type annotation? *Sheepish Grin* its historical, my original thought and attempt was that you would recieve a list of populations

Re: [Haskell-cafe] Newbie questions

2004-07-03 Thread Crypt Master
Hi Very very helpful, thanks. I wasnt sure about the From on the end, but I get the subtle change in way you see it. Much better than mine. Using you other advice I got: gaSolutionSpaceFrom :: a - [a] gaSolutionSpaceFrom p = iterate evolvePopulation p and even managed to curry it :-) :

RE: [Haskell-cafe] List syntax -- [] vs ()

2004-07-03 Thread Stefan Holdermans
Crypt Master, CM I have noticed that lists seem to swtich between CM using [] and using (). for example: CM CM listSum [] = 0 CM listSum (x:xs) = x + listsum xs The parentheses are just 'normal' parentheses that are needed because application binds stronger than (:). Without the

[Haskell-cafe] Running Total or Incremental Sum as a higher order type ?

2004-07-03 Thread Crypt Master
Hi I was attempting to get a running a total of a list i.e for [1,2,3] the result should be [1,3,6] -- [1, 1+2, 2+3] I build this function: incrementalSum [] x = [] incrementalSum (x:xs) runningTotal = currentSum : incrementalSum xs currentSum

RE: [Haskell-cafe] List syntax -- [] vs ()

2004-07-03 Thread Crypt Master
Hi Thanks. A light bulb just went on :). I am still in awe of how much special syntax is made of such simple base. Haskell certainly is an interesting thing to learn, its like fractals, complexity and beuty from simplicity. S Original Message Follows Crypt Master, CM I have noticed

Re: [Haskell-cafe] Running Total or Incremental Sum as a higher order type ?

2004-07-03 Thread Sven Panne
Crypt Master wrote: [...] Surely this is a pattern which has been abstracted ? I feel I have missed the obvious here. There is a prelude function scanl1 for this kind of pattern, so you could write: incrementalSum = scanl1 (+) Cheers, S. ___

[Haskell-cafe] newbie problems

2004-07-03 Thread paolo veronelli
I'd like to have a simple definition of the meanings of 'type' and 'data' and maybe a clarifing example on their use. I've read the Zipper doc on he wiki ,but I can't make it work on n-ary trees,and most of all they are not any clear the performance hits on using more complex 'data'

Re: [Haskell-cafe] newbie problems

2004-07-03 Thread MR K P SCHUPKE
The zipper should work on n-ary trees. all the zipper does is store the tree as (Context,Subtree) so you just need to adapt that to a Rose-Tree. you could do something like (and I am thinking out loud here as I havent written zipper code for rose trees)... data Context x = Root | Parent x

Re: [Haskell-cafe] newbie problems

2004-07-03 Thread paolo veronelli
On Sat, 3 Jul 2004 17:57:04 +0100 (BST), MR K P SCHUPKE [EMAIL PROTECTED] wrote: The zipper should work on n-ary trees. all the zipper does is store the tree as (Context,Subtree) What is the meaning of storing in haskell? Imagine I put numbers in the leaves... you could do something like data

Re: [Haskell-cafe] Question on Exercise from SOE

2004-07-03 Thread Tom Pledger
Nathan Weston wrote: I am learning haskell (and functional programming), from the School of Expression book. There's an exercise to rewrite the following function (for computing the area of a polygon) using map, fold, etc: data Shape = Polygon [Vertex] area (Polygon (v1:vs)) = polyArea vs