Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1 @@
swap

View file

@ -0,0 +1 @@
dup @ -rot !

View file

@ -0,0 +1,10 @@
(mac myswap (a b)
(w/uniq gx
`(let ,gx a
(= a b)
(= b ,gx))))
(with (a 1
b 2)
(myswap a b)
(prn "a:" a #\Newline "b:" b))

View file

@ -0,0 +1 @@
Exch(°A,°B,2)

View file

@ -0,0 +1,20 @@
;; 1)
;; a macro will do it, as shown in Racket (same syntax)
(define-syntax-rule (swap a b)
(let ([tmp a])
(set! a b)
(set! b tmp)))
(define A 666)
(define B "simon")
(swap A B)
A → "simon"
B → 666
;; 2)
;; The list-swap! function allows to swap two items inside a list, regardless of their types
;; This physically alters the list
(define L ' ( 1 2 3 4 🎩 ))
(list-swap! L 1 ' 🎩 )
→ (🎩 2 3 4 1)

View file

@ -0,0 +1,26 @@
' FB 1.05.0
#Macro Declare_Swap(T)
Sub Swap_##T(ByRef t1 As T, ByRef t2 As T)
Dim temp As T = t2
t2 = t1
t1 = temp
End Sub
#EndMacro
Dim As Integer i, j
i = 1 : j = 2
Declare_Swap(Integer) ' expands the macro
Swap_Integer(i, j)
Print i, j
Dim As String s, t
s = "Hello" : t = "World"
Declare_Swap(String)
Swap_String(s, t)
Print s, t
Print
Print "Press any key to exit"
Sleep

View file

@ -0,0 +1,22 @@
include "ConsoleWindow"
dim as long i, j
dim as double x, y
dim as Str15 a, b
i = 1059 : j = 62
print i, j
swap i, j
print i, j
print
x = 1.23 : y = 4.56
print x, y
swap x, y
print x, y
print
a = "Hello" : b = "World!"
print a, b
swap a, b
print a, b

View file

@ -0,0 +1,15 @@
`Swap Vars &.a. &.b.'
{
new .temp.
.temp. = \.word2.
\.word2. = \.word3.
\.word3. = .temp.
delete .temp.
}
.foo. = 123
.bar. = 456
Swap Vars &.foo. &.bar.
show .foo. " " .bar.
# prints "456 123"

View file

@ -0,0 +1,15 @@
`Swap Syns &\a &\b'
{
new \temp
\temp = "\.word2."
\.word2. = "\.word3."
\.word3. = "\temp"
delete \temp
}
\quux = "one"
\xyzzy = "two"
Swap Syns &\quux &\xyzzy
show "\quux \xyzzy"
# prints "two one"

View file

@ -0,0 +1,8 @@
define swap(a, b) => (: #b, #a)
local(a) = 'foo'
local(b) = 42
local(a,b) = swap(#a, #b)
stdoutnl(#a)
stdoutnl(#b)

View file

@ -0,0 +1,5 @@
local(a) = 'hair'
local(b) = 'moose'
local(a,b) = (: #b, #a)
stdoutnl(#a)
stdoutnl(#b)

View file

@ -0,0 +1,3 @@
on swap (x, y)
return "tmp="&x&RETURN&x&"="&y&RETURN&y&"=tmp"
end

View file

@ -0,0 +1,5 @@
x = 1
y = 2
do(swap("x","y"))
put x, y
-- 2 1

View file

@ -0,0 +1,10 @@
put "first" into a1
put "last" into b2
swap a1,b2
put a1 && b2
command swap @p1, @p2
put p2 into p3
put p1 into p2
put p3 into p1
end swap

View file

@ -0,0 +1 @@
swap(a, b)

View file

@ -0,0 +1 @@
swap

View file

@ -0,0 +1 @@
{a,b} = {b,a}

View file

@ -0,0 +1,7 @@
a = 1
b = 2
temp = a
a = b
b = temp
see "a = " + a + nl
see "b = " + b + nl

View file

@ -0,0 +1,5 @@
func swap(Ref a, Ref b) {
var tmp = *a;
*a = *b;
*b = tmp;
}

View file

@ -0,0 +1,3 @@
func swap(Ref a, Ref b) {
(*a, *b) = (*b, *a);
}

View file

@ -0,0 +1,3 @@
func swap(Ref a, Ref b) {
[*a, *b] » (b, a);
}

View file

@ -0,0 +1,2 @@
var (x, y) = (1, 2);
swap(\x, \y);

View file

@ -0,0 +1,3 @@
func swap<T>(inout a: T, inout b: T) {
(a, b) = (b, a)
}

View file

@ -0,0 +1,15 @@
*!* Swap two variables
LOCAL a, b
a = 1
b = "Hallo"
? a, b
*!* Pass a and b by reference
Swap(@a, @b)
? a, b
PROCEDURE Swap(v1, v2)
LOCAL dum
dum = v1
v1 = v2
v2 = dum
ENDPROC

View file

@ -0,0 +1 @@
(swap! x y)

View file

@ -0,0 +1,2 @@
let (x y) (list y x)
...

View file

@ -0,0 +1 @@
jq -n '1 as $a | 2 as $b | $a as $tmp | $b as $a | $tmp as $b | [$a,$b]'

View file

@ -0,0 +1 @@
reverse

View file

@ -0,0 +1 @@
def swap(i;j): .[i] as $t | .[i] = .[j] | .[j] = $t;