Guest User

Finnegans wake quaternion

a guest
Aug 2nd, 2017
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. con<-url("https://ia801302.us.archive.org/17/items/finneganswake00joycuoft/finneganswake00joycuoft_djvu.txt")
  2. finnegan<-scan(con,what="char")
  3. finnegan_quaternion<-str_replace_all(tolower(finnegan),"[^ijk]","")
  4. finnegan_quaternion<-finnegan_quaternion[str_length(finnegan_quaternion)>0]
  5. finnegan_quaternion<-unlist(str_split(finnegan_quaternion,""))
  6.  
  7. quat.def<-matrix(nrow=8,ncol=3)
  8. rownames(quat.def)<-c("p1",
  9. "n1",
  10. "pi",
  11. "ni",
  12. "pj",
  13. "nj",
  14. "pk",
  15. "nk")
  16. colnames(quat.def)<-c("i","j","k")
  17. quat.def[1,1]<-"pi"
  18. quat.def[2,1]<-"ni"
  19. quat.def[3,1]<-"n1"
  20. quat.def[4,1]<-"p1"
  21. quat.def[5,1]<-"nk"
  22. quat.def[6,1]<-"pk"
  23. quat.def[7,1]<-"pj"
  24. quat.def[8,1]<-"nj"
  25.  
  26. quat.def[1,2]<-"pj"
  27. quat.def[2,2]<-"nj"
  28. quat.def[3,2]<-"pk"
  29. quat.def[4,2]<-"nk"
  30. quat.def[5,2]<-"n1"
  31. quat.def[6,2]<-"p1"
  32. quat.def[7,2]<-"nj"
  33. quat.def[8,2]<-"pj"
  34.  
  35. quat.def[1,3]<-"pk"
  36. quat.def[2,3]<-"nk"
  37. quat.def[3,3]<-"nj"
  38. quat.def[4,3]<-"pj"
  39. quat.def[5,3]<-"pi"
  40. quat.def[6,3]<-"ni"
  41. quat.def[7,3]<-"n1"
  42. quat.def[8,3]<-"p1"
  43.  
  44.  
  45.  
  46. finnegan_quaternion[1]<-"i"
  47. finnegan_res<-vector(length=length(finnegan_quaternion))
  48. finnegan_res[1]<-"pi"
  49. for(i in 2:length(finnegan_quaternion)){
  50. finnegan_res[i]<-quat.def[finnegan_res[i-1],finnegan_quaternion[i]]
  51. }
RAW Paste Data