Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Add some example of drift program
Browse files Browse the repository at this point in the history
  • Loading branch information
uanhi committed Apr 16, 2021
1 parent a1d4e1c commit d14f579
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 56 deletions.
64 changes: 32 additions & 32 deletions std/fun.ft
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
mod fun

def Fun
// MY LOVE!!
def () show
def y: float
def s: str
// MY LOVE!!
def () show
def y: float
def s: str

for i: float = 1.5; i > -1.5; i -= 0.1
s = ""
for i: float = 1.5; i > -1.5; i -= 0.1
s = ""

for x: int = -1.5; x < 1.5; x += 0.05
y = x * x + i * i - 1
for x: int = -1.5; x < 1.5; x += 0.05
y = x * x + i * i - 1

if (y * y * y -
x * x * i * i * i) < 0.0
s += "#"
nf
s += " "
end
end
puts(s) // PRINT
if (y * y * y -
x * x * i * i * i) < 0.0
s += "#"
nf
s += " "
end
end
puts(s) // PRINT
end
end
end
/*

// ITS A JOKER!!
def (repeat: int) joker
def first: bool = T
Expand All @@ -45,27 +45,27 @@ def (repeat: int) joker
end
putl("END..")
end
*/

// litter
def () heart
def x: []str = [
"",
" ** ** ",
" * * *",
" * *",
" *",
""
]
def i: int = len(x)
aop i > 0
putl(x[len(x) - i])
i -= 1
end
def x: []str = [
"",
" ** ** ",
" * * *",
" * *",
" *",
""
]
def i: int = len(x)
aop i > 0
putl(x[len(x) - i])
i -= 1
end
end

// return the raw string of heart
def () rawHeart -> str
ret `
ret `
** **
* . * LOVE ?
* *
Expand Down
10 changes: 5 additions & 5 deletions std/math.ft
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod math

// Return the max of two numbers.
def (a + b: int) max -> int
if a > b
ret a
nf
ret b
end
if a > b
ret a
nf
ret b
end
end
24 changes: 24 additions & 0 deletions std/pl.ft
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
mod pl

use math /* MATH MOD */

// Return the function of max
def () f_max -> |int, int| -> int
ret max
end

// Return function
//
// f_nan()()()()() -> 2.53
//
def () f_nan -> || -> || -> || -> float
ret def () -> ||
ret def () -> ||
ret def () -> ||
ret def () -> float
ret 2.53
end
end
end
end
end
36 changes: 18 additions & 18 deletions std/str.ft
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ mod str

// Return the count of character in string
def (src: str, tar: char) count -> int
def count: int

for i: int = 0; i < len(src); i += 1
if src[i] == tar
count += 1
end
def count: int
// ITERATOR
for i: int = 0; i < len(src); i += 1
if src[i] == tar
count += 1
end
ret count
end
ret count
end

// Return the front character of string
def (src: str) front -> char
ret src[0]
ret src[0]
end

// Return the back character of string
def (src: str) back -> char
ret src[len(src) - 1]
ret src[len(src) - 1]
end

// Loop to generate some random string
def (lp: int) random_str -> []str
if lp > 20
ret []
nf
def res: [20]str
if lp > 20
ret []
nf
def res: [20]str

for i: int = 0; lp > 0; lp -= 1
res[i] = randomStr(20, T)
i += 1
end
for i: int = 0; lp > 0; lp -= 1
res[i] = randomStr(20, T)
i += 1
end
ret res
end
ret res
end
2 changes: 1 addition & 1 deletion test/for.ft
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ for i: int = 0; i < 20; i += 1
if i % 2 == 0
put(i)
end
end
end

0 comments on commit d14f579

Please sign in to comment.