On Fri, Dec 29, 2006 at 02:06:32PM +, Paul Moore wrote:
> Speaking as a relative newbie to Haskell, the thing that tripped me up
> was the fact that you can't have nested lists like the Lisp '(1 (2 (3
> 4) 5)) example in Haskell, because its type is not well-defined.
More precisely: You can't
On 12/29/06, Conor McBride <[EMAIL PROTECTED]> wrote:
Or is your issue more superficial? Is it just that
> * (my-flatten '(1 (2 (3 4) 5)))
> (1 2 3 4 5)
looks shorter than
> so
> *Main> flat [E 1, S[E 2, S[E 3, E 4], E 5]]
> [1,2,3,4,5]
Speaking as a relative newbie to Haskell, the thing tha
Hi
pphetra wrote:
Compare to a Lisp solution, It 's not looking good.
Any suggestion.
I'm trying to understand what your issue is here. What's not looking
good?
I would like to write a program that can do something like this.
;; lisp syntax
I suppose, if it were the implementation of
On Thu, Dec 28, 2006 at 11:56:58PM -0800, pphetra wrote:
> data Store a = E a | S [Store a]
> deriving (Show)
>
> flat :: [Store a] -> [a]
> flat [] = []
> flat ((E x):xs) = [x] ++ flat xs
> flat ((S x):xs) = flat x ++ flat xs
>
> so
> *Main> flat [E 1, S[E 2, S[E 3, E 4], E 5]]
> [1
On Fri, Dec 29, 2006 at 07:58:54PM +1100, Donald Bruce Stewart wrote:
> Since this data type:
>
> > data Store a = E a | S [Store a]
> > deriving (Show)
>
> Is isomorphic to the normal Data.Tree type anyway, so we'll use that:
It's a bit different - store has labels only in its leav
pphetra:
>
> I would like to write a program that can do something like this.
>
> ;; lisp syntax
> * (my-flatten '(1 (2 (3 4) 5)))
> (1 2 3 4 5)
>
> I end up like this.
>
> data Store a = E a | S [Store a]
> deriving (Show)
>
> flat :: [Store a] -> [a]
> flat [] = []
> flat ((E x
I would like to write a program that can do something like this.
;; lisp syntax
* (my-flatten '(1 (2 (3 4) 5)))
(1 2 3 4 5)
I end up like this.
data Store a = E a | S [Store a]
deriving (Show)
flat :: [Store a] -> [a]
flat [] = []
flat ((E x):xs) = [x] ++ flat xs
flat ((S x):xs)