langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
1
Task/Call-a-function/OCaml/call-a-function-1.ocaml
Normal file
1
Task/Call-a-function/OCaml/call-a-function-1.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
f ()
|
||||
1
Task/Call-a-function/OCaml/call-a-function-2.ocaml
Normal file
1
Task/Call-a-function/OCaml/call-a-function-2.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
f 1 2 3
|
||||
1
Task/Call-a-function/OCaml/call-a-function-3.ocaml
Normal file
1
Task/Call-a-function/OCaml/call-a-function-3.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
val f : ?a:int -> int -> unit
|
||||
2
Task/Call-a-function/OCaml/call-a-function-4.ocaml
Normal file
2
Task/Call-a-function/OCaml/call-a-function-4.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
f 10
|
||||
f ~a:6 10
|
||||
2
Task/Call-a-function/OCaml/call-a-function-5.ocaml
Normal file
2
Task/Call-a-function/OCaml/call-a-function-5.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
g ()
|
||||
g ~b:1.0 ()
|
||||
1
Task/Call-a-function/OCaml/call-a-function-6.ocaml
Normal file
1
Task/Call-a-function/OCaml/call-a-function-6.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
f ~arg:3
|
||||
2
Task/Call-a-function/OCaml/call-a-function-7.ocaml
Normal file
2
Task/Call-a-function/OCaml/call-a-function-7.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let arg = 3 in
|
||||
f ~arg
|
||||
1
Task/Call-a-function/OCaml/call-a-function-8.ocaml
Normal file
1
Task/Call-a-function/OCaml/call-a-function-8.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
(* TODO *)
|
||||
4
Task/Call-a-function/OCaml/call-a-function-9.ocaml
Normal file
4
Task/Call-a-function/OCaml/call-a-function-9.ocaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let ret = f ()
|
||||
let a, b, c = f () (* if there are several returned values given as a tuple *)
|
||||
let _ = f () (* if we want to ignore the returned value *)
|
||||
let v, _ = f () (* if we want to ignore one of the returned value *)
|
||||
5
Task/Call-a-function/PARI-GP/call-a-function.pari
Normal file
5
Task/Call-a-function/PARI-GP/call-a-function.pari
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
f(); \\ zero arguments
|
||||
sin(Pi/2); \\ fixed number of arguments
|
||||
Str("gg", 1, "hh"); \\ variable number of arguments
|
||||
(x->x^2)(3); \\ first-class
|
||||
x = sin(0); \\ get function value
|
||||
8
Task/Call-a-function/Perl-6/call-a-function-1.pl6
Normal file
8
Task/Call-a-function/Perl-6/call-a-function-1.pl6
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
foo # as list operator
|
||||
foo() # as function
|
||||
foo.() # as function, explicit postfix form
|
||||
$ref() # as object invocation
|
||||
$ref.() # as object invocation, explicit postfix
|
||||
&foo() # as object invocation
|
||||
&foo.() # as object invocation, explicit postfix
|
||||
::($name)() # as symbolic ref
|
||||
1
Task/Call-a-function/Perl-6/call-a-function-10.pl6
Normal file
1
Task/Call-a-function/Perl-6/call-a-function-10.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
my $result = somefunc(1,2,3) + 2;
|
||||
13
Task/Call-a-function/Perl-6/call-a-function-2.pl6
Normal file
13
Task/Call-a-function/Perl-6/call-a-function-2.pl6
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
foo 1 # as list operator
|
||||
foo(1) # as named function
|
||||
foo.(1) # as named function, explicit postfix
|
||||
$ref(1) # as object invocation (must be hard ref)
|
||||
$ref.(1) # as object invocation, explicit postfix
|
||||
1.$foo # as pseudo-method meaning $foo(1) (hard ref only)
|
||||
1.$foo() # as pseudo-method meaning $foo(1) (hard ref only)
|
||||
1.&foo # as pseudo-method meaning &foo(1) (is hard foo)
|
||||
1.&foo() # as pseudo-method meaning &foo(1) (is hard foo)
|
||||
1.foo # as method via dispatcher
|
||||
1.foo() # as method via dispatcher
|
||||
1."$name"() # as method via dispatcher, symbolic
|
||||
+1 # as operator to prefix:<+> function
|
||||
13
Task/Call-a-function/Perl-6/call-a-function-3.pl6
Normal file
13
Task/Call-a-function/Perl-6/call-a-function-3.pl6
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
foo 1,2 # as list operator
|
||||
foo(1,2) # as named function
|
||||
foo.(1,2) # as named function, explicit postfix
|
||||
$ref(1,2) # as object invocation (must be hard ref)
|
||||
$ref.(1,2) # as object invocation, explicit postfix
|
||||
1.$foo: 2 # as pseudo-method meaning $foo(1,2) (hard ref only)
|
||||
1.$foo(2) # as pseudo-method meaning $foo(1,2) (hard ref only)
|
||||
1.&foo: 2 # as pseudo-method meaning &foo(1,2) (is hard foo)
|
||||
1.&foo(2) # as pseudo-method meaning &foo(1,2) (is hard foo)
|
||||
1.foo: 2 # as method via dispatcher
|
||||
1.foo(2) # as method via dispatcher
|
||||
1."$name"(2) # as method via dispatcher, symbolic
|
||||
1 + 2 # as operator to infix:<+> function
|
||||
13
Task/Call-a-function/Perl-6/call-a-function-4.pl6
Normal file
13
Task/Call-a-function/Perl-6/call-a-function-4.pl6
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
foo @args # as list operator
|
||||
foo(@args) # as named function
|
||||
foo.(@args) # as named function, explicit postfix
|
||||
$ref(@args) # as object invocation (must be hard ref)
|
||||
$ref.(@args) # as object invocation, explicit postfix
|
||||
1.$foo: @args # as pseudo-method meaning $foo(1,@args) (hard ref)
|
||||
1.$foo(@args) # as pseudo-method meaning $foo(1,@args) (hard ref)
|
||||
1.&foo: @args # as pseudo-method meaning &foo(1,@args)
|
||||
1.&foo(@args) # as pseudo-method meaning &foo(1,@args)
|
||||
1.foo: @args # as method via dispatcher
|
||||
1.foo(@args) # as method via dispatcher
|
||||
1."$name"(@args) # as method via dispatcher, symbolic
|
||||
@args X @blargs # as list infix operator to infix:<X>
|
||||
2
Task/Call-a-function/Perl-6/call-a-function-5.pl6
Normal file
2
Task/Call-a-function/Perl-6/call-a-function-5.pl6
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
my @args = 1,2,3;
|
||||
foo(|@args); # equivalent to foo(1,2,3)
|
||||
2
Task/Call-a-function/Perl-6/call-a-function-6.pl6
Normal file
2
Task/Call-a-function/Perl-6/call-a-function-6.pl6
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
foo :a, :b(4), :!c, d => "stuff"
|
||||
foo(:a, :b(4), :!c, d => "stuff")
|
||||
1
Task/Call-a-function/Perl-6/call-a-function-7.pl6
Normal file
1
Task/Call-a-function/Perl-6/call-a-function-7.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
1 + 1 :a :b(4) :!c :d("stuff") # calls infix:<+>(1,1,:a, :b(4), :!c, d => "stuff")
|
||||
1
Task/Call-a-function/Perl-6/call-a-function-8.pl6
Normal file
1
Task/Call-a-function/Perl-6/call-a-function-8.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
foo(); bar(); baz(); # evaluate for side effects
|
||||
1
Task/Call-a-function/Perl-6/call-a-function-9.pl6
Normal file
1
Task/Call-a-function/Perl-6/call-a-function-9.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
1 / find-a-func(1,2,3)(4,5,6) ** 2;
|
||||
2
Task/Call-a-function/UNIX-Shell/call-a-function.sh
Normal file
2
Task/Call-a-function/UNIX-Shell/call-a-function.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
sayhello # Call a function in statement context with no arguments
|
||||
multiply 3 4 # Call a function in statement context with two arguments
|
||||
12
Task/Call-a-function/ZX-Spectrum-Basic/call-a-function.zx
Normal file
12
Task/Call-a-function/ZX-Spectrum-Basic/call-a-function.zx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
10 REM functions cannot be called in statement context
|
||||
20 PRINT FN a(5): REM The function is used in first class context. Arguments are not named
|
||||
30 PRINT FN b(): REM Here we call a function that has no arguments
|
||||
40 REM subroutines cannot be passed parameters, however variables are global
|
||||
50 LET n=1: REM This variable will be visible to the called subroutine
|
||||
60 GO SUB 1000: REM subroutines are called by line number and do not have names
|
||||
70 REM subroutines do not return a value, but we can see any variables it defined
|
||||
80 REM subroutines cannot be used in first class context
|
||||
90 REM builtin functions are used in first class context, and do not need the FN keyword prefix
|
||||
100 PRINT SIN(50): REM here we pass a parameter to a builtin function
|
||||
110 PRINT RND(): REM here we use a builtin function without parameters
|
||||
120 RANDOMIZE: REM statements are not functions and cannot be used in first class context.
|
||||
Loading…
Add table
Add a link
Reference in a new issue