Fork me on GitHub
#beginners
<
2020-09-05
>
ikitommi10:09:04

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

👍 6
Michaël Salihi10:09:13

As a reminder @nando, 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: https://github.com/PrestanceDesign/usermanager-reitit-integrant-example

nando13:09:35

@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.

👍 3
Michaël Salihi10:09:13

As a reminder @nando, 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: https://github.com/PrestanceDesign/usermanager-reitit-integrant-example

Karo14:09:23

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

seancorfield14:09:02

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

👍 3
seancorfield15:09:25

For example:

user=> (def a (for [x (range 5) y (range 5)] [x y]))
#'user/a
user=> (type a)
clojure.lang.LazySeq
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/b
user=> (type b)
clojure.lang.LazySeq
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')
user=> 

👍 3
Karo15:09:23

@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 clojure.data.csv ?

seancorfield15:09:00

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

seancorfield15:09:31

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

seancorfield15:09:40

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"})

Karo15:09:03

@seancorfield "first" works, thanks so much.