This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-16
Channels
- # admin-announcements (9)
- # beginners (112)
- # boot (223)
- # cbus (10)
- # cider (19)
- # clara (2)
- # cljs-dev (81)
- # cljsjs (3)
- # cljsrn (45)
- # clojure (239)
- # clojure-conj (12)
- # clojure-poland (2)
- # clojure-russia (56)
- # clojure-taiwan (1)
- # clojurescript (57)
- # cursive (28)
- # datomic (5)
- # events (14)
- # immutant (1)
- # jobs (1)
- # ldnclj (8)
- # off-topic (28)
- # om (80)
- # onyx (121)
- # re-frame (10)
- # sneer-br (1)
- # spacemacs (40)
- # yada (44)
@binduwavell: maybe you want spacemacs.
Can I programm in clojure on windows or can I better use a cloud enviroment so I can use Linux ?
#ian I know enough languages which are not right to do in Windows. Is lighttable then a good ide and can I have a lint and a format function too
oke , then I will try to make my first steps with clojure using light table and the brave book
http://braveclojure.com also has really good info on using emacs
Hi, I am trying to figure out how to use (
to reference a resource in a dependency. I see the an optional argument is a class loader. Is there a way to create a classloader from symbol foo
where foo
is my dependency name?
@shwx84: your dependencies will appear on the classpath once you start the repl/properly packaged app. io/resource
will pick up anything on the classpath. If you want to fetch a dependency dynamically, you can take a look at https://github.com/pallet/alembic
according to http://clojure.org/java_interop: > All arguments are passed to Clojure fns as objects, so there's no point to putting non-array primitive type hints on fn args. Instead, use the let technique shown to place args in primitive locals if they need to participate in primitive arithmetic in the body. is this still true?
Any documentation for specter that I have overlooked? I struggle to understand if-path and cond-path. And how is (s/transform [(s/if-path [:a :b] :a :b)] inc {:a {:b 2}})
= {:a "{:b 2}1"}
?
What I'm trying to do is apply the transform only if the given path exists. I don't know of a similar function in clojure, which is why I wrote a contains-in
, which I check before calling update-in
. However these functions don't handle lists, and specter does so beautifully.
I’m trying to insert a bigInt to a postgrest bigint column using Yesql. But get "Can't infer the SQL type to use for an instance of clojure.lang.BigInt. Use setObject() with an explicit Types value to specify the type to use.” I tried using 🆔:bigint , 🆔:integer and other stuff but can’t get it to work. Did also see https://github.com/krisajenkins/yesql/issues/59 but not really sure what to do really. Any tips?
Here's an example for converting Clojure maps to JSON fields http://hiim.tv/clojure/2014/05/15/clojure-postgres-json/
@mhjort: ah, will look into that- thanks (sorry, kids pulled me from the computer, hence the lag)
@oliv: here is an example: https://github.com/tolitius/mount/blob/master/doc/uberjar.md#creating-reloadable-uberjarable-app
here find-orders
and add-order
are DB calls from within compojure routes, and they are simply :require
d
oke, so no much people code in the cloud . Not handy when you make something as a team I think
hm, I don't think many teams use those cloud programming platforms, do they? everyone just uses DVCS.
Every large team I've ever been on has used git (or in the past other version control systems).
IMO cloud dev environments are a good fit for people with Chromebooks (or windows?) that can’t set up a good environment locally. Not being able to work offline or with poor wifi would be terrible.
oke, I work with Windows but I can set up a good enviroment on my own box. I work now with LightTable, lein
why do add_hundred give a error message here : http://lpaste.net/145376
I see this error message : clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: add_hundred in this context, compiling:(C:\Users\rwobb\Documents\programming-exercises\do_things\src\do_things\core.clj:10:1)
The style guid would tell you to name the function add-hundred (dash not underscore).
darnok may be on the right path, there's some mapping between underscores and dashes when it comes to modules/namespaces and file names. Not sure how deep that goes.
It works in REPL . I'll check if it doesn't work when you load and compile source file.
I work with Lighttable and I see the error when I only select this line (add_hundred 😎
I have a question about lazy seq's... I feel like I must be missing something obvious. I'd like to "store" a lazy seq in a map, like this (merge mymap { :generations (iterate next-generation cells)})
since it just writes over old values… does it matter if mymap has :generations in it already?
it looks like merge uses reduce1
internally, which would evaluate the lazy seq. https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L895
anyone here who is using light table as his/her IDE. I wonder if it is possible to use eastwood in Light table ?
nope, but according to the readme, I have to do lein eastwood but Light table has no terminal where I can put it
no worries, I’m not even sure I’m right. It is what I understood from the source code.
I’m always interacting with the command line (to start figwheel, start a repl, start a docker container, etc)
Yeah I use the lein repl frequently, just to sanity check. The cursive REPL is great, but maybe too helpful sometimes.
yeah, I’m not too familiar with LightTable, maybe they have a plugin similar to cider in Emacs that allows you to start a repl inside emacs.
but since you are just beginning, I would just focus on keeping things simple so I can learn the language
oke, maybe I schould not use a ide but work with repl. Last question : How can I load a source file in repl ?
Assoc worked, thanks roberto! It's a little dangerous on the REPL, because if you try to print the resulting map it tries to eval the infinite seq... But it's a start!
it is good to use when you are building a project and are comfortable with the language
So I am wondering, is it considered a bad idea to make a protocol like this: (defprotocol ICompare (< [this other]) (> [this other]) (<= [this other]) (>= [this other])) (extend-protocol ICompare java.lang.Comparable (< [this other] (neg? (compare this other))) (> [this other] (pos? (compare this other))) (<= [this other] (or (= this other) (neg? (compare this other)))) (>= [this other] (or (= this other) (pos? (compare this other)))))
I mean it gives a lot of warnings, but it works: Warning: protocol #'microservice.cassandra/ICompare is overwriting function < Warning: protocol #'microservice.cassandra/ICompare is overwriting function > Warning: protocol #'microservice.cassandra/ICompare is overwriting function <= Warning: protocol #'microservice.cassandra/ICompare is overwriting function >= WARNING: < already refers to: #'clojure.core/< in namespace: microservice.cassandra, being replaced by: #'microservice.cassandra/< WARNING: <= already refers to: #'clojure.core/<= in namespace: microservice.cassandra, being replaced by: #'microservice.cassandra/<= WARNING: >= already refers to: #'clojure.core/>= in namespace: microservice.cassandra, being replaced by: #'microservice.cassandra/>= WARNING: > already refers to: #'clojure.core/> in namespace: microservice.cassandra, being replaced by: #'microservice.cassandra/>
This way i can compare java.util.Dates and everything else that is comparable. I am just wondering if there is a better way to do it. Or a way to get rid of the warnings.
@casperc: http://clojuredocs.org/clojure.core/refer-clojure will get rid of the warnings . i would choose something else for the fn names though - i would find re-using <
etc confusing
What did I do wrong here ; http://lpaste.net/145384. I see the output : #{(2 2 3 3)} where I was expecting to see #{(2 3 )} ?
@mccraigmccraig: ah cool, thanks. I’ll see if I can find some better names.
@roberto: oke, back to the book (brave) . I try to solve this one : http://lpaste.net/145385
@roelof: You can use apply
for that. (apply hash-set [1 1 2 2])
is equivalent to (hash-set 1 1 2 2)
.
I mean this one : oke, if I change hash-set to set the numbers are right but reversed : #{3 2}
you can do it with both, one will be a little harder than the other. It is a good exercise to also try it with hash-set
I would prefer set
over apply hash-set
. I was only mentioning apply hash-set
to point out what apply
does.
then this are my solutions (http://lpaste.net/145386) to the exercises on this page : http://www.braveclojure.com/do-things/
I hope I done a good job. Exercise 5 and 6 I skipped , I think I have to learn more about clojure to solve those two
Heck yes it is. Many Clojurians prefer to do it that way, to avoid the cognitive load of an entire framework.
@roelof: It depends on what you mean by “framework”. I find ring itself super convenient.
It’s not heavy at all. Literally, though, it’s a framework - it calls you instead of you calling it.
But it's not a framework, it's just an opinionated set of libraries that are convenient for web apps.
oke, and is there a example for authentication and something like roles. So I can make it work that some people may upload new products and other not. Or guest may look but for buying something you have a account ?
There are a few authentication libraries to choose from. I think that luminus uses buddy. Af far as authorization goes, I don't know. You may have to roll your own. Clojure doesn't have anything like, say, devise, (for Rails).
Friend has some good docs on doing oauth too : https://github.com/ddellacosta/friend-oauth2/wiki
@roelof It’s a breath of fresh air compared to the “framework norm” languages like ruby/python/php/javascript. You can understand everything you’re using as you add things piece by piece
@mj_langford: you mean working with luminus
I mean not needing to work with something like luminus
You can start with “here is ring, let me manually assemble some text to return based on the URI passed in”
and then add a templating library to do templating…then when you’re ready, a routing library
You don’t get 234098 components you don’t understand or need sitting around
http://purlyfunctional.tv sells a course that goes through the layering process
certainly not mandatory, but it was a very quick way for me to learn
the web course was really helpful understanding what ring/compojure/hiccup, etc were all doing
I don’t come from a webdev background, and don’t do it most of the time at work, was pretty good at covering the whole topic’s bottom level
and maybe use this book for web development : https://pragprog.com/book/dswdcloj/web-development-with-clojure
hmm, I have a file suspects in the root of my project but as soon as I do this: (def filename "suspects.csv") and then (slurp filename) I get a message that the file is not found. Where do I have to put the file then. Light Table is now driving me grazy
One thing you can try doing is putting it in resources, and using this: https://clojuredocs.org/clojure.java.io/resource
the root of your project is the right place
do you have a repl going?
@mj_langford: Light table has no repl just a instarepl
I’m Not great with the development on windows story, but I’m assuming you can go “lein repl” in a terminal in the root directory of your project, outside of lighttable
(System/getProperty "user.dir") gives you the current working directory
try it in the repl of that project, could illuminate what is going on if something is going strangely
It’s really interesting to see Rich Hickey using metadata in clojure.zip to make “objects” out of vectors by attaching “methods”.
@mj_langford: I see this output and it looks fine to me : C:\\Users\\rwobb\\Documents\\programming-exercises\\core_functions"
what happens then when you (slurp (str (System/getProperty "user.dir”) “/suspects.csv”))
don’t know what to tell you then, looks like you don’t have a file called suspects.csv in that folder. Perhaps you mispelled it, or have it in the wrong place. sorry I couldn’t be more helpful
Can someone help me with this one : http://lpaste.net/145389
You have a carriage return in your CSV file perhaps?
after 10?
windows has /r/n at the end of lines
unix has /n at the end of lines
this is because you’re on windows
there are two ways to fix this, you can change line 27 to split on the string “\r\n” or you can use a more sophisticated str->int function
or you can swap to https://clojuredocs.org/clojure.string/split-lines
instead if (clojure.string/split string #"\n")
I think this is something @nonrecursive should consider fixing in the book/site. Many professional programmers work on mac or linux now, and little things like this slip through
not fun. Now I see this error : clojure.lang.ExceptionInfo: EOF while reading, starting at line 41 and column 1 :: {:type :reader-exception, :line 41, :column 32}
Moving over to #C053AK3F9 to answer about the EOF error
@alex.nixon: do you care about the end result?
nope, only the side effects
something akin to (run! f (sequence xf vs))
I think what you're getting at there is the same as (sequence xf vs)
I was hoping to avoid building a lazy list
I think I might argue that run! should have an arity which takes a transducer
i mean, from what i understand, transducers shouldn’t really be combined with side effects
transduce
will do it right? So you could make a run-xf! or something on top of that so it doesn’t feel awkward?
noonian: yeah I can write that
swizzard: I'm not sure I feel the same about that, particularly given they're heavily involved in core.async which is built on side effects
np, thanks for offering your thoughts anyway
noob question: how to define a function that returns a function in let
?
as for now, I do straightforward ... (let [coercer ((coerce/coercer User coerce/string-coercion-matcher)))] ...
but it feels wrong
the snippet looks wrong, let requires an even number of forms in the binding vector for one thing
like that
or you mean one more level?
((coerce/coercer User coerce/string-coercion-matcher)))
is taking whatever coerce/coercer
returns (presumably a function) and calling that function with no arguments binding the result to coercer
.
but whether or not that is correct depends on the implementation of coerce/coercer
so I’m not sure if that’s what you want