Skip to content

Commit

Permalink
Make parsed sheet more compact by merging adjacent lyrics tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
zcesur committed Aug 17, 2020
1 parent 93868b1 commit 21d038c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,25 @@ parseSheet =
isMusical : Char -> Bool
isMusical c =
List.member c [ '+', '-', '#', '/' ]

consCompact : Token -> List Token -> List Token
consCompact x ys =
case ys of
t :: ts ->
case ( x, t ) of
( Lyrics a, Lyrics b ) ->
Lyrics (a ++ b) :: ts

_ ->
x :: ys

[] ->
x :: ys
in
String.toList
>> List.groupWhile (\x y -> xor (isWordSymbol x) (isWordSymbol y) |> not)
>> List.map (fromNonEmpty >> String.fromList >> parseToken)
>> List.foldr consCompact []


parseToken : String -> Token
Expand Down

0 comments on commit 21d038c

Please sign in to comment.