Substitute /= interface by a generic.

This commit is contained in:
Jorge Acereda 2019-09-20 23:49:20 +02:00
parent a44afe325e
commit 7b7cb5d1e5
15 changed files with 6 additions and 49 deletions

View File

@ -106,10 +106,6 @@ Returns `Nothing` if the array is empty.")
(break))))
eq)))
(doc /= "compares two arrays and inverts the result.")
(defn /= [a b]
(not (= (the (Ref (Array a)) a) b)))
(doc maximum "gets the maximum in an array (elements must support `<`) and wraps it in a `Just`.
If the array is empty, it returns `Nothing`.")

View File

@ -23,9 +23,6 @@
(= @char-ref \9) 9
-1))
(defn /= [a b]
(not (= (the Char a) b)))
(doc lower-case? "tests whether a character is lower case.")
(defn lower-case? [c]
(and (<= \a c) (<= c \z)))
@ -53,8 +50,6 @@
(defmodule CharRef
(defn = [a b]
(Char.= @a @b))
(defn /= [a b]
(Char./= @a @b))
(defn < [a b]
(Char.< @a @b))
(defn > [a b]

View File

@ -50,9 +50,6 @@ The margin of error is `0.00001`.")
(defn approx [x y]
(Generics.approx x y))
(defn /= [x y]
(not (Double.= x y)))
(doc zero "returns the value `0.0`.")
(defn zero []
0.0)

View File

@ -14,8 +14,6 @@
(register copy (Fn [(Ref Float)] Float))
(register = (Fn [Float Float] Bool))
(defn /= [x y]
(not (Float.= x y)))
(register < (Fn [Float Float] Bool))
(register > (Fn [Float Float] Bool))

View File

@ -103,4 +103,7 @@ The margin of error is 0.00001.")
(defn random--1-1 []
(random-between (minus-one) (one)))
(defn /= [a b]
(not (= a b)))
)

View File

@ -10,7 +10,6 @@
(register < (λ [Int Int] Bool))
(register > (λ [Int Int] Bool))
(register = (λ [Int Int] Bool))
(register /= (λ [Int Int] Bool))
(register neg (λ [Int] Int))
(register mod (λ [Int Int] Int))
(register bit-shift-left (λ [Int Int] Int))
@ -74,9 +73,6 @@
(defn = [a b]
(Int.= @a @b))
(defn /= [a b]
(Int./= @a @b))
(defn < [a b]
(Int.< @a @b))

View File

@ -5,7 +5,6 @@
;;(definterface str (λ [a] String))
(definterface = (λ [a a] Bool))
(definterface /= (λ [a a] Bool))
(definterface add-ref (λ [&a &a] a))
(definterface sub-ref (λ [&a &a] a))

View File

@ -25,9 +25,6 @@
to non-refs.")
(register copy (λ [&Long] Long))
(defn /= [x y]
(not (Long.= x y)))
(register safe-add (λ [Long Long (Ref Long)] Bool))
(register safe-sub (λ [Long Long (Ref Long)] Bool))
(register safe-mul (λ [Long Long (Ref Long)] Bool))

View File

@ -121,8 +121,6 @@
(register str (Fn [SDL_Keycode] String))
(defn prn [x]
(SDL.Keycode.str x))
(defn /= [x y]
(not (SDL.Keycode.= x y)))
(register return SDL_Keycode "SDLK_RETURN")
(register space SDL_Keycode "SDLK_SPACE")

View File

@ -23,9 +23,6 @@
(register string-set-at! (Fn [&String Int &String] ()))
(register allocate (Fn [Int Char] String))
(defn /= [a b]
(not (= (the (Ref String) a) b)))
(doc head "Returns the character at start of string.")
(defn head [s]
(char-at s 0))
@ -157,9 +154,6 @@
(defn = [a b]
(String.= &a &b))
(defn /= [a b]
(String./= &a &b))
(defn < [a b]
(String.< &a &b))

View File

@ -5,9 +5,6 @@
(and (= (Pair.a p1) (Pair.a p2))
(= (Pair.b p1) (Pair.b p2))))
(defn /= [p1 p2]
(not (PairRef.= p1 p2)))
(defn < [p1 p2]
(if (= (Pair.a p1) (Pair.a p2))
(< (Pair.b p1) (Pair.b p2))
@ -24,9 +21,6 @@
(and (= (Pair.a &p1) (Pair.a &p2))
(= (Pair.b &p1) (Pair.b &p2))))
(defn /= [p1 p2]
(not (Pair.= p1 p2)))
(defn < [p1 p2]
(PairRef.< &p1 &p2))

View File

@ -35,9 +35,6 @@
(defn = [a b]
(vreduce (fn [i v] (and i v)) true &(zip = a b)))
(defn /= [a b]
(not (= a b)))
(doc vapprox "Check whether the vectors a and b are approximately equal.")
(defn vapprox [a b]
(vreduce (fn [i v] (and i v)) true &(zip Generics.approx a b)))
@ -126,9 +123,6 @@
(defn = [a b]
(vreduce (fn [i v] (and i v)) true &(zip = a b)))
(defn /= [a b]
(not (= a b)))
(doc vapprox "Check whether the vectors a and b are approximately equal.")
(defn vapprox [a b]
(vreduce (fn [i v] (and i v)) true &(zip Generics.approx a b)))
@ -238,9 +232,6 @@
(and (Int.= @(n a) @(n b))
(Array.= (v a) (v b))))
(defn /= [a b]
(not (= a b)))
(defn add [a b]
(zip + a b))

View File

@ -8,8 +8,7 @@ int Int__PLUS_(int x, int y) { return x + y; }
int Int__MINUS_(int x, int y) { return x - y; }
int Int__MUL_(int x, int y) { return x * y; }
int Int__DIV_(int x, int y) { return x / y; }
bool Int__EQ_(int x, int y) { return x == y; }
bool Int__DIV__EQ_(int x, int y) { return x != y; }
bool Int__EQ_(int x, int y) { return x == y; }
bool Int__LT_(int x, int y) { return x < y; }
bool Int__GT_(int x, int y) { return x > y; }
int Int_neg(int x) { return -x; }

View File

@ -1,6 +1,8 @@
; this compiles without needing the core libraries (--no-core flag)
(load "Macros.carp")
(load "Interfaces.carp")
(load "Generics.carp")
(load "Int.carp")
(defn main []

View File

@ -19,8 +19,6 @@
(defmodule Young
(defn = [y1 y2]
(Int.= @(age y1) @(age y2)))
(defn /= [y1 y2]
(Int.= @(age y1) @(age y2))))
;; Now I want to use 'Young.=' in with 'Ur.compare'