Skip to content

Commit

Permalink
Implement extract once
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode committed Jan 3, 2024
1 parent 50bf20a commit 25913c1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions exercises/practice/matrix/.meta/example.sml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ local

val cells: string -> string list =
String.tokens (fn (c: char) => c = #" ")

fun extract (index: int) (l: string list): string =
List.nth (l, index - 1)
in
fun row (s: string, index: int): int list =
let
fun extract (l: string list): string =
List.nth (l, index - 1)
in
map (valOf o Int.fromString) ((cells o extract o lines) s)
end
map (valOf o Int.fromString) ((cells o extract index o lines) s)

fun column (s: string, index: int): int list =
let
fun extract (l: string list): string =
List.nth (l, index - 1)
in
map (valOf o Int.fromString o extract o cells) (lines s)
end
map (valOf o Int.fromString o extract index o cells) (lines s)
end

0 comments on commit 25913c1

Please sign in to comment.