1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
bobbylisp/example/tuples.hz

33 lines
887 B
Plaintext
Raw Normal View History

2022-04-10 17:28:04 -05:00
-- This is a rewrite of runtime/tuples.ts in itself
fun every_ (a : [any]) (b : [any]) (current : int) : bool = do
if @len(a) == current
then return true
else
do
let aa : any = @get(a, current)
let bb : any = @get(b, current)
if aa == bb
then return every_(a, b, current + 1)
else return false end
end
end
end
fun every (a : [any]) (b : [any]): bool = return every_(a, b, 0)
fun eqTuples (a : [any]) (b : [any]) : bool =
match @len(a) == @len(b) with
| true -> return every(a, b)
| else return false
end
fun main : void = do
let foo : (int, int) = (1, 3)
let bar : (int, int) = (2, 1)
let baz : (int, int, int) = (1, 3, 1)
eqT(foo, bar) |> @write(_)
@write("\n")
eqT(foo, baz) |> @write(_)
@write("\n")
eqT(foo, (1, 3)) |> @write(_)
end