langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,38 @@
/* NetRexx */
options replace format comments java crossref symbols
iv = 8; say '8'.right(20) '==' iv.right(8) -- 8
iv = -8; say '-8'.right(20) '==' iv.right(8) -- -8
iv = 1x8; say '1x8'.right(20) '==' iv.right(8) -- -8
iv = 2x8; say '2x8'.right(20) '==' iv.right(8) -- 8
iv = 2x08; say '2x08'.right(20) '==' iv.right(8) -- 8
iv = 0x08; say '0x08'.right(20) '==' iv.right(8) -- 8
iv = 0x10; say '0x10'.right(20) '==' iv.right(8) -- 16
iv = 0x81; say '0x81'.right(20) '==' iv.right(8) -- 129
iv = 2x81; say '2x81'.right(20) '==' iv.right(8) -- -127
iv = 3x81; say '3x81'.right(20) '==' iv.right(8) -- 129
iv = 4x81; say '4x81'.right(20) '==' iv.right(8) -- 129
iv = 04x81; say '04x81'.right(20) '==' iv.right(8) -- 129
iv = 16x81; say '16x81'.right(20) '==' iv.right(8) -- 129
iv = 4xF081; say '4xF081'.right(20) '==' iv.right(8) -- -3967
iv = 8xF081; say '8xF081'.right(20) '==' iv.right(8) -- 61569
iv = 0Xf081; say '0Xf081'.right(20) '==' iv.right(8) -- 61569
iv = 0xffff; say '0xffff'.right(20) '==' iv.right(8) -- 65535
iv = 4xffff; say '4xffff'.right(20) '==' iv.right(8) -- -1
iv = 8xffff; say '8xffff'.right(20) '==' iv.right(8) -- 65535
iv = 1b0; say '1b0'.right(20) '==' iv.right(8) -- 0
iv = 1b1; say '1b1'.right(20) '==' iv.right(8) -- -1
iv = 2b1; say '2b1'.right(20) '==' iv.right(8) -- 1
iv = 0b10; say '0b10'.right(20) '==' iv.right(8) -- 2
iv = 2b10; say '2b10'.right(20) '==' iv.right(8) -- -2
iv = 3b10; say '3b10'.right(20) '==' iv.right(8) -- 2
iv = 0b100; say '0b100'.right(20) '==' iv.right(8) -- 4
iv = 3b100; say '3b100'.right(20) '==' iv.right(8) -- -4
iv = 4b100; say '4b100'.right(20) '==' iv.right(8) -- 4
iv = 4b1000; say '4b1000'.right(20) '==' iv.right(8) -- -8
iv = 8B1000; say '8B1000'.right(20) '==' iv.right(8) -- 8
iv = 00B1111111111111111; say '00B1111111111111111'.right(20) '==' iv.right(8) -- 65535
iv = 16B1111111111111111; say '16B1111111111111111'.right(20) '==' iv.right(8) -- -1
iv = 32B1111111111111111; say '32B1111111111111111'.right(20) '==' iv.right(8) -- 65535
return

View file

@ -0,0 +1,8 @@
# 727 = 0b1011010111;;
- : bool = true
# 727 = 0o1327;;
- : bool = true
# 727 = 0x2d7;;
- : bool = true
# 12345 = 12_345 (* underscores are ignored; useful for keeping track of places *);;
- : bool = true

View file

@ -0,0 +1,7 @@
bundle Default {
class Literal {
function : Main(args : String[]) ~ Nil {
(727 = 0x2d7)->PrintLine();
}
}
}

View file

@ -0,0 +1,7 @@
try
%% binary octal dec. hexadecimal
0b1011010111 = 01327 = 727 = 0x2d7
{Show success}
catch _ then
{Show unexpectedError}
end

View file

@ -0,0 +1 @@
X = ~42

View file

@ -0,0 +1,4 @@
12345
'b4'xn /* a hexadecimal literal integer. */
'ffff_ffff'xn /* a longer hexadecimal hexadecimal integer. */
1101b /* a binary integer, of value decimal 13. */

View file

@ -0,0 +1,14 @@
say 255;
say 0d255;
say 0xff;
say 0o377;
say 0b1111_1111;
say :10<255>;
say :16<ff>;
say :8<377>;
say :2<1111_1111>;
say :3<100110>;
say :4<3333>;
say :12<193>;
say :36<73>;

View file

@ -0,0 +1,5 @@
123 % 123
8#1777 % 1023
16#FFFE % 65534
2#11011 % 27
5#44 % 24

View file

@ -0,0 +1,2 @@
727 # base 10
0x2d7 # base 16

View file

@ -0,0 +1,4 @@
3KB # 3072
3MB # 3145728
3GB # 3221225472
3TB # 3298534883328

View file

@ -0,0 +1,3 @@
x = 15 ;15 in base 10
x = %1111 ;15 in base 2
x = $f ;15 in base 16

View file

@ -0,0 +1 @@
x = 'a' ;129

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,5 @@
#100 ( decimal )
%100 ( binary )
$100 ( hex )
'c ( ascii character )
100 ( number in current base )

View file

@ -0,0 +1,11 @@
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln(727);
writeln(32#MN);
writeln(16#2D7);
writeln(10#727);
writeln(8#1327);
writeln(2#1011010111);
end func;

View file

@ -0,0 +1 @@
2r1011010111 + 8r1327 + 10r727 + 16r2d7 / 4

View file

@ -0,0 +1,11 @@
- 727 = 0x2d7;
val it = true : bool
- 727 = Word.toInt 0w727;
val it = true : bool
- 0w727 = 0wx2d7;
val it = true : bool
- ~727; (* negative number;
* ~ is the unary negation operator for all numbers, including reals and ints;
* worth mentioning because it's unusual
*)
val it = ~727 : int

View file

@ -0,0 +1 @@
0b10000001 = 129 = 0h81

View file

@ -0,0 +1,4 @@
$ expr 700 - 1
699
$ expr 0700 - 01
699

View file

@ -0,0 +1,7 @@
dec=727
oct=$(( 01327 ))
bin=$(( 2#1011010111 ))
hex=$(( 0x2d7 ))
# or e.g.
let bin=2#1011010111
let "baseXX = 20#1g7"

View file

@ -0,0 +1,7 @@
dec=727
oct=$(( 01327 ))
bin=$(( 2#1011010111 ))
hex=$(( 0x2d7 ))
# or e.g.
(( bin = 2#1011010111 ))
(( baseXX = 20#1g7 ))

View file

@ -0,0 +1 @@
n = 724

View file

@ -0,0 +1 @@
z = -35

View file

@ -0,0 +1 @@
m = -2/3

View file

@ -0,0 +1 @@
t = 4534934521_

View file

@ -0,0 +1,7 @@
code CrLf=9, IntOut=11;
def A=123, B=$123, C=%11_0011, D=^A;
[IntOut(0, A); CrLf(0); \decimal
IntOut(0, B); CrLf(0); \hex
IntOut(0, C); CrLf(0); \binary
IntOut(0, D); CrLf(0); \ASCII
]