-
-
Save tuchk4/42a98693fd0d664eea04bd54ad95549e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type part_item = {mutable symbols: string}; | |
type data_item = {symbol: string, next: bool}; | |
let process data => { | |
let parts: list part_item = []; | |
let current = {symbols: ""}; | |
List.iter | |
( | |
fun p => | |
if p.next { | |
/* ? push current to parts ? */ | |
current.symbols = "" | |
} else { | |
current.symbols = current.symbols ^ p.symbol | |
} | |
) | |
data; | |
parts | |
}; | |
let data: list data_item = [ | |
{symbol: "a", next: false}, | |
{symbol: "b", next: false}, | |
{symbol: "c", next: true}, | |
{symbol: "d", next: false} | |
]; | |
let parts = process data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modern ReasonML syntax
Thanks, @yawaramin