Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,30 +0,0 @@
|
|||
with Ada.Strings.Unbounded, Ada.Text_IO;
|
||||
|
||||
procedure Variadic is
|
||||
|
||||
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
|
||||
use type U_String;
|
||||
|
||||
function "+"(S: String) return U_String
|
||||
renames Ada.Strings.Unbounded.To_Unbounded_String;
|
||||
|
||||
function "-"(U: U_String) return String
|
||||
renames Ada.Strings.Unbounded.To_String;
|
||||
|
||||
type Variadic_Array is array(Positive range <>) of U_String;
|
||||
|
||||
procedure Print_Line(Params: Variadic_Array) is
|
||||
begin
|
||||
for I in Params'Range loop
|
||||
Ada.Text_IO.Put(-Params(I));
|
||||
if I < Params'Last then
|
||||
Ada.Text_IO.Put(" ");
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end Print_Line;
|
||||
|
||||
begin
|
||||
Print_Line((+"Mary", +"had", +"a", +"little", +"lamb.")); -- print five strings
|
||||
Print_Line((1 => +"Rosetta Code is cooool!")); -- print one string
|
||||
end;
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
; a quasi-variadic function
|
||||
;-------------------------------------------
|
||||
variadic: function [args][
|
||||
loop args 'arg [
|
||||
print arg
|
||||
loop args 'argv [
|
||||
print argv
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -17,10 +17,9 @@ variadic ["one" 2 "three"]
|
|||
;-------------------------------------------
|
||||
variable: function [args][
|
||||
print ["args:" args]
|
||||
if? attr? "with" [
|
||||
switch attr? "with" [
|
||||
print ["with:" attr "with"]
|
||||
]
|
||||
else [
|
||||
][
|
||||
print "without attributes"
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
program-id. dsp-str is external.
|
||||
data division.
|
||||
linkage section.
|
||||
1 cnt comp-5 pic 9(4).
|
||||
1 str pic x.
|
||||
procedure division using by value cnt
|
||||
by reference str delimited repeated 1 to 5.
|
||||
end program dsp-str.
|
||||
|
||||
program-id. variadic.
|
||||
procedure division.
|
||||
call "dsp-str" using 4 "The" "quick" "brown" "fox"
|
||||
stop run
|
||||
.
|
||||
end program variadic.
|
||||
|
||||
program-id. dsp-str.
|
||||
data division.
|
||||
working-storage section.
|
||||
1 i comp-5 pic 9(4).
|
||||
1 len comp-5 pic 9(4).
|
||||
1 wk-string pic x(20).
|
||||
linkage section.
|
||||
1 cnt comp-5 pic 9(4).
|
||||
1 str1 pic x(20).
|
||||
1 str2 pic x(20).
|
||||
1 str3 pic x(20).
|
||||
1 str4 pic x(20).
|
||||
1 str5 pic x(20).
|
||||
procedure division using cnt str1 str2 str3 str4 str5.
|
||||
if cnt < 1 or > 5
|
||||
display "Invalid number of parameters"
|
||||
stop run
|
||||
end-if
|
||||
perform varying i from 1 by 1
|
||||
until i > cnt
|
||||
evaluate i
|
||||
when 1
|
||||
unstring str1 delimited low-value
|
||||
into wk-string count in len
|
||||
when 2
|
||||
unstring str2 delimited low-value
|
||||
into wk-string count in len
|
||||
when 3
|
||||
unstring str3 delimited low-value
|
||||
into wk-string count in len
|
||||
when 4
|
||||
unstring str4 delimited low-value
|
||||
into wk-string count in len
|
||||
when 5
|
||||
unstring str5 delimited low-value
|
||||
into wk-string count in len
|
||||
end-evaluate
|
||||
display wk-string (1:len)
|
||||
end-perform
|
||||
exit program
|
||||
.
|
||||
end program dsp-str.
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
Fixpoint Arity (A B: Set) (n: nat): Set := match n with
|
||||
|O => B
|
||||
|S n' => A -> (Arity A B n')
|
||||
end.
|
||||
|
|
@ -1 +0,0 @@
|
|||
Definition nat_twobools (n: nat) := Arity nat (Arity bool nat (2*n)) n.
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
Require Import List.
|
||||
Fixpoint build_list_aux {A: Set} (acc: list A) (n : nat): Arity A (list A) n := match n with
|
||||
|O => acc
|
||||
|S n' => fun (val: A) => build_list_aux (acc ++ (val :: nil)) n'
|
||||
end.
|
||||
|
|
@ -1 +0,0 @@
|
|||
Definition build_list {A: Set} := build_list_aux (@nil A).
|
||||
|
|
@ -1 +0,0 @@
|
|||
Check build_list 5 1 2 5 90 42.
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
Lemma transparent_plus_zero: forall n, n + O = n.
|
||||
intros n; induction n.
|
||||
- reflexivity.
|
||||
- simpl; rewrite IHn; trivial.
|
||||
Defined.
|
||||
|
||||
Lemma transparent_plus_S: forall n m, n + S m = S n + m .
|
||||
intros n; induction n; intros m.
|
||||
- reflexivity.
|
||||
- simpl; f_equal; rewrite IHn; reflexivity.
|
||||
Defined.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
Require Import Vector.
|
||||
|
||||
Definition build_vector_aux {A: Set} (n: nat): forall (size_acc : nat) (acc: t A size_acc), Arity A (t A (size_acc + n)) n.
|
||||
induction n; intros size_acc acc.
|
||||
- rewrite transparent_plus_zero; apply acc. (*Just one argument, return the accumulator*)
|
||||
- intros val. rewrite transparent_plus_S. apply IHn. (*Here we use the induction hypothesis. We just have to build the new accumulator*)
|
||||
apply shiftin; [apply val | apply acc]. (*Shiftin adds a term at the end of a vector*)
|
||||
|
|
@ -1 +0,0 @@
|
|||
Definition build_vector {A: Set} (n: nat) := build_vector_aux n O (@nil A).
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Require Import String.
|
||||
Eval compute in build_vector 4 "Hello" "how" "are" "you".
|
||||
|
|
@ -12,7 +12,7 @@ extension variadicOp
|
|||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
console.printAll("test", "rosetta code", 123, 5.6r)
|
||||
Console.printAll("test", "rosetta code", 123, 5.6r)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
(defun my-print-args (&rest arg-list)
|
||||
(message "there are %d argument(s)" (length arg-list))
|
||||
(dolist (arg arg-list)
|
||||
(message "arg is %S" arg)))
|
||||
|
||||
(my-print-args 1 2 3)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(let ((arg-list '("some thing %d %d %d" 1 2 3)))
|
||||
(apply 'message arg-list))
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
procedure print_args(sequence args)
|
||||
for i = 1 to length(args) do
|
||||
puts(1,args[i])
|
||||
puts(1,' ')
|
||||
end for
|
||||
end procedure
|
||||
|
||||
print_args({"Mary", "had", "a", "little", "lamb"})
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
function print_all {
|
||||
foreach ($x in $args) {
|
||||
Write-Host $x
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
print_all 1 2 'foo'
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
$array = 1,2,'foo'
|
||||
Invoke-Expression "& print_all $array"
|
||||
|
|
@ -1 +0,0 @@
|
|||
print_all @array
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
REBOL [
|
||||
Title: "Variadic Arguments"
|
||||
]
|
||||
|
||||
print-all: func [
|
||||
args [block!] {the arguments to print}
|
||||
] [
|
||||
foreach arg args [print arg]
|
||||
]
|
||||
|
||||
print-all [rebol works this way]
|
||||
|
|
@ -1,5 +1,17 @@
|
|||
print_all: procedure /* [↓] is the # of args passed.*/
|
||||
do j=1 for arg()
|
||||
say arg(j)
|
||||
end /*j*/
|
||||
-- 11 Sep 2025
|
||||
include Setting
|
||||
|
||||
say 'VARIADIC FUNCTION'
|
||||
say version
|
||||
say
|
||||
call Task 'Sin(x)',,0,Abs(-12),SqRt(12)/1,,'Number 7',,2**10
|
||||
exit
|
||||
|
||||
Task:
|
||||
procedure
|
||||
do a = 1 to Arg()
|
||||
say 'Arg('a')' '=' Arg(a)
|
||||
end
|
||||
return
|
||||
|
||||
include Math
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
print_all: procedure /* [↓] is the # of args passed.*/
|
||||
do j=1 for arg()
|
||||
say '[argument' j"]: " arg(j)
|
||||
end /*j*/
|
||||
/* REXX */
|
||||
list=''
|
||||
Do i=1 To 6
|
||||
list=list||'"arg"'i','
|
||||
End
|
||||
list=list||'"end"'
|
||||
Interpret 'call show' list
|
||||
Exit
|
||||
show: procedure
|
||||
do j=1 for arg()
|
||||
say arg(j)
|
||||
end /*j*/
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
call print_all .1,5,2,4,-3, 4.7e1, 013.000 ,, 8**2 -3, sign(-66), abs(-71.00), 8 || 9, 'seven numbers are prime, 8th is null'
|
||||
|
||||
call print_all "One ringy-dingy,",
|
||||
"two ringy-dingy,",
|
||||
"three ringy-dingy...",
|
||||
"Hello? This is Ma Bell.",
|
||||
"Have you been misusing your instrument?",
|
||||
"(Lily Tomlin routine)"
|
||||
|
||||
/* [↑] example showing multi-line arguments.*/
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/* REXX */
|
||||
list=''
|
||||
Do i=1 To 6
|
||||
list=list||'"arg"'i','
|
||||
End
|
||||
list=list||'"end"'
|
||||
Interpret 'call show' list
|
||||
Exit
|
||||
show: procedure
|
||||
do j=1 for arg()
|
||||
say arg(j)
|
||||
end /*j*/
|
||||
return
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
proc print_all {args} {puts [join $args \n]}
|
||||
|
||||
print_all 4 3 5 6 4 3
|
||||
print_all 4 3 5
|
||||
print_all Rosetta Code Is Awesome!
|
||||
|
||||
set things {Rosetta Code Is Awesome!}
|
||||
|
||||
print_all $things ;# ==> incorrect: passes a single argument (a list) to print_all
|
||||
print_all {*}$things ;# ==> correct: passes each element of the list to the procedure
|
||||
|
|
@ -1 +0,0 @@
|
|||
eval [list print_all] [lrange $things 0 end]
|
||||
Loading…
Add table
Add a link
Reference in a new issue