2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1 +1,10 @@
|
|||
Demonstrate the language's methods of variable declaration, initialization, assignment, datatypes, scope, referencing, and other variable related facilities.
|
||||
;Task:
|
||||
Demonstrate a language's methods of:
|
||||
:::* variable declaration
|
||||
:::* initialization
|
||||
:::* assignment
|
||||
:::* datatypes
|
||||
:::* scope
|
||||
:::* referencing, and
|
||||
:::* other variable related facilities
|
||||
<br><br>
|
||||
|
|
|
|||
6
Task/Variables/360-Assembly/variables-1.360
Normal file
6
Task/Variables/360-Assembly/variables-1.360
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
* value of F
|
||||
L 2,F assigment r2=f
|
||||
* reference (or address) of F
|
||||
LA 3,F reference r3=@f
|
||||
* referencing (or indexing) of reg3 (r3->f)
|
||||
L 4,0(3) referencing r4=%r3=%@f=f
|
||||
24
Task/Variables/360-Assembly/variables-2.360
Normal file
24
Task/Variables/360-Assembly/variables-2.360
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
* declarations length
|
||||
C DS C character 1
|
||||
X DS X character hexa 1
|
||||
B DS B character bin 1
|
||||
H DS H half word 2
|
||||
F DS F full word 4
|
||||
E DS F single float 4
|
||||
D DS D double float 8
|
||||
L DS L extended float 16
|
||||
S DS CL12 string 12
|
||||
P DS PL16 packed decimal 16
|
||||
Z DS ZL32 zoned decimal 32
|
||||
* declarations + initialization
|
||||
CI DC C'7' character 1
|
||||
XI DC X'F7' character hexa 1
|
||||
BI DC B'11110111' character bin 1
|
||||
HI DC H'7' half word 2
|
||||
FI DC F'7' full word 4
|
||||
EI DC F'7.8E3' single float 4
|
||||
DI DC D'7.8E3' double float 8
|
||||
LI DC L'7.8E3' extended float 16
|
||||
SI DC CL12'789' string 12
|
||||
PI DC PL16'7' packed decimal 16
|
||||
ZI DC ZL32'7' zoned decimal 32
|
||||
|
|
@ -1,7 +1,19 @@
|
|||
declare
|
||||
Name: declare -- a local declaration block has an optional name
|
||||
A : constant Integer := 42; -- Create a constant
|
||||
X : String := "Hello"; -- Create and initialize a local variable
|
||||
Y : Integer; -- Create an uninitialized variable
|
||||
Y : Integer; -- Create an uninitialized variable
|
||||
Z : Integer renames Y: -- Rename Y (creates a view)
|
||||
function F (X: Integer) return Integer is
|
||||
-- Inside, all declarations outside are visible when not hidden: X, Y, Z are global with respect to F.
|
||||
X: Integer := Z; -- hides the outer X which however can be refered to by Name.X
|
||||
begin
|
||||
...
|
||||
end F; -- locally declared variables stop to exist here
|
||||
begin
|
||||
Y := 1; -- Assign variable
|
||||
end; -- End of the scope
|
||||
declare
|
||||
X: Float := -42.0E-10; -- hides the outer X (can be referred to Name.X like in F)
|
||||
begin
|
||||
...
|
||||
end;
|
||||
end Name; -- End of the scope
|
||||
|
|
|
|||
8
Task/Variables/Elena/variables.elena
Normal file
8
Task/Variables/Elena/variables.elena
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#symbol program =
|
||||
[
|
||||
#var c. // declaring variable. default value is $nil
|
||||
#var a := 3. // declaring and initializing variables
|
||||
#var b := "my string" length.
|
||||
|
||||
c := b + a. // assigning variable
|
||||
].
|
||||
3
Task/Variables/Forth/variables-4.fth
Normal file
3
Task/Variables/Forth/variables-4.fth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
VARIABLE X 999 X ! \ create variable x, store 999 in X
|
||||
VARIABLE Y -999 Y ! \ create variable y, store -999 in Y
|
||||
2VARIABLE W 140569874. W 2! \ create and assign a double precision variable
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
u32 = uint32(5);% unsigned 4 byte integers
|
||||
i64 = int64(5); % signed 8 byte integer
|
||||
u64 = uint64(5);% unsigned 8 byte integer
|
||||
f32 = float32(5); % single precission floating point number
|
||||
f64 = float64(5); % double precission floating point number , float 64 is the default data type.
|
||||
f32 = float32(5); % single precision floating point number
|
||||
f64 = float64(5); % double precision floating point number , float 64 is the default data type.
|
||||
|
||||
c = 4+5i; % complex number
|
||||
colvec = [1;2;4]; % column vector
|
||||
|
|
|
|||
3
Task/Variables/Maple/variables-1.maple
Normal file
3
Task/Variables/Maple/variables-1.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a := 1:
|
||||
print ("a is "||a);
|
||||
"a is 1"
|
||||
10
Task/Variables/Maple/variables-2.maple
Normal file
10
Task/Variables/Maple/variables-2.maple
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
b;
|
||||
f := proc()
|
||||
local b := 3;
|
||||
print("b is "||b);
|
||||
end proc:
|
||||
f();
|
||||
print("b is "||b);
|
||||
b
|
||||
"b is 3"
|
||||
"b is b"
|
||||
11
Task/Variables/Maple/variables-3.maple
Normal file
11
Task/Variables/Maple/variables-3.maple
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
f := proc()
|
||||
global c;
|
||||
c := 3;
|
||||
print("a is "||a);
|
||||
print("c is "||c);
|
||||
end proc:
|
||||
f();
|
||||
print("c is "||c);
|
||||
"a is 1"
|
||||
"c is 3"
|
||||
"c is 3"
|
||||
5
Task/Variables/Maple/variables-4.maple
Normal file
5
Task/Variables/Maple/variables-4.maple
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
print ("a is "||a);
|
||||
a := 4:
|
||||
print ("a is "||a);
|
||||
"a is 1"
|
||||
"a is 4"
|
||||
11
Task/Variables/Maple/variables-5.maple
Normal file
11
Task/Variables/Maple/variables-5.maple
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
print ("a is "||a);
|
||||
type(a, integer);
|
||||
a := "Hello World":
|
||||
print ("a is "||a);
|
||||
type(a, integer);
|
||||
type(a, string);
|
||||
"a is 4"
|
||||
true
|
||||
"a is Hello World"
|
||||
false
|
||||
true
|
||||
3
Task/Variables/Maple/variables-6.maple
Normal file
3
Task/Variables/Maple/variables-6.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
`This is a variable` := 1:
|
||||
print(`This is a variable`);
|
||||
1
|
||||
14
Task/Variables/Maple/variables-7.maple
Normal file
14
Task/Variables/Maple/variables-7.maple
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
print ("a is "||a);
|
||||
type(a, string);
|
||||
print("c is "||c);
|
||||
a := 'a':
|
||||
print ("a is "||a);
|
||||
type(a, symbol);
|
||||
unassign('c');
|
||||
print("c is "||c);
|
||||
"a is Hello World"
|
||||
true
|
||||
"c is 3"
|
||||
"a is a"
|
||||
true
|
||||
"c is c"
|
||||
2
Task/Variables/Prolog/variables-1.pro
Normal file
2
Task/Variables/Prolog/variables-1.pro
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mortal(X) :- man(X).
|
||||
man(socrates).
|
||||
2
Task/Variables/Prolog/variables-2.pro
Normal file
2
Task/Variables/Prolog/variables-2.pro
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
student(X,Y) :- taught(Y,X).
|
||||
taught(socrates,plato).
|
||||
6
Task/Variables/Prolog/variables-3.pro
Normal file
6
Task/Variables/Prolog/variables-3.pro
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
?- mortal(socrates).
|
||||
yes
|
||||
?- student(X,socrates).
|
||||
X=plato
|
||||
?- student(socrates,X).
|
||||
no
|
||||
2
Task/Variables/Prolog/variables-4.pro
Normal file
2
Task/Variables/Prolog/variables-4.pro
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
?- mortal(zeus).
|
||||
no
|
||||
1
Task/Variables/Prolog/variables-5.pro
Normal file
1
Task/Variables/Prolog/variables-5.pro
Normal file
|
|
@ -0,0 +1 @@
|
|||
mortal(X) :- man(Y).
|
||||
Loading…
Add table
Add a link
Reference in a new issue