This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -0,0 +1,10 @@
integer f0(void); # No arguments
void f1(integer, real); # Two arguments
real f2(...); # Varargs
void f3(integer, ...); # Varargs
void f4(integer &, text &); # Two arguments (integer and string), pass by reference
integer f5(integer, integer (*)(integer));
# Two arguments: integer and function returning integer and taking one integer argument
integer f6(integer a, real b); # Parameters names are allowed
record f7(void); # Function returning an associative array

View file

@ -0,0 +1,60 @@
NB. j assumes an unknown name f is a verb of infinite rank
NB. f has infinite ranks
f b. 0
_ _ _
NB. The verb g makes a table.
g=: f/~
NB. * has rank 0
f=: *
NB. indeed, make a multiplication table
f/~ i.5
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
NB. g was defined as if f had infinite rank.
g i.5
0 1 4 9 16
NB. f is known to have rank 0.
g=: f/~
NB. Now we reproduce the table
g i.5
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
NB. change f to another rank 0 verb
f=: +
NB. and construct an addition table
g i.5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
NB. f is multiplication at infinite rank
f=: *"_
NB. g, however, has rank 0
g i.5
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16

View file

@ -0,0 +1,11 @@
#lang racket
(define (no-arg) (void))
(define (two-args a b) (void)) ;arguments are always named
(define (varargs . args) (void)) ;the extra arguments are stored in a list
(define (varargs2 a . args) (void)) ;one obligatory argument and the rest are contained in the list
(define (optional-arg (a 5)) (void)) ;a defaults to 5

View file

@ -0,0 +1,2 @@
(provide (contract-out
[two-args (integer? integer? . -> . any)]))

View file

@ -0,0 +1,4 @@
#lang typed/racket
(: two-args (Integer Integer -> Any))
(define (two-args a b) (void))