4 ms·
The entire time I was reading, I hoped that a Haskell solution would be there (knowing it would be much simpler), I got my wish :) +1 to haskell
by emef 16y ago
The entire time I was reading, I hoped that a Haskell solution would be there (knowing it would be much simpler), I got my wish :) +1 to haskell
- megaman821 16y agoExcept for Prolog, I am familiar with all of the languages presented. Python and Haskell were the easiest for me to parse, not that any of them were overly hard.
- eru 16y agoPerhaps more idiomatic: import Data.List main = putStr . unlines . filter ("ing" `isSuffixOf`) . words =<< getContents (To be read from right to left.) A Forth example would be interesting.
- Avshalom 16y agoHere is a Factor version: : print-ing ( filepath encoding -- ) [ [ " " split [ dup "ing" tail? [ print ] [ drop ] if ] each ] each-line ] with-file-reader ; It's kind of ugly because it's designed to print out the values without leaving anything on the stack. It can be prettier if it produces an array of matching words : collect-ing ( filepath encoding -- seq ) { } -rot [ [ " " split [ "ing" tail? ] filter append ] each-line ] with-file-reader ; and then just prints that out : print-ing ( filepath encoding -- ) collect-ing [ print ] each ;
- eru 16y agoThanks!
- deleted 16y ago[deleted]