---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
 
# RunIf(N,S) generates N random elements from a generic collection S of elements
 
RunIf(15, c("A","B","C"))
# "C" "A" "A" "C" "C" "C" "B" "A" "B" "A" "C" "C" "B" "B" "A"
#
RunIf(15, 1:3)
# 3 2 1 2 1 3 1 1 2 1 2 3 2 3 1
#
PLANE(-1,1, -1,1)
traccia <- function(n) for(i in 1:n)
          { s = RunIf(1,c(-1,1)); x = runif(1,-1,1)
              line(x,0, 0,s*(sign(x)-x),  i)     }
           # l'ultima variabile - qui "i" -  il colore
traccia(1000)
              


Back