add functions from June 2025 CC1
This commit is contained in:
parent
10692b4b41
commit
1688aaccf7
|
@ -482,6 +482,11 @@ fn mult {
|
|||
((x, y), scalar as :number) -> mult (scalar, (x, y))
|
||||
}
|
||||
|
||||
fn pow {
|
||||
"Raises a number to the power of another number."
|
||||
(x as :number, y as :number) -> base :pow (x, y)
|
||||
}
|
||||
|
||||
fn div {
|
||||
"Divides numbers. Panics on division by zero."
|
||||
(x as :number) -> x
|
||||
|
@ -1232,8 +1237,28 @@ fn penwidth {
|
|||
() -> do turtle_state > unbox > :penwidth
|
||||
}
|
||||
|
||||
box state = nil
|
||||
&&& fake some lispisms with tuples
|
||||
fn cons {
|
||||
"Old-timey lisp `cons`. `Cons`tructs a tuple out of two arguments."
|
||||
(x, y) -> (x, y)
|
||||
}
|
||||
|
||||
fn car {
|
||||
"Old-timey lisp `car`. Stands for 'contents of the address register.' Returns the first element in a `cons`ed pair (or any two-tuple)."
|
||||
((x, _)) -> x
|
||||
}
|
||||
|
||||
fn cdr {
|
||||
"Old-timey list `cdr`. Stands for 'contents of the decrement register.' Returns the second element in a `cons`ed pair, usually representing the rest of the list."
|
||||
((_, x)) -> x
|
||||
}
|
||||
|
||||
fn llist {
|
||||
"Makes an old-timey linked list of its arguments, of LISt Processor fame."
|
||||
(...xs) -> foldr (cons, xs, nil)
|
||||
}
|
||||
|
||||
&&& processes
|
||||
fn self {
|
||||
"Returns the current process's pid, as a keyword."
|
||||
() -> base :process (:self)
|
||||
|
@ -1247,11 +1272,6 @@ fn send {
|
|||
}
|
||||
}
|
||||
|
||||
& fn spawn! {
|
||||
& "Spawns a new process running the function passed in."
|
||||
& (f as :fn) -> base :process (:spawn, f)
|
||||
& }
|
||||
|
||||
fn yield! {
|
||||
"Forces a process to yield."
|
||||
() -> base :process (:yield)
|
||||
|
@ -1264,10 +1284,10 @@ fn alive? {
|
|||
}
|
||||
|
||||
fn link! {
|
||||
"Creates a link between two processes. There are two types of links: `:report`, which sends a message to pid1 when pid2 dies; and `:enforce`, which causes a panic in one when the other dies. The default is `:report`."
|
||||
"Creates a link between two processes. There are two types of links: `:report`, which sends a message to pid1 when pid2 dies; and `:panic`, which causes a panic in one when the other dies. The default is `:report`."
|
||||
(pid1 as :keyword, pid2 as :keyword) -> link! (pid1, pid2, :report)
|
||||
(pid1 as :keyword, pid2 as :keyword, :report) -> base :process (:link_report, pid1, pid2)
|
||||
(pid1 as :keyword, pid2 as :keyword, :enforce) -> base :process (:link_enforce, pid1, pid2)
|
||||
(pid1 as :keyword, pid2 as :keyword, :panic) -> base :process (:link_panic, pid1, pid2)
|
||||
}
|
||||
|
||||
fn flush! {
|
||||
|
@ -1469,6 +1489,7 @@ fn read_input {
|
|||
pi
|
||||
pos?
|
||||
position
|
||||
pow
|
||||
print!
|
||||
pu!
|
||||
pw!
|
||||
|
|
Loading…
Reference in New Issue
Block a user