import Data.Char ( isSpace ) _sexpr "" = []_sexpr exp@(tok:exp_t) | id == "" = [tok]:sexpr exp_t | otherwise = id:sexpr exp_tt where (id,exp_tt) = break isSep exp isSep c = c `elem` "()" || isSpace c sexpr = _sexpr . dropWhile isSpace main = interact $ unlines . fmap (show . sexpr) . lines
(+ 12 (* 3 4 (+ 1 2 3) 5) 1)
["(","+","12","(","*","3","4","(","+","1","2","3",")","5",")","1",")"]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!