A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,4 @@
|
|||
( scratchpad ) : 2ifte ( ..a ?0 ?1 quot0: ( ..a -- ..b ) quot1: ( ..a -- ..b ) quot2: ( ..a -- ..b ) quot3: ( ..a -- ..b ) -- ..b )
|
||||
[ [ if ] curry curry ] 2bi@ if ; inline
|
||||
( scratchpad ) 3 [ 0 > ] [ even? ] bi [ 0 ] [ 1 ] [ 2 ] [ 3 ] 2ifte .
|
||||
2
|
||||
20
Task/Extend-your-language/Icon/extend-your-language.icon
Normal file
20
Task/Extend-your-language/Icon/extend-your-language.icon
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
procedure main(A)
|
||||
if2 { (A[1] = A[2]), (A[3] = A[4]), # Use PDCO with all three else clauses
|
||||
write("1: both true"),
|
||||
write("1: only first true"),
|
||||
write("1: only second true"),
|
||||
write("1: neither true")
|
||||
}
|
||||
if2 { (A[1] = A[2]), (A[3] = A[4]), # Use same PDCO with only one else clause
|
||||
write("2: both true"),
|
||||
write("2: only first true"),
|
||||
}
|
||||
end
|
||||
|
||||
procedure if2(A) # The double-conditional PDCO
|
||||
suspend if @A[1] then
|
||||
if @A[2] then |@A[3] # Run-err if missing 'then' clause
|
||||
else @\A[4] # (all else clauses are optional)
|
||||
else if @A[2] then |@\A[5]
|
||||
else |@\A[6]
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
To if2 (c1 - condition) and-or (c2 - condition) begin -- end: (- switch (({c1})*2 + ({c2})) { 3: do -).
|
||||
To else1 -- in if2: (- } until (1); 2: do { -).
|
||||
To else2 -- in if2: (- } until (1); 1: do { -).
|
||||
To else0 -- in if2: (- } until (1); 0: -).
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
Home is a room.
|
||||
|
||||
When play begins:
|
||||
if2 (the player is in Home) and-or (the player is a person) begin;
|
||||
say "both";
|
||||
else1;
|
||||
say "only 1";
|
||||
else2;
|
||||
say "only 2";
|
||||
else0;
|
||||
say "neither";
|
||||
end if2.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
To say if2 (c1 - condition) and-or (c2 - condition) -- beginning if2:
|
||||
(- switch (({c1})*2 + ({c2})) { 3: -).
|
||||
To say else1 -- continuing if2: (- 2: -).
|
||||
To say else2 -- continuing if2: (- 1: -).
|
||||
To say else0 -- continuing if2: (- 0: -).
|
||||
To say end if2 -- ending if2: (- } -).
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Home is a room.
|
||||
|
||||
When play begins:
|
||||
say "[if2 the player is not in Home and-or the player is not a person]both[else1]only 1[else2]only 2[else0]neither[end if2]".
|
||||
4
Task/Extend-your-language/J/extend-your-language-1.j
Normal file
4
Task/Extend-your-language/J/extend-your-language-1.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
if2=: 2 :0
|
||||
'`b1 b2'=. n
|
||||
m@.(b1 + 2 * b2) f.
|
||||
)
|
||||
14
Task/Extend-your-language/J/extend-your-language-2.j
Normal file
14
Task/Extend-your-language/J/extend-your-language-2.j
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
f0=: [: smoutput 'neither option: ' , ":
|
||||
f1=: [: smoutput 'first option: ' , ":
|
||||
f2=: [: smoutput 'second option: ' , ":
|
||||
f3=: [: smoutput 'both options: ' , ":
|
||||
|
||||
isprime=: 1&p:
|
||||
iseven=: 0 = 2&|
|
||||
|
||||
f0`f1`f2`f3 if2 (isprime`iseven)"0 i.5
|
||||
second option: 0
|
||||
neither option: 1
|
||||
both options: 2
|
||||
first option: 3
|
||||
second option: 4
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if2[c1_,c2_]:=Which[
|
||||
c1&&c2, bothConditionsAreTrue[],
|
||||
c1, firstConditionIsTrue[],
|
||||
c2, secondConditionIsTrue[],
|
||||
True,noConditionIsTrue]
|
||||
Loading…
Add table
Add a link
Reference in a new issue