Skip to content

Commit

Permalink
Fix permutations
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoTod committed Nov 30, 2016
1 parent 5fbf67c commit f4648c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions exercises/md-table/MdTable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ equalizeColumnSize :: [[String]] -> [[String]]
equalizeColumnSize [] = []
equalizeColumnSize (x:xs) = [pad y | y <- x] : (equalizeColumnSize xs)
where pad z = padWith ' ' (getMaxColumnLength (x:xs)) z


toLine :: [String] -> String
toLine [] = "|"
toLine (x:xs) = "| " ++ x ++ " " ++ toLine xs


padWith :: (Eq a) => a -> Int -> [a] -> [a]
padWith _ 0 x | x == [] = []
| otherwise = x
Expand Down
2 changes: 1 addition & 1 deletion exercises/permutations/perm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Data.List hiding (permutations)

permutations :: [Int] -> [[Int]]
permutations [] = [[]]
permutations (x:xs) = [ y:ys | y <- (x:xs), ys <- permutations xs]
permutations xs = [ y:ys | y <- xs, ys <- permutations (delete y xs)]

1 comment on commit f4648c9

@g-nakov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Супер 😃

Please sign in to comment.