2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
29
Task/Inverted-syntax/ALGOL-68/inverted-syntax.alg
Normal file
29
Task/Inverted-syntax/ALGOL-68/inverted-syntax.alg
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Inverted assignment #
|
||||
# Assignment in Algol 68 is via ":=" which is automaically provided for all modes (types) #
|
||||
# However we could define e.g. "=:" as an inverted assignment operator but we would need to #
|
||||
# define a separate operator for each mode, e.g. for integers and strings: #
|
||||
PRIO =: = 1;
|
||||
OP =: = ( INT a, REF INT b )REF INT: b := a;
|
||||
OP =: = ( STRING a, REF STRING b )REF STRING: b := a;
|
||||
OP =: = ( CHAR a, REF STRING b )REF STRING: b := a;
|
||||
INT a, b; STRING s;
|
||||
1 =: a;
|
||||
a + 1 =: b;
|
||||
"?" =: s;
|
||||
print( ( a, b, s, newline ) );
|
||||
|
||||
# There is one standard inverted assignment operator: +=: or PLUSTO which prepends a string #
|
||||
# to another: #
|
||||
"bc" =: s;
|
||||
"b" +=: s;
|
||||
print( ( s, newline ) );
|
||||
|
||||
# Inverted Conditional Expressions #
|
||||
# We could define an operator called WHEN perhaps, that would execute its left operand if #
|
||||
# the right operand was TRUE. However the left operand would need to be a PROC VOID so the #
|
||||
# syntax would not be as convientent as the standard IF-THEN-FI construct. E.g.: #
|
||||
PRIO WHEN = 1;
|
||||
OP WHEN = ( PROC VOID code, BOOL test )VOID: IF test THEN code FI;
|
||||
|
||||
( VOID: print( ( "NO", newline ) ) ) WHEN a = b; # the anonymous PROC VOID is not called #
|
||||
( VOID: print( ( "yes", newline ) ) ) WHEN a /= b # the anonymous PROC VOID is called #
|
||||
14
Task/Inverted-syntax/Common-Lisp/inverted-syntax-3.lisp
Normal file
14
Task/Inverted-syntax/Common-Lisp/inverted-syntax-3.lisp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/rdmd
|
||||
|
||||
import std.algorithm;
|
||||
|
||||
void main() {
|
||||
assert("Hello, World".length == 12);
|
||||
assert("Cleanliness".startsWith("Clean"));
|
||||
|
||||
auto r = [1, 4, 2, 8, 5, 7]
|
||||
.filter!(n => n > 2)
|
||||
.map!(n => n * 2);
|
||||
|
||||
assert(r.equal([8, 16, 10, 14]));
|
||||
}
|
||||
1
Task/Inverted-syntax/Fortran/inverted-syntax.f
Normal file
1
Task/Inverted-syntax/Fortran/inverted-syntax.f
Normal file
|
|
@ -0,0 +1 @@
|
|||
INQUIRE(FILE = FILENAME(1:L), EXIST = MAYBE, ERR = 666, IOSTAT = RESULT)
|
||||
1
Task/Inverted-syntax/PowerShell/inverted-syntax-1.psh
Normal file
1
Task/Inverted-syntax/PowerShell/inverted-syntax-1.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
if ((Get-Date 5/27/2016).DayOfWeek -eq "Friday") {"Thank God it's Friday!"}
|
||||
8
Task/Inverted-syntax/PowerShell/inverted-syntax-2.psh
Normal file
8
Task/Inverted-syntax/PowerShell/inverted-syntax-2.psh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function Action ([scriptblock]$Expression, [Alias("if")][bool]$Test)
|
||||
{
|
||||
if ($Test) {&$Expression}
|
||||
}
|
||||
|
||||
Set-Alias -Name say -Value Action
|
||||
|
||||
say {"Thank God it's Friday!"} -if (Get-Date 5/27/2016).DayOfWeek -eq "Friday"
|
||||
2
Task/Inverted-syntax/Python/inverted-syntax-2.py
Normal file
2
Task/Inverted-syntax/Python/inverted-syntax-2.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
with open("file.txt") as f:
|
||||
something(f)
|
||||
|
|
@ -1,14 +1,10 @@
|
|||
SIGNAL {ON|OFF} someCondition {name}
|
||||
|
||||
/*here is an example of a special case (for SYNTAX). */
|
||||
/*REXX program demonstrates a use of a special case of inverted syntax (via SIGNAL ON).*/
|
||||
signal on syntax
|
||||
a=7
|
||||
zz=444/(7-a)
|
||||
zz=444 / (7-a)
|
||||
return zz
|
||||
|
||||
syntax: say '***error***!'
|
||||
say 'program is attempting to do division by zero.'
|
||||
say 'REXX statement number is:' sigL
|
||||
say 'the Rexx source statement is:'
|
||||
say sourceLine(sigL)
|
||||
exit 13
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
syntax: say '***error*** program is attempting to do division by zero,'
|
||||
say 'the REXX statement number is: ' sigL " and the REXX source is:"
|
||||
say sourceLine(sigL)
|
||||
exit 13
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue