Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
10
Task/Generic-swap/Ada/generic-swap-1.adb
Normal file
10
Task/Generic-swap/Ada/generic-swap-1.adb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
generic
|
||||
type Swap_Type is private; -- Generic parameter
|
||||
procedure Generic_Swap (Left, Right : in out Swap_Type);
|
||||
|
||||
procedure Generic_Swap (Left, Right : in out Swap_Type) is
|
||||
Temp : constant Swap_Type := Left;
|
||||
begin
|
||||
Left := Right;
|
||||
Right := Temp;
|
||||
end Generic_Swap;
|
||||
7
Task/Generic-swap/Ada/generic-swap-2.adb
Normal file
7
Task/Generic-swap/Ada/generic-swap-2.adb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
with Generic_Swap;
|
||||
...
|
||||
type T is ...
|
||||
procedure T_Swap is new Generic_Swap (Swap_Type => T);
|
||||
A, B : T;
|
||||
...
|
||||
T_Swap (A, B);
|
||||
74
Task/Generic-swap/COBOL/generic-swap.cob
Normal file
74
Task/Generic-swap/COBOL/generic-swap.cob
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
PROGRAM-ID. SWAP-DEMO.
|
||||
AUTHOR. Bill Gunshannon.
|
||||
INSTALLATION. Home.
|
||||
DATE-WRITTEN. 16 December 2021.
|
||||
************************************************************
|
||||
** Program Abstract:
|
||||
** A simple program to demonstrate the SWAP subprogram.
|
||||
**
|
||||
************************************************************
|
||||
|
||||
DATA DIVISION.
|
||||
|
||||
WORKING-STORAGE SECTION.
|
||||
|
||||
01 Val1 PIC X(72).
|
||||
01 Val2 PIC X(72).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
|
||||
Main-Program.
|
||||
|
||||
DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
|
||||
ACCEPT Val1.
|
||||
DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
|
||||
ACCEPT Val2.
|
||||
DISPLAY ' ' .
|
||||
DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
|
||||
DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .
|
||||
|
||||
CALL "SWAP" USING BY REFERENCE Val1, BY REFERENCE Val2.
|
||||
|
||||
DISPLAY ' '.
|
||||
DISPLAY 'After SWAP '.
|
||||
DISPLAY ' '.
|
||||
DISPLAY 'First value: ' FUNCTION TRIM(Val1).
|
||||
DISPLAY 'Second value: ' FUNCTION TRIM(Val2).
|
||||
|
||||
STOP RUN.
|
||||
|
||||
END PROGRAM SWAP-DEMO.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. SWAP.
|
||||
AUTHOR. Bill Gunshannon.
|
||||
INSTALLATION. Home.
|
||||
DATE-WRITTEN. 16 December 2021.
|
||||
************************************************************
|
||||
** Program Abstract:
|
||||
** SWAP any Alphanumeric value. Only limit is 72
|
||||
** character size. But that can be adjusted for
|
||||
** whatever use one needs.
|
||||
************************************************************
|
||||
|
||||
DATA DIVISION.
|
||||
|
||||
WORKING-STORAGE SECTION.
|
||||
|
||||
01 TEMP PIC X(72).
|
||||
|
||||
LINKAGE SECTION.
|
||||
|
||||
01 Field1 PIC X(72).
|
||||
01 Field2 PIC X(72).
|
||||
|
||||
PROCEDURE DIVISION
|
||||
USING BY REFERENCE Field1, BY REFERENCE Field2.
|
||||
|
||||
MOVE Field1 to TEMP.
|
||||
MOVE Field2 to Field1.
|
||||
MOVE TEMP to Field2.
|
||||
|
||||
GOBACK.
|
||||
|
||||
END PROGRAM SWAP.
|
||||
1
Task/Generic-swap/Chapel/generic-swap-1.chpl
Normal file
1
Task/Generic-swap/Chapel/generic-swap-1.chpl
Normal file
|
|
@ -0,0 +1 @@
|
|||
a <=> b
|
||||
1
Task/Generic-swap/Chapel/generic-swap-2.chpl
Normal file
1
Task/Generic-swap/Chapel/generic-swap-2.chpl
Normal file
|
|
@ -0,0 +1 @@
|
|||
(a, b) = (b, a)
|
||||
6
Task/Generic-swap/Emacs-Lisp/generic-swap-1.el
Normal file
6
Task/Generic-swap/Emacs-Lisp/generic-swap-1.el
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defun swap (a-sym b-sym)
|
||||
"Swap values of the variables given by A-SYM and B-SYM."
|
||||
(let ((a-val (symbol-value a-sym)))
|
||||
(set a-sym (symbol-value b-sym))
|
||||
(set b-sym a-val)))
|
||||
(swap 'a 'b)
|
||||
2
Task/Generic-swap/Emacs-Lisp/generic-swap-2.el
Normal file
2
Task/Generic-swap/Emacs-Lisp/generic-swap-2.el
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defmacro swap (a b)
|
||||
`(setq ,b (prog1 ,a (setq ,a ,b))))
|
||||
8
Task/Generic-swap/Emacs-Lisp/generic-swap-3.el
Normal file
8
Task/Generic-swap/Emacs-Lisp/generic-swap-3.el
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(require 'cl-lib)
|
||||
(defmacro swap (a b)
|
||||
`(cl-psetf ,a ,b
|
||||
,b ,a))
|
||||
|
||||
(setq lst (list 123 456))
|
||||
(swap (car lst) (cadr lst))
|
||||
;; now lst is '(456 123)
|
||||
9
Task/Generic-swap/Euphoria/generic-swap.eu
Normal file
9
Task/Generic-swap/Euphoria/generic-swap.eu
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
include std/console.e -- for display
|
||||
|
||||
object x = 3.14159
|
||||
object y = "Rosettacode"
|
||||
|
||||
{y,x} = {x,y}
|
||||
|
||||
display("x is now []",{x})
|
||||
display("y is now []",{y})
|
||||
1
Task/Generic-swap/Gleam/generic-swap-1.gleam
Normal file
1
Task/Generic-swap/Gleam/generic-swap-1.gleam
Normal file
|
|
@ -0,0 +1 @@
|
|||
let #(x, y) = #(y, x)
|
||||
3
Task/Generic-swap/Gleam/generic-swap-2.gleam
Normal file
3
Task/Generic-swap/Gleam/generic-swap-2.gleam
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub fn swap(tuple: #(a, b)) -> #(b, a) {
|
||||
#(tuple.1, tuple.0)
|
||||
}
|
||||
1
Task/Generic-swap/PowerShell/generic-swap-1.ps1
Normal file
1
Task/Generic-swap/PowerShell/generic-swap-1.ps1
Normal file
|
|
@ -0,0 +1 @@
|
|||
$b, $a = $a, $b
|
||||
3
Task/Generic-swap/PowerShell/generic-swap-2.ps1
Normal file
3
Task/Generic-swap/PowerShell/generic-swap-2.ps1
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function swap ([ref] $a, [ref] $b) {
|
||||
$a.Value, $b.Value = $b.Value, $a.Value
|
||||
}
|
||||
1
Task/Generic-swap/PowerShell/generic-swap-3.ps1
Normal file
1
Task/Generic-swap/PowerShell/generic-swap-3.ps1
Normal file
|
|
@ -0,0 +1 @@
|
|||
swap ([ref] $a) ([ref] $b)
|
||||
18
Task/Generic-swap/Rebol/generic-swap.rebol
Normal file
18
Task/Generic-swap/Rebol/generic-swap.rebol
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Rebol [
|
||||
Title: "Generic Swap"
|
||||
URL: http://rosettacode.org/wiki/Generic_swap
|
||||
Reference: [http://reboltutorial.com/blog/rebol-words/]
|
||||
]
|
||||
|
||||
swap: func [
|
||||
"Swap contents of variables."
|
||||
a [word!] b [word!] /local x
|
||||
][
|
||||
x: get a
|
||||
set a get b
|
||||
set b x
|
||||
]
|
||||
|
||||
answer: 42 ship: "Heart of Gold"
|
||||
swap 'answer 'ship ; Note quoted variables.
|
||||
print rejoin ["The answer is " answer ", the ship is " ship "."]
|
||||
6
Task/Generic-swap/VBScript/generic-swap-1.vbs
Normal file
6
Task/Generic-swap/VBScript/generic-swap-1.vbs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
sub swap( byref x, byref y )
|
||||
dim temp
|
||||
temp = x
|
||||
x = y
|
||||
y = temp
|
||||
end sub
|
||||
7
Task/Generic-swap/VBScript/generic-swap-2.vbs
Normal file
7
Task/Generic-swap/VBScript/generic-swap-2.vbs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
dim a
|
||||
a = "woof"
|
||||
dim b
|
||||
b = now()
|
||||
swap a,b
|
||||
wscript.echo a
|
||||
wscript.echo b
|
||||
2
Task/Generic-swap/VBScript/generic-swap-3.vbs
Normal file
2
Task/Generic-swap/VBScript/generic-swap-3.vbs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
5/02/2010 2:35:36 PM
|
||||
woof
|
||||
Loading…
Add table
Add a link
Reference in a new issue