M

@Mashiro

binary search using map filter rduce

Clojure
3 years ago
(defn binary-search [coll value] (let [pred #(< % value)] (->> coll (map #(if (pred %) -1 1)) (reduce (fn [acc x] (+ acc x)) 0) (filter #(not= % 0)) first)))

Assignment 3

Python
3 years ago
"🔒" interface IPrintable { fun printWithIndent(indent: Int) { val indent = (1 .. indent).map {"| "}.joinToString("") println(indent + this.toString()) } } #result #

Assignment 2

Python
3 years ago
"🔒" ; We will be using several builtin libraries (require '[clojure.java.io :as io]) (require '[clojure.string :as str]) (require '[clojure.pprint :refer [pprint]]) (require '[clojure.edn :as edn]) (load-file "my.clj") (def CSV-FILE "my_BankerChurners.csv")

Assignment 1

Python
3 years ago
"🔒" (load-file "my.clj") (require '[clojure.pprint :refer [pprint]]) (println "------ Articles ----------") (pprint articles) (println) (println "------ Authors -----------") (pprint authors)

lecture-11-4-map-reduce

Python
3 years ago
"🔒" (def B 1e9) #Result ##'user/B "🔒" (def social-network {:members [ {:id 1000 :name "Jack" :age 20

Data processing in Clojure

Python
3 years ago
"🔒" (def B 1e9) #Result ##'user/B "🔒" (def social-network {:members [ {:id 1000 :name "Jack" :age 20

Homework 1

Python
3 years ago
"✍️" # @workUnit def stars(height: int): if height < 0: raise Exception("Height is negative.", height) for i in range(height): print("*" * (i+1)) "🔒"

Homework 2

Python
3 years ago
"🔒" (load-file "my.clj") #Result ##'user/... #Complete the following expression so the address symbol is bound to a value with the following properties: # a vector # has length three # the second element is a hashmap # the hashmap has at least one key-value pair of (:hello, "world") "✍️"