[Haskell-beginners] consing an element to a list inside a file

Daniel Fischer daniel.is.fischer at web.de
Thu Feb 11 15:41:15 EST 2010


Am Donnerstag 11 Februar 2010 21:09:37 schrieb kane96 at gmx.de:
> mysecondlist = 0:mylist
>
> that's was I was searching for, but how can I add the element to the
> same list?

You can't. When you add an element to a list, it's a different list.

> I have to get any number of inputs from the user and at the
> end, if he doesn't want to make more inputs, I have to print a list with
> all the inputs he did.

Make the list a parameter of the input loop.

getInputs previous = do
    user <- getUserInput
    if endNow user
      then printList previous
      else getInputs (user:previous)



More information about the Beginners mailing list