Fork me on GitHub

@klaus.azesberger you may want to try adding expound to your project; it'll make those giant spec errors much more readable.


Hello everybody, a beginner question regarding clojurescript tooling: What is the difference between figwheel and figwheel-main? Which one would you recommend? Thanks in advance!


Pick up figwheel if you are using leiningen or boot for building cljs. figwheel-main is mostly for tools.deps utility which is new and still in alpha


Ok, thanks for the advice 🙂 Is there any overview on best practice configuration of leiningen for cljs dev and build? I mean apart from the various templates (eg reagent-figwheel, figwheel, mies) which differ quite alot in structure and complexity?


There is no silver bullet, unfortunately. I can suggest to play with compiler options and find out the best configuration for yourself. Templates can be a good starting point on that way) For myself I usually starting with basic minimum (just cljs-build) and add complex tools only when I have some problems, like need to reload webpage often to reload source code or need to connect my IDE with running program.


It is not the simplest way but as long as you following it will give you a lot in terms of understanding what is going on and how to solve it


maybe doing it manually is the best path anyways. thanks a lot!


mind blank: I got a function that initializes a certain specialized data structure, and a function that adds an element to it. Any reason not to bundle them into an object? or what would be the most idiomatic way to provide users with an easy way to use instances of this duo?


I would look to bundle them into an object myself. If it’s a persistent data structure, implementing IPersistentCollection would be a way to hook into familiar clojure.core fns.


Oh, nice tip about IPersistentCollection


Any recommendation from within this group of alternative paths for implementing an interface?


For implementing a data structure, I would look to deftype or reify

👍 1

Thanks @donaldball anyway, is there a purely functional counterpart to this?


I guess not; just making all those functions that work on my specialized data structure sit in their own namespace, leaving it to users to abuse them on the wrong data types

Mario C.18:07:46

Question: Is there a way I can pattern match on map keys? For example, say I have a map with many different keys and I'd like to filter out some of those based on their key-name. Something along the lines of (dissoc my-map (regex that matches on key name))

Mario C.18:07:59

Another way to put it is that I want to filter out any keys that may contain the word password or phrase pass.


I would do this via reduce-kv - there's no solution that isn't a linear scan on all keys

Mario C.18:07:50

But is there a way I can check if a key contains a word/phrase?


what's the type of the key? if it's a keyword name gives you a string not including (optional) namespace


str gives you the actual string representation of course

Mario C.19:07:18

(filter (fn [[key val]] (= nil (re-find #"pass" (str key)))) my-map)

Mario C.19:07:40

I was able to get it done using that. But I don't understand why I get a vector back?

Mario C.19:07:37

If the input is this {:example "value-a" :sql-pass "abc123" :my-password "hunter2"}

Mario C.19:07:54

The result I get is ([:example "value-a"])

Mario C.19:07:46

Nevermind. That is actually expected


you can use into with the filter transducer here


(into {} (filter f?) m)


where f? is your fn above

Mario C.19:07:26

Yea thats what I ended up doing


note that m is outside the filter call


the other way works too, but filter's transducer is preferable in cases like this where it can be used

Mario C.19:07:07

Why is it preferable?


it directly filters the values going into the hash-map, instead of making a lazy-seq and then putting that into a hash-map


also (filter f) can be composed directly with other transformations


but maybe you don't need this in #beginners 😄

Mario C.19:07:21

:thumbsup: :thumbsup:


How will this code look like on Clojure

const func  = (x, y) => f => f(x, y)


(defn func [x y] (fn [f] (f x y)))


that fn could equivalently be #(% x y)


Hello everyone, I need help in printing the cell data of column A and Column B in REPL. How can I print it? This is what I coded till now: (defn sheet "Return all the sheet [sheet] from file [file-path]" [file-path sheet-name] (->> (load-workbook file-path) (select-sheet sheet-name) (select-columns {:A :col1, :B :col2}) ) )


@rachna.rajput99 If you’d like a nice tabular printout clojure.pprint/print-table is nice.