Using stack inside a function without declaring it as input

Hi I have a function like this : myfunc :: [Char] -> [Char] It is supposed to work pretty much like this : 1. Take a string 2. Put some elements of this input string to output string and put others to stack. 3. Pop elements to that output string too. 4. Do 2 and 3 recursively until stack is empty. 5. Print the output string when stack is empty. I couldn't figure out where to define stack and output string. Can you help me with that? I'm new to Haskell so I can't think in Haskell's logic very well.

There are some things clearly missing in your description. I think you need
to read your problem more carefully and perhaps consult some accompanying
materials too.
Other than that I see no way one can sensibly answer your question without
more information.
Best regards,
Krzysztof Skrzętnicki
On Mon, Mar 11, 2013 at 10:36 AM, doaltan
Hi I have a function like this : myfunc :: [Char] -> [Char] It is supposed to work pretty much like this :
1. Take a string 2. Put some elements of this input string to output string and put others to stack. 3. Pop elements to that output string too. 4. Do 2 and 3 recursively until stack is empty. 5. Print the output string when stack is empty.
I couldn't figure out where to define stack and output string. Can you help me with that? I'm new to Haskell so I can't think in Haskell's logic very well.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hi, Dnia 2013-03-11, pon o godzinie 09:36 +0000, doaltan pisze:
Hi I have a function like this : myfunc :: [Char] -> [Char] It is supposed to work pretty much like this : 1. Take a string 2. Put some elements of this input string to output string and put others to stack. 3. Pop elements to that output string too. 4. Do 2 and 3 recursively until stack is empty. 5. Print the output string when stack is empty.
I couldn't figure out where to define stack and output string. Can you help me with that? I'm new to Haskell so I can't think in Haskell's logic very well.
You can try to define a second function inside myfunc with the stack as an argument: myfunc :: String -> String myfunc str = myfunc' [] str where myfunc' stack str = ... myfunc' can take the stack as an argument, myfunc can call myfunc' passing the empty stack. You should describe your problem more precisely to get more accurate answers. Emanuel
participants (3)
-
doaltan
-
Emanuel Koczwara
-
Krzysztof Skrzętnicki