Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Variables/00-META.yaml
Normal file
5
Task/Variables/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Variables
|
||||
note: Basic language learning
|
||||
11
Task/Variables/00-TASK.txt
Normal file
11
Task/Variables/00-TASK.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;Task:
|
||||
Demonstrate a language's methods of:
|
||||
:::* variable declaration
|
||||
:::* initialization
|
||||
:::* assignment
|
||||
:::* datatypes
|
||||
:::* scope
|
||||
:::* referencing, and
|
||||
:::* other variable related facilities
|
||||
<br><br>
|
||||
|
||||
1
Task/Variables/11l/variables-1.11l
Normal file
1
Task/Variables/11l/variables-1.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
Int a
|
||||
1
Task/Variables/11l/variables-2.11l
Normal file
1
Task/Variables/11l/variables-2.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
V a = 1
|
||||
1
Task/Variables/11l/variables-3.11l
Normal file
1
Task/Variables/11l/variables-3.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
Int p, a, d
|
||||
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
|
||||
6
Task/Variables/6502-Assembly/variables-1.6502
Normal file
6
Task/Variables/6502-Assembly/variables-1.6502
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
org $1200
|
||||
SoundRam equ $1200 ;some assemblers require equ directives to not be indented.
|
||||
SoundChannel_One equ $1200
|
||||
SoundChannel_Two equ $1201
|
||||
SoundChannel_Three equ $1202
|
||||
LDA #$FF ;this still gets assembled starting at $1200, since equ directives don't take up space!
|
||||
5
Task/Variables/6502-Assembly/variables-2.6502
Normal file
5
Task/Variables/6502-Assembly/variables-2.6502
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
joystick equ $00 ;this variable is located at zero page memory address $00
|
||||
Player_Xpos equ $01 ;this variable is located at $01
|
||||
Player_Ypos equ $02
|
||||
pointer equ $03 ;intended to take up 2 bytes
|
||||
sound_on equ $05
|
||||
8
Task/Variables/6502-Assembly/variables-3.6502
Normal file
8
Task/Variables/6502-Assembly/variables-3.6502
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
enum $0000
|
||||
;these will be defined starting at $0000 and increasing in the order listed, incremented by the amount after DSB.
|
||||
joystick dsb 1 ;this takes up 1 byte
|
||||
Player_Xpos dsb 1
|
||||
Player_Ypos dsb 1
|
||||
pointer dsb 2 ;this takes up 2 bytes
|
||||
sound_on dsb 1
|
||||
ende ;end enumeration
|
||||
7
Task/Variables/6502-Assembly/variables-4.6502
Normal file
7
Task/Variables/6502-Assembly/variables-4.6502
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.rsset $0000
|
||||
joystick .rs 1
|
||||
Player_Xpos .rs 1
|
||||
Player_Ypos .rs 1
|
||||
pointer .rs 2
|
||||
sound_on .rs 1
|
||||
;no closer needed for this method
|
||||
8
Task/Variables/6502-Assembly/variables-5.6502
Normal file
8
Task/Variables/6502-Assembly/variables-5.6502
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
LDA #$05
|
||||
STA Player1_Lives ;equivalent C code: Player1_Lives = 5;
|
||||
|
||||
LDA #$05
|
||||
STA pointer+1
|
||||
LDA #$40
|
||||
STA pointer
|
||||
;loads the variable pointer with the value $0540
|
||||
11
Task/Variables/6502-Assembly/variables-6.6502
Normal file
11
Task/Variables/6502-Assembly/variables-6.6502
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
NametableBase equ $20 ;label referring to a constant
|
||||
VRAM_ADDR equ $2006 ;label referring to a memory address
|
||||
VRAM_DATA equ $2007 ;label referring to a memory address
|
||||
|
||||
LDA #NametableBase ;without a # this is interpreted as a memory address like any other number would be.
|
||||
STA VRAM_ADDR
|
||||
LDA #$00
|
||||
STA VRAM_ADDR
|
||||
|
||||
LDA #$03
|
||||
STA VRAM_DATA
|
||||
6
Task/Variables/68000-Assembly/variables.68000
Normal file
6
Task/Variables/68000-Assembly/variables.68000
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
MyVar:
|
||||
DC.L 0 ;reserves 4 bytes of storage. The label MyVar represents the address of the four 0 bytes shown here.
|
||||
|
||||
MyOtherVar:
|
||||
DC.L $C0 ;reserves 8 bytes of storage. The first four bytes are initialized to 00 00 00 C0 and the second four to $00 $00 $01 $F4.
|
||||
DC.L 500 ;MyOtherVar points to the first four bytes, you'll need pointer arithmetic to get to the second four.
|
||||
6
Task/Variables/8086-Assembly/variables-1.8086
Normal file
6
Task/Variables/8086-Assembly/variables-1.8086
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.data
|
||||
MyVar word 0FFFFh ;the leading zero is just to help the assembler tell that this is a number, it's not actually part of the variable.
|
||||
|
||||
.code
|
||||
|
||||
mov ax, word ptr [ds:MyVar]
|
||||
3
Task/Variables/8086-Assembly/variables-2.8086
Normal file
3
Task/Variables/8086-Assembly/variables-2.8086
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Player1_Lives equ 0100h
|
||||
mov al,3
|
||||
mov byte ptr [Player1_Lives],al ;give the player 3 lives to start the game with
|
||||
2
Task/Variables/8086-Assembly/variables-3.8086
Normal file
2
Task/Variables/8086-Assembly/variables-3.8086
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mov ax, seg MyData ;the assembler replaces this with the segment MyData is located in prior to assembling the program.
|
||||
mov ds,ax ;load this segment into the data segment register.
|
||||
11
Task/Variables/8th/variables.8th
Normal file
11
Task/Variables/8th/variables.8th
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
\ declare a variable which is initialized to the number '0'
|
||||
var x
|
||||
|
||||
\ declare a variable which is initialized to a string "cat"
|
||||
"cat" var, y
|
||||
|
||||
\ Get the value in x, add 20 and store it:
|
||||
x @ 20 n:+ x !
|
||||
|
||||
\ Change the cat to a dog:
|
||||
"dog" y !
|
||||
59
Task/Variables/AArch64-Assembly/variables.aarch64
Normal file
59
Task/Variables/AArch64-Assembly/variables.aarch64
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program variable64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szString: .asciz "String définition"
|
||||
sArea1: .fill 11, 1, ' ' // 11 spaces
|
||||
// or
|
||||
sArea2: .space 11,' ' // 11 spaces
|
||||
|
||||
cCharac: .byte '\n' // character
|
||||
cByte1: .byte 0b10101 // 1 byte binary value
|
||||
|
||||
hHalfWord1: .hword 0xFF // 2 bytes value hexa
|
||||
.align 4
|
||||
iInteger1: .int 123456 // 4 bytes value decimal
|
||||
iInteger3: .short 0500 // 4 bytes value octal
|
||||
iInteger5: .int 0x4000 // 4 bytes value hexa
|
||||
|
||||
iInteger7: .word 0x4000 // 4 bytes value hexa
|
||||
iInteger6: .int 04000 // 4 bytes value octal
|
||||
|
||||
TabInteger4: .int 5,4,3,2 // Area of 4 integers = 4 * 4 = 16 bytes
|
||||
|
||||
dDoubleInt1: .quad 0xFFFFFFFFFFFFFFFF // 8 bytes value hexa
|
||||
|
||||
dfFLOAT1: .double 0f-31415926535897932384626433832795028841971.693993751E-40 // Float 8 bytes
|
||||
sfFLOAT2: .float 0f-31415926535897932384626433832795028841971.693993751E-40 // Float 4 bytes (or use .single)
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sBuffer: .skip 500 // 500 bytes values zero
|
||||
iInteger2: .skip 4 // 4 bytes value zero
|
||||
dDoubleint2: .skip 8 // 8 bytes value zero
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: // entry of program
|
||||
ldr x0,qAdriInteger2 // load variable address
|
||||
mov x1,#100
|
||||
str x1,[x0] // init variable iInteger2
|
||||
|
||||
100: // standard end of the program
|
||||
mov x0, 0 // return code
|
||||
mov x8, EXIT // request to exit program
|
||||
svc 0 // perform the system call
|
||||
|
||||
qAdriInteger2: .quad iInteger2 // variable address iInteger2
|
||||
1
Task/Variables/ALGOL-68/variables-1.alg
Normal file
1
Task/Variables/ALGOL-68/variables-1.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
int j;
|
||||
1
Task/Variables/ALGOL-68/variables-2.alg
Normal file
1
Task/Variables/ALGOL-68/variables-2.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
LONG REAL double1, double2, double3;
|
||||
2
Task/Variables/ALGOL-68/variables-3.alg
Normal file
2
Task/Variables/ALGOL-68/variables-3.alg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
SHORT INT b1 := 2500;
|
||||
LONG INT elwood = 3*bsize, jake = bsize -2;
|
||||
1
Task/Variables/ALGOL-68/variables-4.alg
Normal file
1
Task/Variables/ALGOL-68/variables-4.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
FLEX[20]CHAR mystring;
|
||||
1
Task/Variables/ALGOL-68/variables-5.alg
Normal file
1
Task/Variables/ALGOL-68/variables-5.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]CHAR mytext = "The ALGOL 68 Language";
|
||||
7
Task/Variables/ALGOL-W/variables-1.alg
Normal file
7
Task/Variables/ALGOL-W/variables-1.alg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
% declare some variables %
|
||||
integer a1, a2; real b; long real c; complex d; long complex f;
|
||||
logical g; bits h; string(32) j;
|
||||
|
||||
% assign "initial values" %
|
||||
f := d := c := b := a2 := a1 := 0; % multiple assignment %
|
||||
g := false; h := #a0; j := "Hello, World!";
|
||||
2
Task/Variables/ALGOL-W/variables-2.alg
Normal file
2
Task/Variables/ALGOL-W/variables-2.alg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
record R1 ( integer length; string(256) text );
|
||||
reference(R1) ref1, ref2;
|
||||
3
Task/Variables/ALGOL-W/variables-3.alg
Normal file
3
Task/Variables/ALGOL-W/variables-3.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
record person( string(32) name; integer age );
|
||||
record date( integer day, month, year );
|
||||
reference(person, date) ref3;
|
||||
1
Task/Variables/ALGOL-W/variables-4.alg
Normal file
1
Task/Variables/ALGOL-W/variables-4.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
reference(integer) refInt; % an illegal declaration %
|
||||
2
Task/Variables/ALGOL-W/variables-5.alg
Normal file
2
Task/Variables/ALGOL-W/variables-5.alg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
record INT_VALUE ( integer val );
|
||||
reference(INT_VALUE) refInt;
|
||||
7
Task/Variables/ALGOL-W/variables-6.alg
Normal file
7
Task/Variables/ALGOL-W/variables-6.alg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
% using the person record defined above...%
|
||||
reference (person) someone;
|
||||
someone := person % create a new person structure with uninitialised fields %
|
||||
name(someone) := "Fred"; % initialise the fields %
|
||||
age(someone) := 27;
|
||||
% could also initialise the fields when the record is created: %
|
||||
someone := person( "Harry", 32 );
|
||||
59
Task/Variables/ARM-Assembly/variables.arm
Normal file
59
Task/Variables/ARM-Assembly/variables.arm
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program variable.s */
|
||||
|
||||
/************************************/
|
||||
/* Constantes Définition */
|
||||
/************************************/
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szString: .asciz "String définition"
|
||||
sArea1: .fill 11, 1, ' ' @ 11 spaces
|
||||
@ or
|
||||
sArea2: .space 11,' ' @ 11 spaces
|
||||
|
||||
cCharac: .byte '\n' @ character
|
||||
cByte1: .byte 0b10101 @ 1 byte binary value
|
||||
|
||||
hHalfWord1: .hword 0xFF @ 2 bytes value hexa
|
||||
.align 4
|
||||
iInteger1: .int 123456 @ 4 bytes value decimal
|
||||
iInteger3: .short 0500 @ 4 bytes value octal
|
||||
iPointer1: .int 0x4000 @ 4 bytes value hexa
|
||||
@ or
|
||||
iPointer2: .word 0x4000 @ 4 bytes value hexa
|
||||
iPointer3: .int 04000 @ 4 bytes value octal
|
||||
|
||||
TabInteger4: .int 5,4,3,2 @ Area of 4 integers = 4 * 4 = 16 bytes
|
||||
|
||||
iDoubleInt1: .quad 0xFFFFFFFFFFFFFFFF @ 8 bytes
|
||||
|
||||
dfFLOAT1: .double 0f-31415926535897932384626433832795028841971.693993751E-40 @ Float 8 bytes
|
||||
sfFLOAT2: .float 0f-31415926535897932384626433832795028841971.693993751E-40 @ Float 4 bytes (or use .single)
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sBuffer: .skip 500 @ 500 bytes values zero
|
||||
iInteger2: .skip 4 @ 4 bytes value zero
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: @ entry of program
|
||||
ldr r0,iAdriInteger2 @ load variable address
|
||||
mov r1,#100
|
||||
str r1,[r0] @ init variable iInteger2
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc #0 @ perform the system call
|
||||
|
||||
iAdriInteger2: .int iInteger2 @ variable address iInteger2
|
||||
20
Task/Variables/AWK/variables-1.awk
Normal file
20
Task/Variables/AWK/variables-1.awk
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
BEGIN {
|
||||
# Variables are dynamically typecast, and do not need declaration prior to use:
|
||||
fruit = "banana" # create a variable, and fill it with a string
|
||||
a = 1 # create a variable, and fill it with a numeric value
|
||||
a = "apple" # re-use the above variable for a string
|
||||
print a, fruit
|
||||
|
||||
# Multiple assignments are possible from within a single statement:
|
||||
x = y = z = 3
|
||||
print "x,y,z:", x,y,z
|
||||
|
||||
# "dynamically typecast" means the content of a variable is used
|
||||
# as needed by the current operation, e.g. for a calculation:
|
||||
a = "1"
|
||||
b = "2banana"
|
||||
c = "3*4"
|
||||
|
||||
print "a,b,c=",a,b,c, "c+0=", c+0, 0+c
|
||||
print "a+b=", a+b, "b+c=", b+c
|
||||
}
|
||||
7
Task/Variables/AWK/variables-2.awk
Normal file
7
Task/Variables/AWK/variables-2.awk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# usage: awk -v x=9 -f test.awk
|
||||
BEGIN {
|
||||
y = 3
|
||||
z = x+y
|
||||
print "x,y,z:", x,y,z
|
||||
printf( "x=%d,y=%d,z=%d:", x,y,z )
|
||||
}
|
||||
15
Task/Variables/AWK/variables-3.awk
Normal file
15
Task/Variables/AWK/variables-3.awk
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function foo(s, k) {
|
||||
# s is an argument passed from caller
|
||||
# k is a dummy not passed by caller, but because it is
|
||||
# in the argument list, it will have a scope local to the function
|
||||
k = length(s)
|
||||
print "'" s "' contains", k, "characters"
|
||||
}
|
||||
BEGIN {
|
||||
k = 42
|
||||
s = "Test"
|
||||
foo("Demo")
|
||||
print "k is still", k
|
||||
foo(s,k)
|
||||
print "k still is", k
|
||||
}
|
||||
2
Task/Variables/AWK/variables-4.awk
Normal file
2
Task/Variables/AWK/variables-4.awk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Feeding standard-input with echo:
|
||||
echo -e "2 apples 0.44$ \n 3 banana 0.33$" | awk '{p=$1*$NF; sum+=p; print $2,":",p; }; END{print "Sum=",sum}'
|
||||
19
Task/Variables/Ada/variables.ada
Normal file
19
Task/Variables/Ada/variables.ada
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
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 referred to by Name.X
|
||||
begin
|
||||
...
|
||||
end F; -- locally declared variables stop to exist here
|
||||
begin
|
||||
Y := 1; -- Assign variable
|
||||
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
|
||||
15
Task/Variables/Apex/variables.apex
Normal file
15
Task/Variables/Apex/variables.apex
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// If not initialized at class/member level, it will be set to null
|
||||
Integer x = 0;
|
||||
Integer y; // y is null here
|
||||
Integer p,q,r; // declare multiple variables
|
||||
Integer i=1,j=2,k=3; // declare and initialize
|
||||
|
||||
/*
|
||||
* Similar to Integer, below variables can be initialized together separated by ','.
|
||||
*/
|
||||
String s = 'a string';
|
||||
Decimal d = 0.0;
|
||||
Double dbl = 0.0;
|
||||
Blob blb = Blob.valueOf('Any String');
|
||||
Boolean b = true;
|
||||
AClassName cls = new AClassName();
|
||||
1
Task/Variables/AppleScript/variables-1.applescript
Normal file
1
Task/Variables/AppleScript/variables-1.applescript
Normal file
|
|
@ -0,0 +1 @@
|
|||
set x to 1
|
||||
4
Task/Variables/AppleScript/variables-2.applescript
Normal file
4
Task/Variables/AppleScript/variables-2.applescript
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
global x
|
||||
set x to 1
|
||||
local y
|
||||
set y to 2
|
||||
15
Task/Variables/AppleScript/variables-3.applescript
Normal file
15
Task/Variables/AppleScript/variables-3.applescript
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
on localx()
|
||||
set x to 0 -- implicit local
|
||||
return x
|
||||
end localx
|
||||
|
||||
on globalx()
|
||||
set x to 0 -- implicit local
|
||||
return my x
|
||||
end globalx
|
||||
|
||||
on run
|
||||
set x to 1 -- top-level implicit global
|
||||
return {localx(), globalx()}
|
||||
end run
|
||||
--> RETURNS: {0, 1}
|
||||
1
Task/Variables/AppleScript/variables-4.applescript
Normal file
1
Task/Variables/AppleScript/variables-4.applescript
Normal file
|
|
@ -0,0 +1 @@
|
|||
property x : 1
|
||||
15
Task/Variables/Applesoft-BASIC/variables.basic
Normal file
15
Task/Variables/Applesoft-BASIC/variables.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
10 A = 1.7: REM LET IS NOT REQUIRED
|
||||
20 LET B% = 1.7: REM THE PERCENT SIGN INDICATES AN INTEGER; THIS GETS TRUNCATED DOWN
|
||||
30 LET C$ = "0121": REM THE DOLLAR SIGN INDICATES A STRING DATA TYPE. THE LEADING ZERO IS NOT TRUNCATED
|
||||
40 DIM D(20): REM CREATE AN ARRAY OF 21 FLOATING POINT NUMBERS
|
||||
50 DIM E$(5,10): REM CREATE A TWO DIMENSIONAL ARRAY OF 66 STRINGS
|
||||
60 LET D(1) = 1.3: REM ASSIGN THE SECOND ELEMENT OF D
|
||||
70 Y$(3) = "ROSE": REM ASSIGN A VALUE TO THE FOURTH STRING
|
||||
80 PRINT X: REM UNASSIGNED FLOATING POINT AND INTEGER VARIABLES HAVE A DEFAULT VALUE OF ZERO
|
||||
90 PRINT Y$(2): REM UNASSIGNED STRING VARIABLES ARE EMPTY
|
||||
100 PRINT Y$(3);"TTA CODE": REM THERE WON'T BE SPACES BETWEEN ROSE AND ETTA
|
||||
110 F%(10) = 0: REM IF ARRAYS ARE NOT DECLARED THEY HAVE 11 ELEMENTS BY DEFAULT; IE. DIM F%(10)
|
||||
120 PRINT G: REM THIS PRINTS 0 AND IS NOT AN ERROR EVEN THOUGH G HAS NOT BEEN DEFINED
|
||||
130 PRINT D(0): REM THIS IS NOT AN ERROR BECAUSE ELEMENTS ARE NUMBERED FROM ZERO.
|
||||
140 PRINT F%: REM THIS PRINTS 0 BECAUSE F% IS A DIFFERENT VARIABLE THAN THE ARRAY F%(10)
|
||||
150 LET D(21) = 6: REM THIS IS AN ERROR BECAUSE D ONLY HAS 21 ELEMENTS INDEXED FROM 0 TO 20.
|
||||
17
Task/Variables/Arturo/variables.arturo
Normal file
17
Task/Variables/Arturo/variables.arturo
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
num: 10
|
||||
str: "hello world"
|
||||
|
||||
arrA: [1 2 3]
|
||||
arrB: ["one" "two" "three"]
|
||||
arrC: [1 "two" [3 4 5]]
|
||||
arrD: ["one" true [ print "something" ]]
|
||||
|
||||
dict: [
|
||||
name: "john"
|
||||
surname: "doe"
|
||||
function: $[][
|
||||
print "do sth"
|
||||
]
|
||||
]
|
||||
|
||||
inspect symbols
|
||||
10
Task/Variables/AutoHotkey/variables.ahk
Normal file
10
Task/Variables/AutoHotkey/variables.ahk
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
x = hello ; assign verbatim as a string
|
||||
z := 3 + 4 ; assign an expression
|
||||
if !y ; uninitialized variables are assumed to be 0 or "" (blank string)
|
||||
Msgbox %x% ; variable dereferencing is done by surrounding '%' signs
|
||||
fx()
|
||||
{
|
||||
local x ; variable default scope in a function is local anyways
|
||||
global y ;
|
||||
static z=4 ; initialized once, then value is remembered between function calls
|
||||
}
|
||||
1
Task/Variables/Axe/variables-1.axe
Normal file
1
Task/Variables/Axe/variables-1.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
1→A
|
||||
1
Task/Variables/Axe/variables-2.axe
Normal file
1
Task/Variables/Axe/variables-2.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
#Realloc(L₂)
|
||||
16
Task/Variables/BASIC/variables.basic
Normal file
16
Task/Variables/BASIC/variables.basic
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
10 LET A=1.3
|
||||
20 LET B%=1.3: REM The sigil indicates an integer, so this will be rounded down
|
||||
30 LET C$="0121": REM The sigil indicates a string data type. the leading zero is not truncated
|
||||
40 DIM D(10): REM Create an array of 10 digits
|
||||
50 DIM E$(5.10): REM Create an array of 5 strings, with a maximum length of 10 characters
|
||||
60 LET D(1)=1.3: REM Assign the first element of d
|
||||
70 LET E$(3)="ROSE": REM Assign a value to the third string
|
||||
80 PRINT D(3): REM Unassigned array elements have a default value of zero
|
||||
90 PRINT E$(3): REM Ten spaces because string arrays are not dynamic
|
||||
100 PRINT E$(3);"TTA CODE": REM There will be spaces between rose and etta
|
||||
110 DIM F%(10): REM Integers use less space than floating point values
|
||||
120 PRINT G: REM This is an error because f has not been defined
|
||||
130 PRINT D(0): REM This is an error because elements are numbered from one
|
||||
140 LET D(11)=6: REM This is an error because d only has 10 elements
|
||||
150 PRINT F%: REM This is an error because we have not provided an element number
|
||||
160 END
|
||||
33
Task/Variables/BBC-BASIC/variables.basic
Normal file
33
Task/Variables/BBC-BASIC/variables.basic
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
REM BBC BASIC (for Windows) has the following scalar variable types;
|
||||
REM the type is explicitly indicated by means of a suffix character.
|
||||
REM Variable names must start with A-Z, a-z, _ or `, and may contain
|
||||
REM any of those characters plus 0-9 and @; they are case-sensitive.
|
||||
|
||||
A& = 123 : REM Unsigned 8-bit byte (0 to 255)
|
||||
A% = 12345678 : REM Signed 32-bit integer (-2147483648 to +2147483647)
|
||||
A = 123.45E6 : REM Variant 40-bit float or 32-bit integer (no suffix)
|
||||
A# = 123.45E6 : REM Variant 64-bit double or 32-bit integer
|
||||
A$ = "Abcdef" : REM String (0 to 65535 bytes)
|
||||
|
||||
REM Scalar variables do not need to be declared but must be initialised
|
||||
REM before being read, otherwise a 'No such variable' error is reported
|
||||
REM The static integer variables A% to Z% are permanently defined.
|
||||
|
||||
REM BBC BASIC also has indirection operators which allow variable-like
|
||||
REM entities to be created in memory:
|
||||
|
||||
DIM addr 7 : REM Allocate 8 bytes of heap
|
||||
?addr = 123 : REM Unsigned 8-bit byte (0 to 255)
|
||||
!addr = 12345 : REM Signed 32-bit integer (-2147483648 to +2147483647)
|
||||
|addr = 12.34 : REM Variant 40-bit or 64-bit float or 32-bit integer
|
||||
$addr = "Abc" : REM String terminated by CR (0 to 65535 bytes)
|
||||
$$addr = "Abc": REM String terminated by NUL (0 to 65535 bytes)
|
||||
|
||||
REM The integer indirection operators may be used in a dyadic form:
|
||||
offset = 4
|
||||
addr?offset = 12345678 : REM Unsigned 8-bit byte at addr+offset
|
||||
addr!offset = 12345678 : REM Signed 32-bit integer at addr+offset
|
||||
|
||||
REM All variables in BBC BASIC have global scope unless they are used
|
||||
REM as a formal parameter of a function or procedure, or are declared
|
||||
REM as LOCAL or PRIVATE. This is different from most other BASICs.
|
||||
1
Task/Variables/BQN/variables.bqn
Normal file
1
Task/Variables/BQN/variables.bqn
Normal file
|
|
@ -0,0 +1 @@
|
|||
a ← 10
|
||||
16
Task/Variables/Batch-File/variables.bat
Normal file
16
Task/Variables/Batch-File/variables.bat
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
@echo off
|
||||
|
||||
::setting variables in defferent ways
|
||||
set myInt1=5
|
||||
set myString1=Rosetta Code
|
||||
set "myInt2=5"
|
||||
set "myString2=Rosetta Code"
|
||||
|
||||
::Arithmetic
|
||||
set /a myInt1=%myInt1%+1
|
||||
set /a myInt2+=1
|
||||
set /a myInt3=myInt2+ 5
|
||||
|
||||
set myInt
|
||||
set myString
|
||||
pause>nul
|
||||
1
Task/Variables/Bracmat/variables.bracmat
Normal file
1
Task/Variables/Bracmat/variables.bracmat
Normal file
|
|
@ -0,0 +1 @@
|
|||
(myfunc=i j.!arg:(?i.?j)&!i+!j)
|
||||
1
Task/Variables/C++/variables-1.cpp
Normal file
1
Task/Variables/C++/variables-1.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
int a;
|
||||
1
Task/Variables/C++/variables-2.cpp
Normal file
1
Task/Variables/C++/variables-2.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
auto a = 1; // int a = 1
|
||||
1
Task/Variables/C++/variables-3.cpp
Normal file
1
Task/Variables/C++/variables-3.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
std::vector<int> intVec;
|
||||
1
Task/Variables/C-sharp/variables-1.cs
Normal file
1
Task/Variables/C-sharp/variables-1.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
int j;
|
||||
1
Task/Variables/C-sharp/variables-2.cs
Normal file
1
Task/Variables/C-sharp/variables-2.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
int p, a, d;
|
||||
5
Task/Variables/C-sharp/variables-3.cs
Normal file
5
Task/Variables/C-sharp/variables-3.cs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
int a = 4;
|
||||
int b;
|
||||
int c = Func(a);
|
||||
|
||||
b = 5;
|
||||
1
Task/Variables/C/variables-1.c
Normal file
1
Task/Variables/C/variables-1.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
int j;
|
||||
1
Task/Variables/C/variables-2.c
Normal file
1
Task/Variables/C/variables-2.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
double double1, double2, double3;
|
||||
2
Task/Variables/C/variables-3.c
Normal file
2
Task/Variables/C/variables-3.c
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
short b1 = 2500;
|
||||
long elwood = 3*BSIZE, jake = BSIZE -2;
|
||||
1
Task/Variables/C/variables-4.c
Normal file
1
Task/Variables/C/variables-4.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
char mystring[21];
|
||||
1
Task/Variables/C/variables-5.c
Normal file
1
Task/Variables/C/variables-5.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
const char * mytext = "The C Language";
|
||||
5
Task/Variables/COBOL/variables-1.cobol
Normal file
5
Task/Variables/COBOL/variables-1.cobol
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
MOVE 5 TO x
|
||||
MOVE FUNCTION SOME-FUNC(x) TO y
|
||||
MOVE "foo" TO z
|
||||
MOVE "values 1234" TO group-item
|
||||
SET some-index TO 5
|
||||
18
Task/Variables/COBOL/variables-2.cobol
Normal file
18
Task/Variables/COBOL/variables-2.cobol
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
01 normal-date.
|
||||
03 year PIC 9(4).
|
||||
03 FILLER PIC X VALUE "-".
|
||||
03 month PIC 99.
|
||||
03 FILLER PIC X VALUE "-".
|
||||
03 dday PIC 99. *> Misspelling is intentional; day is a reserved word.
|
||||
|
||||
01 reversed-date.
|
||||
03 dday PIC 99.
|
||||
03 FILLER PIC X VALUE "-".
|
||||
03 month PIC 99.
|
||||
03 FILLER PIC X VALUE "-".
|
||||
03 year PIC 9(4).
|
||||
...
|
||||
PROCEDURE DIVISION.
|
||||
MOVE "2012-11-10" TO normal-date
|
||||
MOVE CORR normal-date TO reversed-date
|
||||
DISPLAY reversed-date *> Shows '10-11-2012'
|
||||
4
Task/Variables/COBOL/variables-3.cobol
Normal file
4
Task/Variables/COBOL/variables-3.cobol
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
01 a PIC X(20). *> a is a string of 20 characters.
|
||||
01 b PIC 9(10). *> b is a 10-digit integer.
|
||||
01 c PIC 9(10)V9(5). *> c is a decimal number with a 10-digit integral part and a 5-digit fractional part.
|
||||
01 d PIC 99/99/99. *> d is an edited number, with a slash between each pair of digits in a 6-digit integer.
|
||||
4
Task/Variables/COBOL/variables-4.cobol
Normal file
4
Task/Variables/COBOL/variables-4.cobol
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*> Group data items do not have a picture clause.
|
||||
01 group-item.
|
||||
03 sub-data PIC X(10).
|
||||
03 more-sub-data PIC X(10).
|
||||
8
Task/Variables/COBOL/variables-5.cobol
Normal file
8
Task/Variables/COBOL/variables-5.cobol
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 initialized-data PIC X(15) VALUE "Hello, World!".
|
||||
01 other-data PIC X(15).
|
||||
...
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY initialized-data *> Shows 'Hello, World!'
|
||||
DISPLAY other-data *> Will probably show 15 spaces.
|
||||
3
Task/Variables/COBOL/variables-6.cobol
Normal file
3
Task/Variables/COBOL/variables-6.cobol
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
01 group-item VALUE "Hello!12345".
|
||||
03 a-string PIC X(6). *> Contains "Hello!"
|
||||
03 a-number PIC 9(5). *> Contains '12345'.
|
||||
6
Task/Variables/COBOL/variables-7.cobol
Normal file
6
Task/Variables/COBOL/variables-7.cobol
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
some-str (1:1) *> Gets the first character from the string
|
||||
some-num (1:3) *> Get the first three digits from the number
|
||||
another-string (5:) *> Get everything from the 5th character/digit onwards.
|
||||
|
||||
*> To reference modify an array element
|
||||
some-table (1) (5:1) *> Get the 5th character from the 1st element in the table
|
||||
1
Task/Variables/ChucK/variables-1.chuck
Normal file
1
Task/Variables/ChucK/variables-1.chuck
Normal file
|
|
@ -0,0 +1 @@
|
|||
int a;
|
||||
1
Task/Variables/ChucK/variables-2.chuck
Normal file
1
Task/Variables/ChucK/variables-2.chuck
Normal file
|
|
@ -0,0 +1 @@
|
|||
int b,c,d;
|
||||
1
Task/Variables/ChucK/variables-3.chuck
Normal file
1
Task/Variables/ChucK/variables-3.chuck
Normal file
|
|
@ -0,0 +1 @@
|
|||
0 => int e;
|
||||
1
Task/Variables/Clojure/variables-1.clj
Normal file
1
Task/Variables/Clojure/variables-1.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(declare foo)
|
||||
1
Task/Variables/Clojure/variables-10.clj
Normal file
1
Task/Variables/Clojure/variables-10.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def foo (atom 42))
|
||||
1
Task/Variables/Clojure/variables-11.clj
Normal file
1
Task/Variables/Clojure/variables-11.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def bar (ref 42))
|
||||
1
Task/Variables/Clojure/variables-12.clj
Normal file
1
Task/Variables/Clojure/variables-12.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def baz (agent 42))
|
||||
1
Task/Variables/Clojure/variables-2.clj
Normal file
1
Task/Variables/Clojure/variables-2.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def bar)
|
||||
1
Task/Variables/Clojure/variables-3.clj
Normal file
1
Task/Variables/Clojure/variables-3.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def foo 42)
|
||||
1
Task/Variables/Clojure/variables-4.clj
Normal file
1
Task/Variables/Clojure/variables-4.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defonce bar 42)
|
||||
1
Task/Variables/Clojure/variables-5.clj
Normal file
1
Task/Variables/Clojure/variables-5.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defn baz [x] 42)
|
||||
1
Task/Variables/Clojure/variables-6.clj
Normal file
1
Task/Variables/Clojure/variables-6.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defmacro qux [x] 42)
|
||||
1
Task/Variables/Clojure/variables-7.clj
Normal file
1
Task/Variables/Clojure/variables-7.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(let [foo 42] ...)
|
||||
2
Task/Variables/Clojure/variables-8.clj
Normal file
2
Task/Variables/Clojure/variables-8.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(def ^:dynamic foo 10)
|
||||
(binding [foo 20] ...)
|
||||
2
Task/Variables/Clojure/variables-9.clj
Normal file
2
Task/Variables/Clojure/variables-9.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defn len [^String x]
|
||||
(.length x))
|
||||
122
Task/Variables/Commodore-BASIC/variables-1.basic
Normal file
122
Task/Variables/Commodore-BASIC/variables-1.basic
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
1 rem rosetta code
|
||||
5 rem commodore basic variable demonstration
|
||||
10 print chr$(147);chr$(14);:ti$="000000":rem see lines 420-460
|
||||
15 rem numeric variables default to 0; strings default to empty
|
||||
20 print a:print b%:print c$:print
|
||||
25 :
|
||||
30 rem no symbol after variable defaults to float.
|
||||
35 let a=1.7
|
||||
40 rem "let" is not required and rarely used.
|
||||
45 b=2.42
|
||||
50 print a:print b
|
||||
55 rem % means integer type; digits after decimal are truncated
|
||||
60 b%=1.7
|
||||
65 print b%
|
||||
70 rem $ means string type
|
||||
75 c$="Commodore"
|
||||
80 print c$:print
|
||||
85 :
|
||||
90 rem each type is unique, even when name is "same"
|
||||
95 a=5.0
|
||||
100 a%=9
|
||||
105 a$="twenty-five"
|
||||
110 print a:print a%:print a$:print
|
||||
115 :
|
||||
120 rem names unique only to two characters; extra ignored
|
||||
125 li=10:lives=8:lights=64
|
||||
130 print li:print lives:print lights:print
|
||||
135 rem second character can be alphanumeric, but is not array
|
||||
140 s1=100 : s2=200 : s3=300
|
||||
145 print s1:print s2:print s3:print
|
||||
150 gosub 5000
|
||||
155 :
|
||||
160 rem strings preserve all literal characters
|
||||
165 rem numerics drop leading zeros and trailing zeros after decimal
|
||||
170 n$="01276":print n$:rem 01276
|
||||
175 o%=01276:print n%: rem 1276
|
||||
180 p=4.900:print p: print: rem 4.9
|
||||
185 :
|
||||
190 rem string-numeric conversion functions
|
||||
195 c$="05034"
|
||||
200 c%=val(c$) : rem converts to the numeric value of 5034 (first zero dropped)
|
||||
205 d=123.45600 : rem define a float
|
||||
210 d$=str$(d) : rem converts above into a string
|
||||
215 print c$:print c%:print d:print d$:print
|
||||
218 :
|
||||
220 rem strings can be ordered/compared > or < like numbers
|
||||
225 input "Enter a string";x$:print
|
||||
230 input "Enter another string";y$:print
|
||||
235 if x$>y$ then print x$;" comes after ";y$
|
||||
240 if x$<y$ then print x$;" comes before ";y$
|
||||
245 if x$=y$ then print "You entered the same string twice!"
|
||||
250 gosub 5000
|
||||
255 :
|
||||
260 rem numbers have a leading character for pos/neg sign
|
||||
265 rem " " means positive
|
||||
270 a=-52:b=124
|
||||
275 print a:print b:print
|
||||
280 :
|
||||
285 rem variable operations
|
||||
290 e$="endothermic":print e$
|
||||
295 print left$(e$,3) : rem "end"
|
||||
300 print right$(e$,3) : rem "mic"
|
||||
305 print mid$(e$,4,5) : rem "other"
|
||||
310 print
|
||||
315 a=5:b=20:c=a+b:print a;"+";b;"=";c : rem addition
|
||||
320 q=90:r=60:s=q-r:print s : rem subtraction
|
||||
325 x=3:y=4:z=x*y:print x;"*";y;"=";z : rem 12 multiplication
|
||||
330 l=12:m=16:n=l/m:print l;"/";m;"=";n :rem division
|
||||
335 rem string concatenation
|
||||
340 print
|
||||
345 f$="John":l$="Jones":n$=l$+", "+f$:print f$:print l$:print n$
|
||||
350 gosub 5000
|
||||
355 :
|
||||
360 rem arrays can be single or multidimensional
|
||||
365 rem array index starts at 0
|
||||
370 rem single dimenstion arrays of 11 elements or less
|
||||
375 rem do not need to be DIMensioned
|
||||
380 a$(0)="first":a$(1)="second":a$(3)="third":rem we skipped index 2
|
||||
385 for i=0 to 3:print a$(i):next
|
||||
390 gosub 5000
|
||||
395 dim b(1,20) : rem 42 elements
|
||||
400 for i=0 to 1:for j=0 to 20:b(i,j)=(i+1)*j:next j,i
|
||||
405 for i=0 to 1:print chr$(19):for j=0 to 20:print tab(i*6);b(i,j):next j,i
|
||||
410 gosub 5000
|
||||
415 :
|
||||
420 rem special variables - ti and st are technically functions,
|
||||
425 rem but ti$ can be assigned a value similar to a string variable
|
||||
430 t$=left$(ti$,2)+":"+mid$(ti$,3,2)+":"+right$(ti$,2)
|
||||
435 print "Ticks since program started:":print ti
|
||||
440 print "Elapsed time since program started:":print t$
|
||||
445 print "I/O Status:";st : rem i/o status
|
||||
450 print:print "Enter new time (HHMMSS): ";:gosub 5200
|
||||
455 ti$=t$:gosub 5500
|
||||
460 print
|
||||
465 :
|
||||
470 rem all variables can be cleared with the "clr" statement
|
||||
475 rem however, this also clears the return address stack for subroutines
|
||||
480 rem making "return" not possible.
|
||||
485 print "Before CLR:":print a:print a$:print a$(0):print b:print c
|
||||
490 clr:print:print "After CLR:"
|
||||
495 print a:print a$:print a$(0):print b:print c
|
||||
500 print
|
||||
505 end
|
||||
600 :
|
||||
700 rem supporting subroutines
|
||||
800 :
|
||||
5000 rem screen pause routine
|
||||
5005 print:print "press a key to continue"
|
||||
5010 get k$:if k$="" then 5010
|
||||
5015 print chr$(147):return
|
||||
5020 :
|
||||
5200 rem custom time input routine
|
||||
5205 t$="":for d=1 to 6
|
||||
5210 get k$:if k$<"0" or k$>"9" then 5210
|
||||
5215 t$=t$+k$:print k$;:next
|
||||
5220 return
|
||||
5230 :
|
||||
5500 rem display live clock
|
||||
5505 print chr$(147):print:print "Press a key to continue."
|
||||
5510 print chr$(19);"Time: "left$(ti$,2)":"mid$(ti$,3,2)":"right$(ti$,2);
|
||||
5515 get k$:if k$="" then 5510
|
||||
5520 print chr$(147);:return
|
||||
12
Task/Variables/Commodore-BASIC/variables-2.basic
Normal file
12
Task/Variables/Commodore-BASIC/variables-2.basic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
10 print chr$(147);chr$(14);:ti$="0000000":rem see lines 420-460
|
||||
|
||||
430 t$=left$(ti$,2)+":"+mid$(ti$,3,2)+":"+mid$(ti$,5,2)+"."+right$(ti$,1)
|
||||
|
||||
5205 t$="":for d=1 to 7
|
||||
|
||||
5500 rem display live clock
|
||||
5505 print chr$(147):print:print "Press a key to continue."
|
||||
5510 t$=left$(ti$,2)+":"+mid$(ti$,3,2)+":"+mid$(ti$,5,2)+"."+right$(ti$,1)
|
||||
5515 print chr$(19);"Time: "t$
|
||||
5520 get k$:if k$="" then 5510
|
||||
5525 print chr$(147);:return
|
||||
30
Task/Variables/Commodore-BASIC/variables-3.basic
Normal file
30
Task/Variables/Commodore-BASIC/variables-3.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
REM Tiny Basic has exactly 26 variables.
|
||||
REM They start off initialised to zero.
|
||||
PRINT A
|
||||
|
||||
REM The only data type is sixteen-bit signed integer.
|
||||
REM They are assigned using the LET statement.
|
||||
REM Their scope is the whole program.
|
||||
LET B = -12345
|
||||
REM The integer arithmetic operations of + - * and / can be used
|
||||
REM and so can the unary negative and positive operators - +
|
||||
LET C = 1 + B - B/5
|
||||
LET A = -B
|
||||
PRINT "B is ", B
|
||||
PRINT "C is ", C
|
||||
GOSUB 10
|
||||
|
||||
REM The comparison operators = < > <= >= <> are available,
|
||||
REM but their results are not expressions and can only be used in an
|
||||
REM if statement.
|
||||
LET D = 3
|
||||
IF D <> 7 THEN LET D = 7
|
||||
GOTO D-2
|
||||
PRINT "Skip this"
|
||||
5 PRINT "Gotos and gosubs can be computed. Beware of moving spaghetti."
|
||||
END
|
||||
10 PRINT "B is now ", B
|
||||
RETURN
|
||||
|
||||
REM Tiny Basic does not support arrays or pointers. Strings can
|
||||
REM be used, but only as string constants within a PRINT statement.
|
||||
1
Task/Variables/Common-Lisp/variables-1.lisp
Normal file
1
Task/Variables/Common-Lisp/variables-1.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defparameter *x* nil "nothing")
|
||||
3
Task/Variables/Common-Lisp/variables-10.lisp
Normal file
3
Task/Variables/Common-Lisp/variables-10.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defun frobnicate (x)
|
||||
(declare (type fixnum x))
|
||||
(the fixnum (+ x 128)))
|
||||
1
Task/Variables/Common-Lisp/variables-2.lisp
Normal file
1
Task/Variables/Common-Lisp/variables-2.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defvar *x* 42 "The answer.")
|
||||
1
Task/Variables/Common-Lisp/variables-3.lisp
Normal file
1
Task/Variables/Common-Lisp/variables-3.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(documentation '*x* 'variable)
|
||||
3
Task/Variables/Common-Lisp/variables-4.lisp
Normal file
3
Task/Variables/Common-Lisp/variables-4.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(let ((jenny (list 8 6 7 5 3 0 9))
|
||||
hobo-joe)
|
||||
(apply #'+ jenny))
|
||||
4
Task/Variables/Common-Lisp/variables-5.lisp
Normal file
4
Task/Variables/Common-Lisp/variables-5.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(progn
|
||||
(let ((*x* 43))
|
||||
(print *x*)
|
||||
(print *x*))
|
||||
1
Task/Variables/Common-Lisp/variables-6.lisp
Normal file
1
Task/Variables/Common-Lisp/variables-6.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(setf *x* 625)
|
||||
2
Task/Variables/Common-Lisp/variables-7.lisp
Normal file
2
Task/Variables/Common-Lisp/variables-7.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(setf *x* 42 *y* (1+ *x*))
|
||||
=>43
|
||||
3
Task/Variables/Common-Lisp/variables-8.lisp
Normal file
3
Task/Variables/Common-Lisp/variables-8.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(setf *x* 625)
|
||||
(psetf *x* 42 *y* (1+ *x*)
|
||||
=>NIL
|
||||
3
Task/Variables/Common-Lisp/variables-9.lisp
Normal file
3
Task/Variables/Common-Lisp/variables-9.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(declaim (ftype (function (fixnum) fixnum) frobnicate))
|
||||
(defun frobnicate (x)
|
||||
(+ x 42))
|
||||
3
Task/Variables/D/variables.d
Normal file
3
Task/Variables/D/variables.d
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
float bite = 36.321; ///_Defines a floating-point number (float), "bite", with a value of 36.321
|
||||
float[3] bites; ///_Defines a static array of 3 floats
|
||||
float[] more_bites; ///_Defines a dynamic array of floats
|
||||
72
Task/Variables/DBL/variables.dbl
Normal file
72
Task/Variables/DBL/variables.dbl
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
;
|
||||
; Variables examples for DBL version 4 by Dario B.
|
||||
;
|
||||
|
||||
.DEFINE NR,10 ;const
|
||||
.DEFINE AP,"PIPPO" ;const
|
||||
|
||||
|
||||
RECORD CUSTOM
|
||||
COD, D5
|
||||
NAME, A80
|
||||
ZIP, D6
|
||||
CITY, A80
|
||||
;-----------------------
|
||||
|
||||
RECORD
|
||||
|
||||
ALPHA, A5 ;alphanumeric
|
||||
NUMBR, D5 ;number
|
||||
DECML, F5.2 ;float
|
||||
NUMVE, 10D5 ;array of number
|
||||
NUMAR, [10,2]D5 ;array of number
|
||||
ALPV1, 10A8 ;array of alphanumeric
|
||||
ALPV2, [NR]A8 ;array of alphanumeric
|
||||
ALPA1, [10,2]A8 ;array of alphanumeric
|
||||
|
||||
NUMV, 3D3,100,200,300
|
||||
ALPV, 2A3,'ABC','FGH','KLM'
|
||||
MSX, A9,"VARIABLES"
|
||||
MSG, A*,'Esempio di variabile autodimensionante'
|
||||
|
||||
PROC
|
||||
;-----------------------------------------------------------------------
|
||||
|
||||
CLEAR ALPHA,NUMBR,DEML,NUMVE(1:10*5),NUMAR(1:10*2*5),ALPV1(1:10*8)
|
||||
CLEAR ALPV2(1:10*8),ALPA1(1:10*2*8)
|
||||
|
||||
ALPHA="PIPPO"
|
||||
NUMBR=10
|
||||
DECML=20.55
|
||||
|
||||
CLEAR CUSTOM
|
||||
COD=1050
|
||||
NAME='Dario Benenati'
|
||||
ZIP=27100
|
||||
CITY="PAVIA"
|
||||
|
||||
NUMVE(1:10*5)=
|
||||
NUMVE(1)=1
|
||||
SET NUMVE(2),NUMVE(3),NUMVE(4)=2
|
||||
|
||||
NUMAR(1:10*2*5)=
|
||||
NUMAR[1,1]=11
|
||||
NUMAR[1,2]=12
|
||||
NUMAR[2,1]=21
|
||||
NUMAR[2,2]=22
|
||||
|
||||
ALPV1(1:10*8)=
|
||||
ALPV1(1)="PIPPO"
|
||||
APLV1(2)="PLUTO"
|
||||
APLV1(2)="ABCDEFGHIJKLMNOP" ;ALPV(3)='IJKLMNOP'
|
||||
|
||||
ALPV2(1:10*8)=" "
|
||||
ALPV2[1]="PIPPO"
|
||||
ALPV2(2)="PLUTO"
|
||||
ALPV2[3](3:2)="FO"
|
||||
ALPV2[4](3,4)="FO"
|
||||
|
||||
SET ALPA1[1,1],ALPA1[1,2]="PLUTO"
|
||||
ALPA1[2,1](3:2)="FO"
|
||||
ALPA1[2,1](3,4)="FO"
|
||||
;.....................
|
||||
12
Task/Variables/DM/variables-1.dm
Normal file
12
Task/Variables/DM/variables-1.dm
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Both of the following declarations can be seen as a tree,
|
||||
// var -> <varname>
|
||||
var/x
|
||||
var y
|
||||
|
||||
// They can also be defined like this.
|
||||
// This is once again a tree structure, but this time the "var" only appears once, and the x and y are children.
|
||||
var
|
||||
x
|
||||
y
|
||||
// And like this, still a tree structure.
|
||||
var/x, y
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue