Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
1
Task/Generic-swap/8th/generic-swap-1.8th
Normal file
1
Task/Generic-swap/8th/generic-swap-1.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
swap
|
||||
1
Task/Generic-swap/8th/generic-swap-2.8th
Normal file
1
Task/Generic-swap/8th/generic-swap-2.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
dup @ -rot !
|
||||
10
Task/Generic-swap/Arc/generic-swap.arc
Normal file
10
Task/Generic-swap/Arc/generic-swap.arc
Normal 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))
|
||||
1
Task/Generic-swap/Axe/generic-swap.axe
Normal file
1
Task/Generic-swap/Axe/generic-swap.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
Exch(°A,°B,2)
|
||||
20
Task/Generic-swap/EchoLisp/generic-swap.echolisp
Normal file
20
Task/Generic-swap/EchoLisp/generic-swap.echolisp
Normal 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)
|
||||
26
Task/Generic-swap/FreeBASIC/generic-swap.freebasic
Normal file
26
Task/Generic-swap/FreeBASIC/generic-swap.freebasic
Normal 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
|
||||
22
Task/Generic-swap/FutureBasic/generic-swap.futurebasic
Normal file
22
Task/Generic-swap/FutureBasic/generic-swap.futurebasic
Normal 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
|
||||
15
Task/Generic-swap/Gri/generic-swap-1.gri
Normal file
15
Task/Generic-swap/Gri/generic-swap-1.gri
Normal 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"
|
||||
15
Task/Generic-swap/Gri/generic-swap-2.gri
Normal file
15
Task/Generic-swap/Gri/generic-swap-2.gri
Normal 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"
|
||||
8
Task/Generic-swap/Lasso/generic-swap-1.lasso
Normal file
8
Task/Generic-swap/Lasso/generic-swap-1.lasso
Normal 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)
|
||||
5
Task/Generic-swap/Lasso/generic-swap-2.lasso
Normal file
5
Task/Generic-swap/Lasso/generic-swap-2.lasso
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
local(a) = 'hair'
|
||||
local(b) = 'moose'
|
||||
local(a,b) = (: #b, #a)
|
||||
stdoutnl(#a)
|
||||
stdoutnl(#b)
|
||||
3
Task/Generic-swap/Lingo/generic-swap-1.lingo
Normal file
3
Task/Generic-swap/Lingo/generic-swap-1.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
on swap (x, y)
|
||||
return "tmp="&x&RETURN&x&"="&y&RETURN&y&"=tmp"
|
||||
end
|
||||
5
Task/Generic-swap/Lingo/generic-swap-2.lingo
Normal file
5
Task/Generic-swap/Lingo/generic-swap-2.lingo
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
x = 1
|
||||
y = 2
|
||||
do(swap("x","y"))
|
||||
put x, y
|
||||
-- 2 1
|
||||
10
Task/Generic-swap/LiveCode/generic-swap.livecode
Normal file
10
Task/Generic-swap/LiveCode/generic-swap.livecode
Normal 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
|
||||
1
Task/Generic-swap/Nim/generic-swap.nim
Normal file
1
Task/Generic-swap/Nim/generic-swap.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
swap(a, b)
|
||||
1
Task/Generic-swap/Oforth/generic-swap.oforth
Normal file
1
Task/Generic-swap/Oforth/generic-swap.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
swap
|
||||
1
Task/Generic-swap/Phix/generic-swap.phix
Normal file
1
Task/Generic-swap/Phix/generic-swap.phix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{a,b} = {b,a}
|
||||
7
Task/Generic-swap/Ring/generic-swap.ring
Normal file
7
Task/Generic-swap/Ring/generic-swap.ring
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
a = 1
|
||||
b = 2
|
||||
temp = a
|
||||
a = b
|
||||
b = temp
|
||||
see "a = " + a + nl
|
||||
see "b = " + b + nl
|
||||
5
Task/Generic-swap/Sidef/generic-swap-1.sidef
Normal file
5
Task/Generic-swap/Sidef/generic-swap-1.sidef
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
func swap(Ref a, Ref b) {
|
||||
var tmp = *a;
|
||||
*a = *b;
|
||||
*b = tmp;
|
||||
}
|
||||
3
Task/Generic-swap/Sidef/generic-swap-2.sidef
Normal file
3
Task/Generic-swap/Sidef/generic-swap-2.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func swap(Ref a, Ref b) {
|
||||
(*a, *b) = (*b, *a);
|
||||
}
|
||||
3
Task/Generic-swap/Sidef/generic-swap-3.sidef
Normal file
3
Task/Generic-swap/Sidef/generic-swap-3.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func swap(Ref a, Ref b) {
|
||||
[*a, *b] » (b, a);
|
||||
}
|
||||
2
Task/Generic-swap/Sidef/generic-swap-4.sidef
Normal file
2
Task/Generic-swap/Sidef/generic-swap-4.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var (x, y) = (1, 2);
|
||||
swap(\x, \y);
|
||||
3
Task/Generic-swap/Swift/generic-swap.swift
Normal file
3
Task/Generic-swap/Swift/generic-swap.swift
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func swap<T>(inout a: T, inout b: T) {
|
||||
(a, b) = (b, a)
|
||||
}
|
||||
15
Task/Generic-swap/Visual-FoxPro/generic-swap.visual
Normal file
15
Task/Generic-swap/Visual-FoxPro/generic-swap.visual
Normal 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
|
||||
1
Task/Generic-swap/Wart/generic-swap-1.wart
Normal file
1
Task/Generic-swap/Wart/generic-swap-1.wart
Normal file
|
|
@ -0,0 +1 @@
|
|||
(swap! x y)
|
||||
2
Task/Generic-swap/Wart/generic-swap-2.wart
Normal file
2
Task/Generic-swap/Wart/generic-swap-2.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let (x y) (list y x)
|
||||
...
|
||||
1
Task/Generic-swap/jq/generic-swap-1.jq
Normal file
1
Task/Generic-swap/jq/generic-swap-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -n '1 as $a | 2 as $b | $a as $tmp | $b as $a | $tmp as $b | [$a,$b]'
|
||||
1
Task/Generic-swap/jq/generic-swap-2.jq
Normal file
1
Task/Generic-swap/jq/generic-swap-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
reverse
|
||||
1
Task/Generic-swap/jq/generic-swap-3.jq
Normal file
1
Task/Generic-swap/jq/generic-swap-3.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def swap(i;j): .[i] as $t | .[i] = .[j] | .[j] = $t;
|
||||
Loading…
Add table
Add a link
Reference in a new issue