Facebook
From Κώστας Κούδας, 7 Months ago, written in R.
Embed
Download Paste or View Raw
Hits: 89
  1. sygxoneysi <- function(akolouthia,v1,v2,v3){
  2.   n1 <- v2-v1+1
  3.   n2 <- v3-v2
  4.   aristera <- c(1)
  5.   for (i in c(1:n1)){
  6.     aristera[i] <- akolouthia[v1+i-1]
  7.   }
  8.   aristera[n1+1] <- Inf
  9.   dexia <- c(1)
  10.   for (i in c(1:n2)){
  11.     dexia[i] <- akolouthia[v2+i]
  12.   }
  13.   dexia[n2+1] <- Inf
  14.   i <- 1
  15.   j <- 1
  16.   for (k in c(v1:v3)){
  17.     if (anisosi(aristera[i],dexia[j])) {
  18.       akolouthia[k] <- aristera[i]
  19.       i <- i+1
  20.     }
  21.     else {
  22.       akolouthia[k] <- dexia[j]
  23.       j <- j+1
  24.     }
  25.   }
  26.   akolouthia
  27. }
  28.  
  29. ttt <- c(4,6, 2,5,7,9, 3,4,7,12,21, 6,5,0)
  30. ttt2 <- c(4,6, 2,5,7,9,10, 3,4,7,12,21, 6,5,0)
  31. sygxoneysi(ttt,3,6,11)
  32. sygxoneysi(ttt2,3,7,11)