File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 583583 (.map (fn [vid] {:id (vid " id" ) :title (vid " title" )}))
584584
585585 subscribe-collectors
586- pdump
587- )
586+ pdump)
588587
589588; ;; in JavsScript, interpret "pair" to mean "an object with two
590589; ;; properties"
628627 (.map (fn [vid] (vid " id" )))
629628
630629 subscribe-collectors
631- pdump
632- )
630+ pdump)
633631
634632; ;; Javascript
635633; ;;
712710 asynchronous-observable
713711
714712 (.mapMany (fn [genres] (-> (genres " videos" ) asynchronous-observable)))
713+
715714 (.mapMany (fn [vid] (-> (vid " boxarts" ) asynchronous-observable
716715 (.filter (fn [art] (and (== 150 (art " width" ))
717716 (== 200 (art " height" )))))
775774; ;; Exercise 24: Retrieve each video's id, title, middle interesting moment
776775; ;; time, and smallest box art url.
777776
777+ (-> (jslurp " Exercise_24.json" )
778+ asynchronous-observable
779+
780+ (.mapMany (fn [genre] (-> (genre " videos" ) asynchronous-observable)))
781+ (.mapMany (fn [vid]
782+ (let [arts (-> (vid " boxarts" )
783+ asynchronous-observable
784+ (.reduce (fn [c p]
785+ (if (< (* (c " height" ) (c " width" ))
786+ (* (p " height" ) (p " width" )))
787+ c p))))
788+ moments (-> (vid " interestingMoments" )
789+ asynchronous-observable
790+ (.filter (fn [moment] (= (moment " type" ) " Middle" ))))
791+ ]
792+ (Observable/zip
793+ arts
794+ moments
795+ (fn [art moment]
796+ {:id (vid " id" )
797+ :title (vid " title" )
798+ :time (moment " time" )
799+ :url (art " url" )}
800+ )))
801+ ))
802+
803+ subscribe-collectors
804+ pdump)
778805
779806; ;; Javascript
780807; ;;
You can’t perform that action at this time.
0 commit comments