[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
-- 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
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 :-) :
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
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
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
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.
___
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'
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
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
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
11 matches
Mail list logo