test.cljs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. (farts) foo
  2. (thing) foo
  3. '[foo `(bar )]asdf [foo ]
  4. #_
  5. (ns learnnext.core
  6. (:require
  7. [om.next :as om :refer-macros [defui]]
  8. [om.next.protocols :as p]
  9. [om.dom :as dom]
  10. [pdf.core :refer [and* or* not*] :refer-macros [defpdf pdf]]
  11. [heh.core :as heh :refer-macros [html]]
  12. [dollar.bill :as $ :refer [$]]
  13. [learnnext.data :as data])
  14. (:use [cljs.pprint :only [pprint]])) (foo) sdf
  15. lsdfk.cheese/*foo*
  16. cat
  17. foo
  18. foo.core/*baz*
  19. *foo*
  20. *
  21. @(enable-console-print!)
  22. thing.core/asdlfkj
  23. ($/append ($ "head")
  24. ($ "<style>#chart{font-size:.7em; font-family:courier;}
  25. .column{display:inline-block; width:150px; border-right:1px solid black; padding:.2em .5em; border-bottom:1px dotted silver;}</style>"))
  26. @sdgf '(@( 'foo)) asfg sdf
  27. dfg
  28. '(ts.core/foo (:sldjf 37 )) asdf
  29. @( '( @(+ 1 '(* 3 1) ) ))
  30. (ns rainbow.sexpress)
  31. (quote
  32. ((((((((((((((((()))))))))))))))))
  33. {{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}
  34. [[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]
  35. ({[({[({[({[({[({})]})]})]})]})]}))
  36. fo.bazo/core
  37. (def app-state (atom {
  38. :app/title "Main Sequence Stars"
  39. :stars (into {}
  40. (map
  41. (fn [[class rgb]] {class {:color/rgb rgb}})
  42. data/stellar-colors))}))
  43. (def stars? #{:stars})
  44. (def rgb? #(re-find #"rgb$" (str %)))
  45. (comment foo (sdlfkj))
  46. (defn read [data k] ;hello world
  47. (if-let [#_ foo local (get (:state data) k) ]
  48. (comment {:value local})
  49. {:value :not-found}))
  50. *fart*
  51. @atom
  52. (defpdf read)
  53. *fart*
  54. (pdf read [data k]
  55. (get @(:state data) k :not-found ) )
  56. (pdf read [data k _]
  57. (get @(:state data) k :not-found))
  58. (pdf read [data k props]
  59. {props (and* :start :end)}
  60. (let [local (get @(:state data) k)
  61. {:keys [start end]} props]
  62. {:value (take (- end start) (drop start local))}))
  63. (pdf read [data k _]
  64. {k #{:app/title}}
  65. {:value (reverse (get @(:state data) k))})
  66. (defn mutate [_ _ _] {})
  67. (defui Star
  68. static om/IQuery
  69. (query [this] '[:class :color/rgb :color/hex])
  70. Object
  71. (render [this]
  72. (let [props (om/props this)]
  73. (html
  74. (<div.star
  75. (<span.class.column (:class props))
  76. (<span.rgb.column
  77. (style {:background (:color/hex props)})
  78. (str "rgb" (into '() (:color/rgb props))))
  79. (<span.class.column
  80. (style {:background (:color/hex props)})
  81. (:color/hex props)) )))))
  82. [[[[[[[]]]]]]]
  83. ;TODO
  84. ; [x] #_ ignore pair
  85. ; [x] fix newlines breaking basic forms
  86. ; [x] hashmap capture
  87. ; [ ] sexpr pairs
  88. ; [x] special form scoping
  89. ; [x] illegalize nested lambdas, naked lambda args
  90. ; [x] scope for clojure.core fns
  91. ;rainbows
  92. (quote
  93. ((((((((((((((((()))))))))))))))))
  94. {{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}
  95. [[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]
  96. ({[({[({[({[({[({})]})]})]})]})]}))
  97. ;symbols
  98. methods userland foo.core/qualified
  99. [[ \newline23] ]
  100. ;literals
  101. 12 2.9 3/6 0xBADA55 9r8012 07123 -1.2e-5 4.2M 18N
  102. :keyword ::qualified :foo.core/resolved
  103. "hello \"world\"" #"rgb$[\(]"
  104. #<GameObject Foo (UnityEngine.GameObject)>
  105. {0 '₀ 1 '₁ 2 '₂ 3 '₃ 4 '₄ 5}
  106. ;specials
  107. @(atomic) @foo
  108. #(re-find #"rgb$\(" (str %3))
  109. '(reader [quoted @(form) `(~@[1 2 3])])
  110. ;macro-specials
  111. (defmacro fun [sym args & code]
  112. `(do #_'(prn ~[sym args])
  113. '~@[sym args]
  114. (comment (def ~'foo 7))
  115. (def ~sym [~'a b]
  116. ~@code)))
  117. ;TODO illegalize
  118. [foo/ /baz %1 ::foo.bar/quaz .67 #(#()) {1 2 3} \newline23]
  119. ;TODO legalize
  120. [ :./d :. :./. a:b ] \newline
  121. ;TODO scope
  122. [clojure.pprint/*thing* #'foo foo#
  123. #?(:cljs reader-conditional) ^{:meta 'form }]
  124. ;TODO fix
  125. (map
  126. (comp ;ridic
  127. #(re-find #_ #"rgb$\("
  128. (str %))
  129. #(* % %))
  130. (get {:foo.core/thing [1 2/7 3 4.6]}
  131. ::thing)))
  132. (def subscript
  133. {0 '₀ 1 '₁ 2 '₂ 3 '₃ 4 '₄ 5 '₅ 6 '₆ 7 '₇ 8 '₈ 9 '₉ '+ '₊ '- '₋ '= '₌ :open '₍ :close '₎ })
  134. (defn sub-int [n]
  135. (symbol (apply str
  136. (concat
  137. (if (neg? n) ['₋] [])
  138. (mapv (comp
  139. #(get subscript % '?)
  140. int
  141. str)
  142. (seq (str (int n))))))))
  143. (defn sub-list [s]
  144. (symbol (apply str (concat ['₍] [s] ['₎]))))
  145. (defn baz [a b c]
  146. #_(map
  147. (comp ;ridic
  148. #(re-find #"rgb$\(" (str %))
  149. #(* % %))
  150. (get {:foo.core/thing [1 2/7 3 4.6]}
  151. ::thing)))
  152. fii
  153. [dfjk]
  154. clojure.string/lowercase
  155. (comment)
  156. #_ asdf adf
  157. gii
  158. #_ (defui Widget
  159. static om/IQueryParams
  160. (params [this]
  161. {:start 0 :end 5})
  162. static om/IQuery
  163. (query [this] '[:app/title (:stars {:start ?start :end ?end})])
  164. Object
  165. (render [this]
  166. (comment )(let [props (om/props this)
  167. stars (:stars props)]
  168. (html
  169. (<h1#title (:app/title props) ) (<hr)
  170. (map
  171. (fn [[k v]]
  172. (<label (clj->js k)
  173. (<input
  174. (value (str v))
  175. (onChange (fn [e]
  176. (om/set-params! this
  177. (conj (om/params this)
  178. {k (int (.. e -target -value))}))
  179. (prn (om/params this)))))))
  180. (om/params this))
  181. (<div#chart
  182. (map #(<span.column %) (clj->js (keys (last (last stars)))))
  183. (map #(star (assoc (last %) :om-index (gensym))) stars))))))
  184. (def reconciler (om/reconciler {:state app-state :parser (om/parser {:read read :mutate mutate})}))
  185. (om/add-root! reconciler Widget (first ($ "#app")))