Advertisement
Guest User

Untitled

a guest
Dec 5th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn calculate-row
  2.   [data rows]
  3.   (loop [d data
  4.          r rows]
  5.     (if (= (rest d) ())
  6.       r)
  7.     (cond
  8.       (= (first d) \F) (recur (rest d) (bottom r))
  9.       (= (first d) \B) (recur (rest d) (top r)))))
  10.  
  11. (defn bottom [rows]
  12.   (first (partition (quot (count rows) 2) rows)))
  13.  
  14. (defn top [rows]
  15.   (second (partition (quot (count rows) 2) rows)))
  16.  
  17.  
  18. (calculate-row (char-array "FBFBBFF") (range 0 128))
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement