Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposition for complex cons operator #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
profile = default
version = 0.26.1
version = 0.26.0
2 changes: 1 addition & 1 deletion lib/render.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ let render_axes () =
let x_axis = line ~a:{ x = 0.; y = -.half_y } { x = 0.; y = half_y } in
let y_axis = line ~a:{ x = -.half_x; y = 0. } { x = half_x; y = 0. } in
set_color (0, 0, 0);
show [ x_axis; y_axis ]
show [ x_axis; y_axis ]
5 changes: 5 additions & 0 deletions lib/shape.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@ let ellipse ?(c = center) rx ry =
let line ?(a = center) b = Line { a; b }
let polygon lst_points = Polygon lst_points

let ( <> ) shape complex =
match (shape, complex) with
| shape', Complex complex' -> Complex (shape' :: complex')
| a, b -> Complex [ a; b ]

let complex shapes =
match shapes with _ :: _ -> Complex shapes | [] -> Complex []
1 change: 1 addition & 0 deletions lib/shape.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ val circle : ?c:float point -> int -> shape
val rectangle : ?c:float point -> int -> int -> shape
val ellipse : ?c:float point -> int -> int -> shape
val complex : shape list -> shape
val ( <> ) : shape -> shape -> shape
val line : ?a:float point -> float point -> shape
val polygon : float point list -> shape
Loading