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,17 @@
macro cond(a,c) {c then a}
macro store(b,a) {a=b}
sys a,c=10
if c>4 then a=4
'INVERTED SYNTAX FORMS:
cond a=40, if c>4
store 4,a
'COMBINED:
cond store(5,a), if c>4

View file

@ -0,0 +1,4 @@
fi(f, condition)=if(condition,f());
if(raining, print("Umbrella needed"))
fi(->print("Umbrella needed"), raining)

View file

@ -0,0 +1,4 @@
if $guess == 6 { say "Wow! Lucky Guess!" } # Traditional
say 'Wow! Lucky Guess!' if $guess == 6; # Inverted
unless $guess == 6 { say "Huh! You Guessed Rong!" } # Traditional
say 'Huh! You Guessed Rong!' unless $guess == 6; # Inverted

View file

@ -0,0 +1,8 @@
while $i { --$i }
--$i while $i;
until $x > 10 { $x++ }
$x++ until $x > 10;
for 1..10 { .say if $_ %% 2 }
.say if $_ %% 2 for 1..10; # list comprehension

View file

@ -0,0 +1 @@
42 R= $_; say $_; # prints 42

View file

@ -0,0 +1,2 @@
my @a = 1,2,3;
(1,2,3) R= my @a;

View file

@ -0,0 +1,2 @@
my @a <== 1,2,3;
1,2,3 ==> my @a;

View file

@ -0,0 +1,7 @@
repeat {
$_ = prompt "Gimme a number: ";
} until /^\d+$/;
repeat until /^\d+$/ {
$_ = prompt "Gimme a number: ";
}

View file

@ -0,0 +1,3 @@
repeat until my $answer ~~ 42 {
$answer = prompt "Gimme an answer: ";
}

View file

@ -0,0 +1,4 @@
my $answer;
repeat {
$answer = prompt "Gimme an answer: ";
} until $answer ~~ 42;

View file

@ -0,0 +1,27 @@
(define set-needumbrella
Raining -> (set needumbrella true) where (= true Raining)
Raining -> (set needumbrella false) where (= false Raining))
(define set-needumbrella
Raining -> (if (= true Raining)
(set needumbrella true)
(set needumbrella false)))
Alternatives:
(define set-needumbrella
Raining -> (set needumbrella true) where Raining
Raining -> (set needumbrella false))
(define set-needumbrella
Raining -> (if Raining
(set needumbrella true)
(set needumbrella false)))
(define set-needumbrella
true -> (set needumbrella true)
false -> (set needumbrella false))
(define set-needumbrella
A -> (set needumbrella A))