Renamed some functions in Double and Float.

This commit is contained in:
Erik Svedäng 2017-10-13 16:11:23 +02:00
parent cebc0a98d9
commit 09fc80599a
6 changed files with 46 additions and 9 deletions

View File

@ -4,8 +4,8 @@
(register - (Fn [Double Double] Double))
(register * (Fn [Double Double] Double))
(register / (Fn [Double Double] Double))
(register toInt (Fn [Double] Int))
(register fromInt (Fn [Int] Double))
(register to-int (Fn [Double] Int))
(register from-int (Fn [Int] Double))
(register sin (Fn [Double] Double))
(register cos (Fn [Double] Double))
(register str (Fn [Double] String))

View File

@ -4,5 +4,5 @@
(register - (Fn [Float Float] Float))
(register * (Fn [Float Float] Float))
(register / (Fn [Float Float] Float))
(register toInt (Fn [Float] Int))
(register to-int (Fn [Float] Int))
(register str (Fn [Float] String)))

View File

@ -174,11 +174,11 @@ int exmod__bleh(int x) {
}
// Double.toInt : Double -> Int
int Double_toInt(double x) {
int Double_to_MINUS_int(double x) {
return (int)x;
}
double Double_fromInt(int x) {
double Double_from_MINUS_int(int x) {
return (double)x;
}
@ -196,7 +196,7 @@ string Double_str(double x) {
return buffer;
}
int Float_toInt(double x) {
int Float_to_MINUS_int(double x) {
return (int)x;
}

View File

@ -302,9 +302,46 @@ inc : (λ [Int] Int)
(defn confused-twice [x] (+ x x))
```
---
# Inspecting modules at the REPL
```
鲮 (type Double)
Double : Module = {
* : (λ [Double Double] Double)
+ : (λ [Double Double] Double)
- : (λ [Double Double] Double)
/ : (λ [Double Double] Double)
cos : (λ [Double] Double)
from-int : (λ [Int] Double)
sin : (λ [Double] Double)
str : (λ [Double] String)
to-int : (λ [Double] Int)
π : Double
}
```
---
# 4. Defining data types
---
# Structs
```
(deftype Point
[x Int
y Int])
```
---
# [fit] Defining a struct will create a module with the same name
```
(deftype Point
[x Int
y Int])
```
---
# 5. Array processing

View File

@ -18,7 +18,7 @@
(inside (String.copy "Hello"))))
(defn use-doubles []
(println (ref (str (Double.toInt (Double.+ 2.0 3.0))))))
(println (ref (str (Double.to-int (Double.+ 2.0 3.0))))))
(deftype Person
[name String
@ -98,7 +98,7 @@
(defn negative-numbers []
(let [x -10.0 y -20.0f z -30]
(* (*(toInt x) (toInt y)) z)))
(* (* (to-int x) (to-int y)) z)))
(defn square [x]
(Int.* x x))

View File

@ -59,7 +59,7 @@
img
(address (dimensions img))
(address (make-rect 100 100 300 300))
(* 0.1 (fromInt (SDL_GetTicks)))
(* 0.1 (from-int (SDL_GetTicks)))
(address (make-point 150 150))
SDL_FLIP_NONE))
(SDL_RenderPresent rend)