This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-16
Channels
- # admin-announcements (3)
- # arachne (9)
- # beginners (10)
- # boot (56)
- # cider (4)
- # cljs-dev (5)
- # cljsjs (4)
- # cljsrn (3)
- # clojure (146)
- # clojure-austin (9)
- # clojure-greece (3)
- # clojure-poland (14)
- # clojure-russia (1)
- # clojure-uk (19)
- # clojurescript (46)
- # cursive (16)
- # datomic (21)
- # emacs (38)
- # events (2)
- # flambo (1)
- # garden (3)
- # hoplon (41)
- # jobs (1)
- # keechma (87)
- # off-topic (2)
- # om (62)
- # om-next (4)
- # other-languages (7)
- # pedestal (6)
- # protorepl (1)
- # reagent (3)
- # rethinkdb (1)
- # ring-swagger (1)
- # rum (3)
- # spacemacs (2)
- # specter (12)
- # test200 (2)
- # untangled (12)
Is there a decent Clojure parser that preserves comments and whitespace? I know that rewrite-clj has one, and that sjacket has one, but I think neither really intend that to be consumed.
@eraserhd: I wrote one custom in cljs, with a custom zipping library - my main goal was to use tools.reader and not custom implementation like clj-rewrite does. But it was never intended to be consumed as a library. Also requires patched tools.reader. Could be interesting for you just for inspiration to see scope of the problem: the main trick was to expose log-source*[1] from tools.reader and then expose it to track whitespace, comments and other “gray matter” [2][3] [1] https://github.com/darwin/tools.reader/commit/321abf7b4242b30c94052c93cdcf5d5d92c7dc38 [2] https://github.com/darwin/plastic/blob/master/src/meld/meld/parser.cljs#L33 [3] https://github.com/darwin/plastic/blob/master/src/meld/meld/tracker.cljs#L28
it is poorly documented, here are some notes: https://github.com/darwin/plastic/blob/master/src/meld/meld/core.cljs
hi all. I'd like to make a java library available to my project. It's not in maven and I've had to compile the .jar myself...
where would I put it to make it available to my Clojure project. (I'm using lein for builds)
@triss Quick and dirty answer: jar xf file.jar
from within your src
or resources
directory.
Longer, cleaner answer: make a new Leiningen project for the Java library, with a project.clj, compile it, and run lein install
, then add it as a dependency of your project.
or with Maven / pom.xml / mvn install
thanks @stuartsierra quick and dirty will do for me today.... jar xf blah.jar
completd with out error... I'll see if I can import it
You might need to restart your REPL process.
There might be a Leiningen plug-in that does effectively the same thing without cluttering your src
dir.
ok this is strange. Emacs knows all about the classes in the JAR now. It autocompletes the class names for me.
@stuartsierra: In the past I've just put jars in my project somewhere and pointed to them in project.clj under :resource-paths
. Anything wrong with that approach?
@plexus: nothing wrong that I know of
(:import [my.classes sub-a sub-b])
works... but when I try to call a static method I get:
@triss Java class names cannot have hyphens.
CompilerException java.lang.NoClassDefFoundError: Could not initialize class org.vamp_plugins.PluginLoader, compiling:(form-init4384086965817994186.clj:47:27)
sorry @stuartsierra that was a an attempted demo. real import statement is:
(:import [org.vamp_plugins
Feature OutputDescriptor ParameterDescriptor Plugin PluginLoader])
dunno
Maybe try @plexus' approach
Hello Clojurians, I wonder how relevant “Clojure Programming” is right now as 4 years have passed after the publication, and perhaps so much has changed in Clojure
@giga: I think it’s stood the test of time pretty well. It’s a good all-round book.
It targets Clojure 1.5 I believe? (I’d have to crack open my copy to check) So it doesn’t cover trandsducers… But I’m not sure there’s much coverage out there of writing transducers in any book (and using the built-in ones can be gleaned from the documentation).
Ah, so it won’t have reducers either...
So transducers, reducers, read conditionals, the new Java API… those are the "big" changes it won’t have.
Not a huge list.
The biggest jump in the books was 1.2 to 1.3 really, since all the 1.2 code was written against monolithic contrib and that changed dramatically in 1.3.
The other changes since 1.4 that would affect code are the cond->
and as->
threading macros, and the various some
-related additions, I guess.
Right now, I’m on two minds - whether should I jump into Web dev(the topic I’m most familiar in programming) with Clojure or continue building Clojure Basics Skills
I’m trying to avoid some framework driven book such as Clojure Web Development Essentials, but I’d like to hear experienced voice towards the topic 🙂
If you have a specific web dev project in mind, that would give you somewhere to practice your Clojure "basics" 🙂
If you want to get up and running quickly with web dev but really want to focus on honing your Clojure skills, try my FW/1 "framework" — really just a bundle of Selmer for view templates, Ring for the core, and a dynamic routing system (http://domain.com/foo/bar calls (bar …)
in controllers.foo
namespace).
We’re using it at work because it means we don’t have to declare routes in code, but we can add mapped routes later if we want (as data).
ah ok.. the .jar I'm using interfaces some C++ via JNI.... I've got a library file called vamp-jni.so
that needs to be on the "Java load path"
@triss you'll need something like :jvm-opts ["-Djava.library.path=...."]
in your project.clj
Hi guys! I really need some help because I have no idea how to do that: I have a col : [ {:price 25} {:price 50} {:price 15} ] and I need to take 65 from this price col. The expected result is: [ {:price 0} {:price 10} {:price 15} ].
got it
could be done easily with loop / recur, but I am waiting if someone comes up with a different solution
there is one project where I need to do this with roll over interests, but it is in F#
(reduce (fn [rest,price] (do (conj {:price (abs (- price rest))} (- rest price) [] ) [ {:price 25} {:price 50} {:price 15} ] )
somethin like this ?
using reduce to recreate a map an keep your (abs (- price rest)) "price" up to date ????
(abs (- price rest)) => wont work ... :(]
you need a conditional ... 😕
yeah, i would vote for loop/recur. for me it’s the readability
val_waeselynck: hey, there, not sure if this changes anything, but the api to an external service requires that I log in to grab a session key. Then, I can use their api, attaching the session key to all my requests.
val_waeselynck: would I still use something like redis for that?
wouldn’t that be a bit overkill since it’d used for storing just one session key?
it’d be used*
@thug.nasty: a Redis instance is not that hard to manage 🙂
sure, but that’s not the problem
the question is just what storage characteristics you need for that key
i just need to hold on to it
should it be persistent?
for how long?
it might change
maybe you can just store it in your UI then
the UI doesn’t need it
it’s backend only
and the backend doesn't have a database already?
it has a database
but I am using an external service
a third-party service
that requires that I acquire a session key
before I can utilize the service
there may be a scenario where the session expires and I need to get a new key
i wouldn’t need to use redis for anything else
so I figured it’d be overkill for this case
ah, I just did something like that with something I’m doing for a friend on the side. They are migrating from quickbase to something else. Quickbase requires that you authenticate through their api and get a key that you then use to make queries. I created a component that when started, connects to quickbase, authenticates, and stores the key inside the component. Any other part of my app that needs that key (which in this case I limited to one component), just needs to specify a dependency on QuickbaseComponent
i’m not familiar with components
what do you mean by components?
you don’t need component to do what you want, I just feel more comfortable using that. You can probably use an some sort of global atom.
ah, i’ll check that out, regardless. thanks 🙂
zane: great. thanks!
@thug.nasty: sorry, was away. If it's okay to request a new key frequently, you can use an in-memory cache, which you can indeed back by an atom, or Google Guava for example
@val_waeselynck: np. I'll check that out too. Thanks :)
I'm aware that leiningen will evaluate for things like environment variables in profiles.clj but I'm curious how to do so in project.clj. Is it the same? #=(eval (System/getenv "ci.compile-path"))
If I want to construct a strings, then like #=(eval (str (System/getenv "someurl") "/segment"))
tom: the easier option is to use unquote or unquote-splicing
~(System/getenv "ci.compile-path")
defproject is a macro, and will unquote / unquote-splice
(read-string "(str " \"I want qutation marks here \"" )")
So my question is, how do I double escape qutation marks, \\" text \\" tries to resolve to symbol 😕
to be more accurate, this is excacly what Im trying to escape
((eval (read-string "(fn [index aindex] (apply vector ((fn [index aindex] (map #(str \"i \"\"sweet21\"\" 0 5 (get [-20 -22 -21] (mod aindex 3)) \" % \" 0 0 \" ) (get [[440]] (mod index 1) ))) index aindex)))")) 0 0)
@noisesmith: you should be able to guess what I'm doing here 😛
"sweet21" needs to be quoted.
"foo \"bar\""
yes, but I guess in my case, read-string
and str
seemingly will resolve escaped quotation marks...
"\"with \\\"quotation marks\\\"\""
reads as "with \"quotation marks\""
First you escape the backslash as \\
, then escape the quotation mark as \"
yup, this did the trick, I think I would have had to spend another half an hour to figure it out. Yes, escaping the backslash I did not think about. Thanks!
you're welcome
hello all. um. I still think I should ask this quick question: is it ok in clojure if I start wrapping all my functions that works with external world and can throw exceptions into some either datastructure? I can go erlang style with [:ok ..] and [:error ..] return values, or maybe there is some other way? will it hurt readability and/or understandability in the team? it's not the built-in thing after all
thanks jr... got it going... biut only with a $
: [javax.sound.sampled.AudioFormat$Encoding]
jr: that's the jvm's way of making inner classes actually
it has nothing to do with namespaces
when you make an inner class, what is actually created is a regular class with a $ in the name