import Html exposing (..)
import String
type alias Stack = List String
push : String -> Stack -> Stack
push tok stack =
(tok :: stack)
pop : Stack -> (Maybe String, Maybe Stack)
pop stack =
let
top = List.head stack
in
(top, List.tail stack)
reverseString: String -> String
reverseString incoming =
let
stringStack = incoming
|> String.split ""
|> List.foldl push []
in
-- How to use pop() here?
List.foldr String.append "" stringStack
main : Html
main =
"Hello World!"
|> reverseString
|> toString
|> text
I am attempting on my own reverse
of a string using push()
and pop()
. I am able to incorporate push
, but not able to use pop
within the function reverseString
. What am I doing wrong here?