This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-21
Channels
- # admin-announcements (24)
- # beginners (80)
- # cider (18)
- # cljs-dev (12)
- # clojure (94)
- # clojure-berlin (15)
- # clojure-dev (10)
- # clojure-gamedev (3)
- # clojure-italy (38)
- # clojure-japan (4)
- # clojure-russia (109)
- # clojure-sg (1)
- # clojurescript (161)
- # code-reviews (29)
- # core-async (17)
- # datomic (20)
- # editors (14)
- # instaparse (17)
- # ldnclj (9)
- # off-topic (9)
- # om (2)
- # onyx (2)
- # re-frame (11)
- # reagent (46)
This could more generally be, if I want a function to return multiple vectors, what’s the best way to do that?
The right way appears to be just wrapping everything in a list
clj-pdf will render all elements of the list
Can anyone explain the difference between structs and records to me please?
How do I make a a target directory for exporting pages in the stasis library?
Dw got it working lol
@agile_geek: It’s my understanding structs are obsolete
https://clojuredocs.org/clojure.core/defstruct - See the note 3.2 years ago at that link
And also http://clojure.org/datatypes, which in addition to outlining the differences says "Overall, records will be better than structmaps for all information-bearing purposes"
Hmm, still running into the issues from earlier. If I have a list of things, say, (“item 1” “item 2” “item 3”), and I want them to appear as:
[item 1]
[item 2]
[item 3]
What’s the best way to do such a thing? Do I need a macro?Or is there a way with apply
I just haven’t figured out yet
@yogthos If you have any suggestions on how to do such a thing, I’d appreciate it. A concrete example of what I’d like, given that items
refers to a vector of
[“Item 1” “Item 2” “Item 3”]
, what’s the best way to transform that to
[:list
[:chunk “Item 1"]
[:chunk “Item 2”]
[:chunk “Item 3”]
]
Currently trying with this:
(let [items ["item 1" "Item 2" "item 3"]]
[:list
(for [item items]
[:chunk item])
]
)
which fails due to a ClassCastExceptionThis is all in clj-pdf
Thanks @akiva! That did it
@surreal.analysis: I think akiva’s solution might flatten the three [:chunk “Item <n>”] vectors into a single vector. If you want the output to be exactly as you requested you could try this approach: (into [:list] (map (juxt (constantly :chunk) identity) x))
Ah, you’re right @james - Not sure why that was considered valid
Thanks for the clarification
@surreal.analysis: Your approach with the for macro also works: (into [:list] (for [item items] [:chunk item]))
Oh, that’s my favorite so far
Thanks again!
@surreal.analysis: I suspected as much but I just wasn’t sure. Thanks.
Hi, How do I decipher following error?
[server] lein figwheel
Figwheel: Starting server at
clojure.lang.ArityException: Wrong number of args (2) passed to: reader/read
at clojure.lang.AFn.throwArity(AFn.java:429)
at clojure.lang.AFn.invoke(AFn.java:36)
at cljs.analyzer$forms_seq_STAR_$forms_seq___2093$fn__2094$fn__2095.invoke(analyzer.cljc:2040)
at cljs.analyzer$forms_seq_STAR_$forms_seq___2093$fn__2094.invoke(analyzer.cljc:2034)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:507)
at clojure.core$seq__4128.invoke(core.clj:137)
at cljs.analyzer$parse_ns$fn__2109.invoke(analyzer.cljc:2111)
at cljs.analyzer$parse_ns.invoke(analyzer.cljc:2094)
at cljs.analyzer$parse_ns.invoke(analyzer.cljc:2085)
at cljs.analyzer$analyze_file.invoke(analyzer.cljc:2212)
at cljs.compiler$with_core_cljs.invoke(compiler.cljc:967)
at figwheel_sidecar.repl$analyze_core_cljs$fn__18151.invoke(repl.clj:263)
at figwheel_sidecar.repl$analyze_core_cljs.invoke(repl.clj:261)
at figwheel_sidecar.repl$run_autobuilder_helper.invoke(repl.clj:298)
at figwheel_sidecar.repl$start_autobuild.invoke(repl.clj:376)
at figwheel_sidecar.repl$run_autobuilder.invoke(repl.clj:535)
at user$eval18255.invoke(form-init3831675151583155220.clj:1)
@arathunku: Not sure the right way to go about it, but I see that error when I have a #
symbol out of place
Specifically, if I’m moving s-expressions around
And I end up with an anonymous function like
# (do-something %)
Note the space
Ah, but some googling lead me to here - https://www.reddit.com/r/Clojure/comments/3295j6/clojurescript_003196_and_cidernrepl/
So it might be a dependency conflict with your ~/.lein/profiles.clj
Are you using cider-nrepl?
What does your project.clj look like?
https://github.com/arathunku/game-fun/blob/feature/figwheel-cljs/tiled-mmo/server/project.clj
It looks like, that line: https://github.com/arathunku/game-fun/blob/feature/figwheel-cljs/tiled-mmo/server/project.clj#L20 is causing problems...
@arathunku: oh right, that error is a clashing dependency issue, possibly someone else trying to bring in a stale version of tools.reader
@arathunku: ClojureScript relies on a specific version of tools.reader some other dep might be clobbering that
Though I do not see any clash when I do lein deps :tree
, what does your ~/.lein/profiles.clj
look like?
@dnolen: is there any place where I should report such stuff? Because if it wasn't for git diff, I'd have never guessed that from the error message
@arathunku: not really since this is just typical dep management hijinks
@arathunku: That's a conflict caused by the wrong version of Clojure in your dependencies somewhere, I think. read
accepting 2 arguments was added in Clojure 1.7.
Ah, okay, I didn’t see you were on a feature branch. Running lein deps :tree
prints out a huge tree, which includes:
[jarohen/chord "0.6.0"] -> [org.clojure/tools.reader "0.8.3"]
overrides
[lein-figwheel "0.3.5"] -> [figwheel-sidecar "0.3.5"] -> [com.cemerick/piggieback "0.1.5"] -> [org.clojure/clojurescript "0.0-2665"] -> [org.clojure/tools.reader "0.8.10”]
I know it’s not the simplest solution, but that gives you a place to start if you run into weird errors that might be dependency management again
That might be the case, but still, shouldn't lein take care of that and inform me about the problem? I'd like open an issue about that somewhere and avoid poking around next time something like that happens. For the same error message I've received 3 completely different suggestions what should I check, clearly something is wrong.
That's why we call it dependency hell. No one has solved it yet in the history of programming.
I've never experienced such problem with bundler(ruby) because the output is very clear about the problem and highlights gems with their deps and conflicts.
You can read about some of the reasoning here: https://github.com/technomancy/leiningen/issues/1337
@surreal.analysis: thanks!
@arathunku: I don’t know what bundler you used but it’s not the bundler I used at NYTimes for 3 years
Since this discussion is in #C053AK3F9, I expect @arathunku is experiencing the typical difference between a tool/environment you have a lot of experience with — where most problems are "easy" — and an environment that is totally unfamiliar.
@dnolen: newest, for last 2y. I've fighted with bundler a lot too just not with conflicting versions of gems.
@arathunku: I fought everything from conflicting gems to native gems
@stuartsierra: for me it's more about completely useless error message.
having said that, yeah, I’ve run into weird deps issues with clojure, but maybe because of my java background, I kind more or less diagnose the issue
can someone please help me understand the exception (#(%1) 1)
throws? I'd expect it to be an equivalent of 'identity' function, but am getting ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
@hq1 Very common #C053AK3F9 mistake
#(%)
is not the same as (fn [x] x)
Rather, #(%)
expands to (fn [x] (x))
.
you're welcome!
@stuartsierra: how can I expand that macro to actually see it?
@hq1: It's a reader macro, so something like (read-string "#(%1)")