Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Variables/Oz/variables-1.oz
Normal file
7
Task/Variables/Oz/variables-1.oz
Normal 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
|
||||
10
Task/Variables/Oz/variables-10.oz
Normal file
10
Task/Variables/Oz/variables-10.oz
Normal 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
|
||||
7
Task/Variables/Oz/variables-11.oz
Normal file
7
Task/Variables/Oz/variables-11.oz
Normal 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)
|
||||
6
Task/Variables/Oz/variables-2.oz
Normal file
6
Task/Variables/Oz/variables-2.oz
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
declare
|
||||
A = 3
|
||||
B
|
||||
in
|
||||
A = B
|
||||
{Show B}
|
||||
5
Task/Variables/Oz/variables-3.oz
Normal file
5
Task/Variables/Oz/variables-3.oz
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
declare
|
||||
A = 3
|
||||
A = B %% Error: variable B not introduced
|
||||
in
|
||||
{Show B}
|
||||
2
Task/Variables/Oz/variables-4.oz
Normal file
2
Task/Variables/Oz/variables-4.oz
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare
|
||||
[A B C D] = [1 2 3 4] %% unification of two lists
|
||||
9
Task/Variables/Oz/variables-5.oz
Normal file
9
Task/Variables/Oz/variables-5.oz
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
functor
|
||||
export Function
|
||||
define
|
||||
ToplevelVariable = 42
|
||||
|
||||
fun {Function}
|
||||
42
|
||||
end
|
||||
end
|
||||
15
Task/Variables/Oz/variables-6.oz
Normal file
15
Task/Variables/Oz/variables-6.oz
Normal 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
|
||||
8
Task/Variables/Oz/variables-7.oz
Normal file
8
Task/Variables/Oz/variables-7.oz
Normal 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
|
||||
1
Task/Variables/Oz/variables-8.oz
Normal file
1
Task/Variables/Oz/variables-8.oz
Normal file
|
|
@ -0,0 +1 @@
|
|||
case "Rosetta code" of First|_ then {Show First} end %% prints "R"
|
||||
8
Task/Variables/Oz/variables-9.oz
Normal file
8
Task/Variables/Oz/variables-9.oz
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue