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

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
uanhi committed Apr 15, 2021
1 parent 918ce53 commit a1d4e1c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 100 deletions.
66 changes: 33 additions & 33 deletions std/fun.ft
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
mod fun

def Fun
// MY LOVE!!
def () love
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 += " "
if (y * y * y -
x * x * i * i * i) < 0.0
s += "#"
nf
s += " "
end
end
puts(s) // PRINT
end
end
puts(s) // PRINT
end
end
end

/*
// ITS A JOKER!!
def (repeat: int) joker
def first: bool = T
def x: int = repeat + 1 // Love you more forever

aop ->
new Fun.love()
new Fun.show()
putl("第几次了?", x, " 次!!")

if first
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
11 changes: 1 addition & 10 deletions std/http.ft
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
mod http

def Status
OK
NotFound
BadRequest

InternalServerError
GatewayError
end
mod http
11 changes: 10 additions & 1 deletion std/math.ft
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
mod math
mod math

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

def Iter
def (char) *count -> int

def () *first -> char
def () *back -> char
def () *size -> int
// 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
end
ret count
end

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

def String <- Iter + And
def val: str

def (x: char) count -> int
if len(val) == 0
ret 0
end

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

def l: int = len(val)
aop l > i
if val[len(val) - l] == x
c += 1
end
l -= 1
// Loop to generate some random string
def (lp: int) random_str -> []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
end
ret c
end

def (x: str) add -> str
ret val + x
end

def () first -> char
ret val[0]
end

def () back -> char
ret val[len(val) - 1]
end

def () size -> int
ret len(val)
end

def () split -> []char
ret [val[0], val[1], val[2]]
end
ret res
end
17 changes: 8 additions & 9 deletions test/whole3.ft
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
def Foo
def () show
puts("SHOW TIME!!")
end
def () show
puts("SHOW TIME!!")
end
end

do
def i: int = 0
for i < 100
new Foo.show()
i += 1
end
def i: int = 0
aop i < 100
new Foo.show()
i += 1
end

0 comments on commit a1d4e1c

Please sign in to comment.