Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
1
Task/Generic-swap/Chapel/generic-swap.chapel
Normal file
1
Task/Generic-swap/Chapel/generic-swap.chapel
Normal file
|
|
@ -0,0 +1 @@
|
|||
(a, b) = (b, a)
|
||||
1
Task/Generic-swap/Deja-Vu/generic-swap-1.djv
Normal file
1
Task/Generic-swap/Deja-Vu/generic-swap-1.djv
Normal file
|
|
@ -0,0 +1 @@
|
|||
swap
|
||||
1
Task/Generic-swap/Deja-Vu/generic-swap-2.djv
Normal file
1
Task/Generic-swap/Deja-Vu/generic-swap-2.djv
Normal file
|
|
@ -0,0 +1 @@
|
|||
set :a set :b @a @b
|
||||
8
Task/Generic-swap/Delphi/generic-swap-1.delphi
Normal file
8
Task/Generic-swap/Delphi/generic-swap-1.delphi
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
procedure Swap_T(var a, b: T);
|
||||
var
|
||||
temp: T;
|
||||
begin
|
||||
temp := a;
|
||||
a := b;
|
||||
b := temp;
|
||||
end;
|
||||
26
Task/Generic-swap/Delphi/generic-swap-2.delphi
Normal file
26
Task/Generic-swap/Delphi/generic-swap-2.delphi
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
program GenericSwap;
|
||||
|
||||
type
|
||||
TSwap = class
|
||||
class procedure Swap<T>(var left, right: T);
|
||||
end;
|
||||
|
||||
class procedure TSwap.Swap<T>(var left, right: T);
|
||||
var
|
||||
temp : T;
|
||||
begin
|
||||
temp := left;
|
||||
left := right;
|
||||
right := temp;
|
||||
end;
|
||||
|
||||
var
|
||||
a, b : integer;
|
||||
|
||||
begin
|
||||
a := 5;
|
||||
b := 3;
|
||||
writeln('Before swap: a=', a, ' b=', b);
|
||||
TSwap.Swap<integer>(a, b);
|
||||
writeln('After swap: a=', a, ' b=', b);
|
||||
end.
|
||||
21
Task/Generic-swap/NetRexx/generic-swap.netrexx
Normal file
21
Task/Generic-swap/NetRexx/generic-swap.netrexx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
-- Simple values with no spaces can be swapped without the use of a parse template
|
||||
lval = 27
|
||||
rval = 5
|
||||
say 'Before - <lval>'lval'</lval> <rval>'rval'</rval>'
|
||||
parse (lval rval) rval lval
|
||||
say 'After - <lval>'lval'</lval> <rval>'rval'</rval>'
|
||||
say
|
||||
|
||||
-- More complex data needs to use some form of parsing template
|
||||
lval = 'This value started on the left'
|
||||
rval = 'This value started on the right'
|
||||
dlm = 12x80facebead01 -- some delimiting value that is unlikely to occur in the LVAL to be swapped
|
||||
say 'Before - <lval>'lval'</lval> <rval>'rval'</rval>'
|
||||
parse (lval || dlm || rval) rval (dlm) lval
|
||||
say 'After - <lval>'lval'</lval> <rval>'rval'</rval>'
|
||||
say
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue