Skip to content

Commit

Permalink
cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gfngfn committed Oct 28, 2024
1 parent 0cf8d1a commit a7d2546
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
16 changes: 8 additions & 8 deletions lib-satysfi/packages/stdlib/stdlib.0.0.1/src/list.satyg
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ end = struct

val persistent ~fold-indexed-adjacent f init xs =
let (_, acc) =
xs |> fold-adjacent (fun (i, acc) x prev-opt next-opt -> (
xs |> fold-adjacent (fun (i, acc) x prev-opt next-opt ->
(i + 1, f acc i x prev-opt next-opt)
)) (0, init)
) (0, init)
in
acc

Expand All @@ -135,22 +135,22 @@ end = struct
aux 0 f

val persistent ~map-adjacent f xs =
xs |> fold-adjacent (fun acc x prev-opt next-opt -> (
xs |> fold-adjacent (fun acc x prev-opt next-opt ->
f x prev-opt next-opt :: acc
)) [] |> reverse
) [] |> reverse

val persistent ~map-indexed-adjacent f xs =
xs |> fold-indexed-adjacent (fun acc i x prev-opt next-opt -> (
xs |> fold-indexed-adjacent (fun acc i x prev-opt next-opt ->
f i x prev-opt next-opt :: acc
)) [] |> reverse
) [] |> reverse

val persistent ~map-with-ends f xs =
fold-adjacent (fun acc x prev-opt next-opt -> (
fold-adjacent (fun acc x prev-opt next-opt ->
let is-first = Option.is-none prev-opt in
let is-last = Option.is-none next-opt in
let y = f is-first is-last x in
y :: acc
)) [] xs |> reverse
) [] xs |> reverse

val persistent ~rec append xs1 xs2 =
match xs1 with
Expand Down
16 changes: 8 additions & 8 deletions lib-satysfi/packages/stdlib/stdlib.0.0.1/src/map.satyg
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ end = struct
end
end
in
(fun mp -> (
(fun mp ->
let (_, mp-new) = aux mp in
mp-new
))
)

val trim-minimum =
let rec aux n =
Expand All @@ -214,12 +214,12 @@ end = struct
(kv-min, rebalance tL n#key n#data n#right)
end
in
(fun t -> (
(fun t ->
match t with
| Empty -> None
| Node(n) -> Some(aux n)
end
))
)

% Merges two trees `t1` and `t2`,
% where the maximum key in `t1` is less than the minimum key in `t2`
Expand Down Expand Up @@ -256,12 +256,12 @@ end = struct
end
end
in
(fun mp -> (
(fun mp ->
match aux mp with
| None -> mp
| Some(mp-new) -> mp-new
end
))
)

val find k =
let rec aux mp =
Expand Down Expand Up @@ -422,7 +422,7 @@ end = struct

#[test]
val add-test () =
List.iter (fun r -> (
List.iter (fun r ->
let title = r#title in
let input = r#input in
let expected = r#expected in
Expand All @@ -431,7 +431,7 @@ end = struct
let got = r#operation r#input in
let () = assert ?(title = title ^ `: output well-formedness`) (is-well-formed got) in
assert-equal ?(title = title) (eq-internal Equality.string) expected got
)) [
) [
(|
title = `added to the left`,
input =
Expand Down
8 changes: 4 additions & 4 deletions lib-satysfi/packages/stdlib/stdlib.0.0.1/src/path.satyh
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ end = struct
|> close-with-line

val poly-line pt-init pts =
pts |> List.fold (fun acc pt -> (
pts |> List.fold (fun acc pt ->
acc |> line-to pt
)) (start-path pt-init) |> terminate-path
) (start-path pt-init) |> terminate-path

val polygon pt-init pts =
pts |> List.fold (fun acc pt -> (
pts |> List.fold (fun acc pt ->
acc |> line-to pt
)) (start-path pt-init) |> close-with-line
) (start-path pt-init) |> close-with-line

val line pt1 pt2 =
start-path pt1 |> line-to pt2 |> terminate-path
Expand Down
24 changes: 12 additions & 12 deletions lib-satysfi/packages/stdlib/stdlib.0.0.1/test/list-test.satyg
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ module ListTest = struct
let mutable r <- [3] in
let inputs = [1, 4, 1, 5, 9, 2] in
let () =
List.iter (fun n -> (
List.iter (fun n ->
r <- n :: !r
)) inputs
) inputs
in
let got = !r in
let expected = [2, 9, 5, 1, 4, 1, 3] in
assert-equal Equality.(list int) expected got

#[test]
val compare-test () =
List.iter (fun r -> (
List.iter (fun r ->
let got = List.compare Int.compare r#input1 r#input2 in
assert-equal ?(title = r#title) eq-ordering r#expected got
)) [
) [
(|
title = `prefix is smaller 1`,
input1 = [],
Expand Down Expand Up @@ -60,10 +60,10 @@ module ListTest = struct

#[test]
val show-test () =
List.iter (fun r -> (
List.iter (fun r ->
let got = List.show arabic r#input in
assert-equal ?(title = r#title) Equality.string r#expected got
)) [
) [
(|
title = `empty`,
input = [],
Expand Down Expand Up @@ -109,11 +109,11 @@ module ListTest = struct
let input = [`a`, `b`, `c`, `d`] in
let expected = [`cdY`, `bcd`, `abc`, `Xab`] in
let got =
List.fold-adjacent (fun acc s prev next -> (
List.fold-adjacent (fun acc s prev next ->
let s-prev = Option.from `X` prev in
let s-next = Option.from `Y` next in
(s-prev ^ s ^ s-next) :: acc
)) [] input
) [] input
in
assert-equal Equality.(list string) expected got

Expand All @@ -122,11 +122,11 @@ module ListTest = struct
let input = [`a`, `b`, `c`, `d`] in
let expected = [`3cdY`, `2bcd`, `1abc`, `0Xab`] in
let got =
List.fold-indexed-adjacent (fun acc i s prev next -> (
List.fold-indexed-adjacent (fun acc i s prev next ->
let s-prev = Option.from `X` prev in
let s-next = Option.from `Y` next in
(arabic i ^ s-prev ^ s ^ s-next) :: acc
)) [] input
) [] input
in
assert-equal Equality.(list string) expected got

Expand All @@ -149,11 +149,11 @@ module ListTest = struct
let input = [3, 1, 4, 1, 5, 9, 2] in
let expected = [`X31`, `314`, `141`, `415`, `159`, `592`, `92Y`] in
let got =
List.map-adjacent (fun n prev next -> (
List.map-adjacent (fun n prev next ->
let s-prev = Option.from `X` (Option.map arabic prev) in
let s-next = Option.from `Y` (Option.map arabic next) in
s-prev ^ arabic n ^ s-next
)) input
) input
in
assert-equal Equality.(list string) expected got

Expand Down

0 comments on commit a7d2546

Please sign in to comment.