This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-18
Channels
- # admin-announcements (3)
- # arachne (8)
- # beginners (55)
- # boot (51)
- # cbus (1)
- # cider (15)
- # cljs-dev (5)
- # cljsrn (8)
- # clojure (203)
- # clojure-austin (2)
- # clojure-belgium (12)
- # clojure-boston (6)
- # clojure-czech (47)
- # clojure-dusseldorf (14)
- # clojure-estonia (1)
- # clojure-greece (42)
- # clojure-japan (2)
- # clojure-poland (4)
- # clojure-russia (97)
- # clojure-sg (5)
- # clojure-uk (41)
- # clojurescript (122)
- # code-reviews (4)
- # component (3)
- # core-matrix (19)
- # cursive (25)
- # datomic (16)
- # devcards (24)
- # editors (6)
- # euroclojure (1)
- # hoplon (88)
- # immutant (3)
- # incanter (4)
- # jobs (5)
- # keechma (1)
- # luminus (1)
- # om (44)
- # onyx (22)
- # parinfer (3)
- # planck (1)
- # proton (3)
- # re-frame (5)
- # reagent (30)
- # ring (2)
- # spacemacs (1)
- # untangled (92)
- # yada (1)
I don't think so
if you're asking that question, you're likely to be better off creating a Java interface and implementing it in Clojure instead
Clojure functions, records, and protocols will generate Java interfaces that take and return Object for all args which most Java users find disconcerting :)
Hi all. Very new to Clojure. Say I have a list of symbols (names if you will) and I want to derive a list with certain symbols removed, I'm sort of struggling to understand how to do that in Clojure. In Java 8, for example, I would simply do something like this:
(remove #{'a 'b} '(a b c))
maybe?
that returns ’(c)
(remove #{’name-to-remove} names)
maybe? where names
is a sequence?
#{}
is a set literal, so (remove #{’set ‘of ’things} x)
returns a new sequence where anything in the set is removed
what does the ' mean in front of the bar and in front of the sequence of foo bar baz?
the ’
does “quoting”, which means “treat this as data, don’t evaluate it”. otherwise Clojure would try to call the foo
function on arguments bar
and baz
with quoting, you get a list containing the symbols foo
etc
instead of clojure trying to evaluate the function that foo
evaluates too, and applying that to the value that bar
evaluates to
@dharrigan: might i suggest reading clojure for the brave and true? it’s free to read online
Would it not be the case that if foo, bar and baz are not found as a function or macro, that clojure would then think it's a symbol and treat as such?
it does a good job of introducing clojure
I’m looking to iterate over a number (e.g. 1 to 5) and create a vector of maps (using the number as part of the input). (brave clojure chapter 3 ex. 6) — seems like I should be using reduce
but I can’t figure out how
bojan.matic: thank you. I have it - but to be honest, I find it a bit "brogrammy" with tales that I find distracting from getting to the gist of the code.
if i’m not mistaken, quoting really only means “don’t evaluate this list as a function call, and don’t try to resolve symbols within it”
@dharrigan: if you can make it past all stuff you don’t like, http://www.braveclojure.com/read-and-eval is meant to give a solid understanding of how clojure evaluation works
https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome explains quote as well
FWIW I like the silly stuff @nonrecursive 😉
tx 😄 I know it’s not for everyone, no big deal
my question was missed a little while back: I’m looking to iterate over a number (e.g. 1 to 5) and create a vector of maps (using the number as part of the input). (brave clojure chapter 3 ex. 6) — seems like I should be using reduce
but I can’t figure out how. Any pointers in the right direction?
what do you want to be the output, given an input of [1 2 3 4 5]
where do the :a
and :b
come from?
shamelessly copied and adapted: (map vector [:a 😛 :c :d :e] (take 5 (map inc (iterate inc 0))))
@jeffh-fp: I’m with Bojan in asking about where the keys are coming from but from the sound of it you might want to look at misread about the input datareduce-kv
If the keys are just :a
, :b
, :c
, etc. , something like
(map (comp keyword str char) (range 97 (+ 97 vector-size)))
can generate the array of keywords@jeffh-fp: I wrote this awhile back to explain how to reduce
more complicated things http://jcswart.github.io/2014/01/25/clojure-like-im-five-reduce-functions/