Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,15 @@
|
|||
begin
|
||||
|
||||
logical procedure a( logical value v ) ; begin write( "a: ", v ); v end ;
|
||||
logical procedure b( logical value v ) ; begin write( "b: ", v ); v end ;
|
||||
|
||||
write( "and: ", a( true ) and b( true ) );
|
||||
write( "---" );
|
||||
write( "or: ", a( true ) or b( true ) );
|
||||
write( "---" );
|
||||
write( "and: ", a( false ) and b( true ) );
|
||||
write( "---" );
|
||||
write( "or: ", a( false ) or b( true ) );
|
||||
write( "---" );
|
||||
|
||||
end.
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
%=== Batch Files have no booleans. ===%
|
||||
%=== I will instead use 1 as true and 0 as false. ===%
|
||||
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
echo AND
|
||||
for /l %%i in (0,1,1) do (
|
||||
for /l %%j in (0,1,1) do (
|
||||
echo.a^(%%i^) AND b^(%%j^)
|
||||
call :a %%i
|
||||
set res=!bool_a!
|
||||
if not !res!==0 (
|
||||
call :b %%j
|
||||
set res=!bool_b!
|
||||
)
|
||||
echo.=^> !res!
|
||||
)
|
||||
)
|
||||
|
||||
echo ---------------------------------
|
||||
echo OR
|
||||
for /l %%i in (0,1,1) do (
|
||||
for /l %%j in (0,1,1) do (
|
||||
echo a^(%%i^) OR b^(%%j^)
|
||||
call :a %%i
|
||||
set res=!bool_a!
|
||||
if !res!==0 (
|
||||
call :b %%j
|
||||
set res=!bool_b!
|
||||
)
|
||||
echo.=^> !res!
|
||||
)
|
||||
)
|
||||
pause>nul
|
||||
exit /b 0
|
||||
|
||||
|
||||
::----------------------------------------
|
||||
:a
|
||||
echo. calls func a
|
||||
set bool_a=%1
|
||||
goto :EOF
|
||||
|
||||
:b
|
||||
echo. calls func b
|
||||
set bool_b=%1
|
||||
goto :EOF
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
defmodule Short_circuit do
|
||||
defp a(bool) do
|
||||
IO.puts "a( #{bool} ) called"
|
||||
bool
|
||||
end
|
||||
|
||||
defp b(bool) do
|
||||
IO.puts "b( #{bool} ) called"
|
||||
bool
|
||||
end
|
||||
|
||||
def task do
|
||||
Enum.each([true, false], fn i ->
|
||||
Enum.each([true, false], fn j ->
|
||||
IO.puts "a( #{i} ) and b( #{j} ) is #{a(i) and b(j)}.\n"
|
||||
IO.puts "a( #{i} ) or b( #{j} ) is #{a(i) or b(j)}.\n"
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
Short_circuit.task
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
function a(bool) {
|
||||
console.log('a -->', bool);
|
||||
|
||||
return bool;
|
||||
}
|
||||
|
||||
function b(bool) {
|
||||
console.log('b -->', bool);
|
||||
|
||||
return bool;
|
||||
}
|
||||
|
||||
var x = a(false) && b(true),
|
||||
y = a(true) || b(false);
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
a --> false
|
||||
a --> true
|
||||
|
|
@ -14,7 +14,7 @@ print "---------------------------------"
|
|||
print "OR"
|
||||
for i = 0 to 1
|
||||
for j = 0 to 1
|
||||
print "a("; i; ") AND b("; j; ")"
|
||||
print "a("; i; ") OR b("; j; ")"
|
||||
res =a( i) 'call always
|
||||
if res = 0 then 'short circuit if <>0
|
||||
res = b( j)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
Parse Version v
|
||||
Say 'Version='v
|
||||
|
||||
If a() | b() Then Say 'a and b are true'
|
||||
If \a() | b() Then Say 'Surprise'
|
||||
Else Say 'ok'
|
||||
|
||||
If a(), b() Then Say 'a is true'
|
||||
If \a(), b() Then Say 'Surprise'
|
||||
Else Say 'ok: \\a() is false'
|
||||
|
||||
Select
|
||||
When \a(), b() Then Say 'Surprise'
|
||||
Otherwise Say 'ok: \\a() is false (Select)'
|
||||
End
|
||||
Return
|
||||
|
||||
method a private static binary returns boolean
|
||||
state = Boolean.TRUE.booleanValue()
|
||||
Say '--a returns' state
|
||||
Return state
|
||||
|
||||
method b private static binary returns boolean
|
||||
state = Boolean.TRUE.booleanValue()
|
||||
Say '--b returns' state
|
||||
Return state
|
||||
Loading…
Add table
Add a link
Reference in a new issue