Re: [Haskell-cafe] Emptying a list

2005-10-15 Thread Sebastian Sylvan
On 10/15/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Before you read any more, let me just say I'm fairly new to Haskell, so 
> forgive
> me if this is really basic stuff.
>
>
> Hi there, I'm just wondering if there is a command for emptying a list?
>

Variables in haskell do not vary.
So there's not even way to add an element to a list, but there is an
operator which will construct a NEW list by adding an element to the
front of an EXISTING list: xs' = 'a' : xs
xs' is xs but with an 'a' in front. Note that you can still access the
old list xs, you never update the meaning of the variable xs, you
merely create a new variable (with a new value) called xs'.

So. To answer you question, no you can not change the meaning of a
variable which contains a list, into all of a sudden containing the
empty list.
You can however use the value of the empty list, which is simply: []

> Also, is there any way to incorporate list operations (concatenation in
> particular) in a do-statement on lists? Every time I try it gives a type 
> error.
>

Not quite sure what you mean. Perhaps an example of what you'd want to
accomplish?

/S

--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Emptying a list

2005-10-14 Thread Ketil Malde
[EMAIL PROTECTED] writes:

> Hi there, I'm just wondering if there is a command for emptying a list?

Not really.  If you want an empty list, you can use [].

> Also, is there any way to incorporate list operations (concatenation in 
> particular) in a do-statement on lists? Every time I try it gives a
> type error. 

You can always include pure code in let statements, but I get the
feeling that's not quite what you are asking for.  Could you post your
non-working code? 
   
-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe