Sha256: 18dc2f50247c6251d237f05d2530d563c4e6806b71273cbd3653c964c7466e4c
Contents?: true
Size: 1.32 KB
Versions: 66
Compression:
Stored size: 1.32 KB
Contents
module Transpose exposing (transpose) import List import String transpose : List String -> List String transpose lines = let longestRow = Maybe.withDefault 0 <| List.maximum <| List.map String.length lines padNothingRight maxLength line = line ++ List.repeat (maxLength - List.length line) Nothing stringify line = String.concat <| List.map (\x -> case x of Nothing -> " " Just c -> String.fromChar c ) (dropNothingRight line) dropNothingRight line = Tuple.second <| List.foldr (\x ( ignore, list ) -> if ignore && x == Nothing then ( ignore, list ) else ( False, x :: list ) ) ( True, [] ) line in List.map stringify <| List.foldr (List.map2 (::)) (List.repeat longestRow []) (List.map (padNothingRight longestRow << List.map Just << String.toList) lines)
Version data entries
66 entries across 66 versions & 1 rubygems