Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,7 @@
declare
Var %% new variable Var, initially free
{Show Var}
Var = 42 %% now Var has the value 42
{Show Var}
Var = 42 %% the same value is assigned again: ok
Var = 43 %% a different value is assigned: exception

View file

@ -0,0 +1,10 @@
declare
V = 42
in
{Wait V} %% explicitly wait for V to become determined
if {IsDet V} then %% check whether V is determined; not recommended
{Show determined}
elseif {IsFree V} then %% check whether V is free; not recommended
{Show free}
end

View file

@ -0,0 +1,7 @@
declare
A = {NewCell 42}
OldVal
in
{Show @A} %% read a cell with @
A := 43 %% change its value
OldVal = A := 44 %% read and write at the same time (atomically)

View file

@ -0,0 +1,6 @@
declare
A = 3
B
in
A = B
{Show B}

View file

@ -0,0 +1,5 @@
declare
A = 3
A = B %% Error: variable B not introduced
in
{Show B}

View file

@ -0,0 +1,2 @@
declare
[A B C D] = [1 2 3 4] %% unification of two lists

View file

@ -0,0 +1,9 @@
functor
export Function
define
ToplevelVariable = 42
fun {Function}
42
end
end

View file

@ -0,0 +1,15 @@
fun {Function Arg}
LocalVar1
in
LocalVar1 = if Arg == 42 then
LocalVar2
in
LocalVar2 = yes
LocalVar2
else
LocalVar3 = no %% variables can be initialized when declared
in
LocalVar3
end
LocalVar1
end

View file

@ -0,0 +1,8 @@
if {IsEven 42} then
{System.showInfo "Here, LocalVar is not visible."}
local
LocalVar = "Here, LocalVar IS visible"
in
{System.showInfo LocalVar}
end
end

View file

@ -0,0 +1 @@
case "Rosetta code" of First|_ then {Show First} end %% prints "R"

View file

@ -0,0 +1,8 @@
declare
A
B = !!A %% B is a read-only view of A
in
thread
B = 43 %% this blocks until A is known; then it fails because 43 \= 42
end
A = 42