Skip to content

Commit

Permalink
Create string-reductions.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-fm authored Aug 29, 2016
1 parent aac5b38 commit 3ab7274
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hacker-rank/functional-programming/recursion/string-reductions.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import qualified Data.Set as Set
import Data.Set (Set)

reduction :: String -> Set Char -> String
reduction [] _ = []
reduction (x:ys) set
| Set.member x set = reduction(ys) set
| otherwise = x:reduction(ys) ((Set.insert x) set)

main = do string <- getLine
putStr(reduction string Set.empty)




0 comments on commit 3ab7274

Please sign in to comment.