Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
20
Task/Extend-your-language/Ada/extend-your-language.adb
Normal file
20
Task/Extend-your-language/Ada/extend-your-language.adb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Test_If_2 is
|
||||
|
||||
type Two_Bool is range 0 .. 3;
|
||||
|
||||
function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
|
||||
(Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
|
||||
|
||||
begin
|
||||
for N in 10 .. 20 loop
|
||||
Put(Integer'Image(N) & " is ");
|
||||
case If_2(N mod 2 = 0, N mod 3 = 0) is
|
||||
when 2#11# => Put_Line("divisible by both two and three.");
|
||||
when 2#10# => Put_Line("divisible by two, but not by three.");
|
||||
when 2#01# => Put_Line("divisible by three, but not by two.");
|
||||
when 2#00# => Put_Line("neither divisible by two, nor by three.");
|
||||
end case;
|
||||
end loop;
|
||||
end Test_If_2;
|
||||
10
Task/Extend-your-language/COBOL/extend-your-language.cob
Normal file
10
Task/Extend-your-language/COBOL/extend-your-language.cob
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
EVALUATE EXPRESSION-1 ALSO EXPRESSION-2
|
||||
WHEN TRUE ALSO TRUE
|
||||
DISPLAY 'Both are true.'
|
||||
WHEN TRUE ALSO FALSE
|
||||
DISPLAY 'Expression 1 is true.'
|
||||
WHEN FALSE ALSO TRUE
|
||||
DISPLAY 'Expression 2 is true.'
|
||||
WHEN OTHER
|
||||
DISPLAY 'Neither is true.'
|
||||
END-EVALUATE
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
(defmacro if2 (cond1 cond2 both first second &rest neither)
|
||||
(let ((res1 (gensym))
|
||||
(res2 (gensym)))
|
||||
`(let ((,res1 ,cond1)
|
||||
(,res2 ,cond2))
|
||||
(cond ((and ,res1 ,res2) ,both)
|
||||
(,res1 ,first)
|
||||
(,res2 ,second)
|
||||
(t ,@neither)))))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
switch[and] x nxor, y nxor {
|
||||
case true: ... # both true
|
||||
case true, false: ... # first true, second false
|
||||
case false, true: ... # first false, second true
|
||||
default: ... # both false
|
||||
case true: ... # both truthy
|
||||
case true, false: ... # first truthy, second not truthy
|
||||
case false, true: ... # first not truthy, second truthy
|
||||
default: ... # both not truthy
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
function When-Condition
|
||||
{
|
||||
[CmdletBinding()]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true, Position=0)]
|
||||
[bool]
|
||||
$Test1,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=1)]
|
||||
[bool]
|
||||
$Test2,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=2)]
|
||||
[scriptblock]
|
||||
$Both,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=3)]
|
||||
[scriptblock]
|
||||
$First,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=4)]
|
||||
[scriptblock]
|
||||
$Second,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=5)]
|
||||
[scriptblock]
|
||||
$Neither
|
||||
)
|
||||
|
||||
if ($Test1 -and $Test2)
|
||||
{
|
||||
return (&$Both)
|
||||
}
|
||||
elseif ($Test1 -and -not $Test2)
|
||||
{
|
||||
return (&$First)
|
||||
}
|
||||
elseif (-not $Test1 -and $Test2)
|
||||
{
|
||||
return (&$Second)
|
||||
}
|
||||
else
|
||||
{
|
||||
return (&$Neither)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
When-Condition -Test1 (Test-Path .\temp.txt) -Test2 (Test-Path .\tmp.txt) `
|
||||
-Both { "both true"
|
||||
} -First { "first true"
|
||||
} -Second { "second true"
|
||||
} -Neither { "neither true"
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Set-Alias -Name if2 -Value When-Condition
|
||||
|
||||
if2 $true $false {
|
||||
"both true"
|
||||
} { "first true"
|
||||
} { "second true"
|
||||
} { "neither true"
|
||||
}
|
||||
36
Task/Extend-your-language/Red/extend-your-language.red
Normal file
36
Task/Extend-your-language/Red/extend-your-language.red
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Red [ "Extend your language - Hinjolicious"]
|
||||
|
||||
; This function will print a string as a heading and print any codes
|
||||
; to the screen before executing it.
|
||||
demo: function [s b] [print ["^/==" s "==^/"] print [mold/only b "^/^/Output:"] do b]
|
||||
|
||||
demo "Creating a custom control structure if-both" [
|
||||
if-both: function [cond1 cond2 both-body first-body second-body none-body] [
|
||||
c1: do cond1
|
||||
c2: do cond2
|
||||
case [
|
||||
all [c1 c2] [do both-body]
|
||||
c1 [do first-body]
|
||||
c2 [do second-body]
|
||||
true [do none-body]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
demo "Testing it" [
|
||||
random/seed now
|
||||
|
||||
test: does [
|
||||
if-both [(random 100) > 50] [(random 100) < 50] [
|
||||
print "both"
|
||||
][
|
||||
print "first"
|
||||
][
|
||||
print "second"
|
||||
][
|
||||
print "none"
|
||||
]
|
||||
]
|
||||
|
||||
loop 10 [test]
|
||||
]
|
||||
1
Task/Extend-your-language/Rocq/extend-your-language.rocq
Normal file
1
Task/Extend-your-language/Rocq/extend-your-language.rocq
Normal file
|
|
@ -0,0 +1 @@
|
|||
Notation "A /\ B" := (and A B)
|
||||
Loading…
Add table
Add a link
Reference in a new issue