September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,11 @@
# list of the vectors by inserting x in s at position 0...end.
linsert <- function(x,s) lapply(0:length(s), function(k) append(s,x,k))
# list of all permutations of 1:n
perm <- function(n){
if (n == 1) list(1)
else unlist(lapply(perm(n-1), function(s) linsert(n,s)),
recursive = F)}
# permutations of a vector s
permutation <- function(s) unique(lapply(perm(length(s)), function(i) s[i]))

View file

@ -0,0 +1,18 @@
> permutation(letters[1:3])
[[1]]
[1] "c" "b" "a"
[[2]]
[1] "b" "c" "a"
[[3]]
[1] "b" "a" "c"
[[4]]
[1] "c" "a" "b"
[[5]]
[1] "a" "c" "b"
[[6]]
[1] "a" "b" "c"