Fork me on GitHub

I recommend looking at Integrant and adopting integrant.repl/reset as part of the dev workflow. All stateful things are reseted, including routers.

👍 2
Michaël Salihi10:09:13

As a reminder @U078GPYL8, you can find the integrant.repl/reset setup on the repo that I shared with you last time. The Sean Corfield's usermanager with Reitit / Integrant version:


@UFBL6R4P3 Thanks for the tip! I've been planning to integrate Integrant into my app as the next major step moving forward. And I've been using your repo as a reference, so thanks again for sharing it with me. It's been very helpful.

👍 1

Hi all, is it possible to convert clojure.lang.LazySeq to clojure map?


@vnazaryan That depends on what the lazy sequence contains. Can you be more specific about the context of your question?

👍 1

For example:

user=> (def a (for [x (range 5) y (range 5)] [x y]))
user=> (type a)
user=> (into {} a) ; a is a lazy seq of vector pairs so this works
{0 4, 1 4, 2 4, 3 4, 4 4}
user=> (def b (map inc (range 10)))
user=> (type b)
user=> (into {} b) ; plain ol' sequence -- won't work
Execution error (IllegalArgumentException) at user/eval168 (REPL:1).
Don't know how to create ISeq from: java.lang.Long
user=> (into {} (partition 2 b)) -- sequence of (non-vector) pairs -- won't work
Execution error (ClassCastException) at user/eval170 (REPL:1).
class java.lang.Long cannot be cast to class java.util.Map$Entry (java.lang.Long and java.util.Map$Entry are in module java.base of loader 'bootstrap')

👍 1

@seancorfield please see the result or print function of returned data. its class is clojure.lang.LazySeq that is why I am not able to read values by keys, need to convert it into map.

Matthew Pettis15:09:08

I am looking to read in some CSV files and do some very simple manipulations on the result, like concatenating two CSV files on same-named column, altering the value of a column, and computing a new column based on the values of other columns in the same row. If you are familiar with R, I am thinking a very small subset of what is implemented in the {dplyr} package there. I started looking at incanter, but that appears to no longer be under active development, and I'm not sure I can find the appropriate ways to do it via that anyway (though if it is no longer supported, and I am missing the basic data manipulation tooling, I'd be happy to be pointed to it). I imagine I can implement from scratch, but I have to assume this has already been implemented elsewhere and far more robustly than my first pass will do. Is there a section of incanter that does basic tabular data manipulation? Or is there another package that is smaller that does this for the data structure that is read in by ?


@vnazaryan That looks like a hash map inside a sequence. Use first to get the hash map out.


(and it's much easier for folks to help if you post code as text instead of images)


You can use triple backticks around blocks of code to make it more readable, or single backticks around a short expression

block of 
code with three ` before and after
And ({:short "expression"})


@seancorfield "first" works, thanks so much.