This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-07
Channels
Hello, I want to use core.match, but I want to load the patterns from a file or db, is there a clean way to do it ?
it's exactly the same as in the patterns, for example ["foo" "bar" _ 1] could be one entry, where the first three would match to the value 1, makes sense ?
@kongeor @socksy there's also clojure.edn/read|read-string which is safer if you are dealing with input from uncertain sources
I +1 zoldar’s recommendation, can’t think of any situation where you want to have arbitrary logic in an external matching specification
@socksy @zoldar: Thanks, my first approach was to use edn/read-string because all my input can be expressed in edn. Well, that's the simple part. Then I have to restructure the data to format it for core.match, right? That has to be done with a macro?
but you said it’s the exactly the same as the patterns? What’s the exact format of the match? Maybe give two/three lines
@kongeor: yes, you will have to use macro to match the pattern with core.match, but if pattern form is close to the match body format, it shouldn't be that much of a hassle.
you need to have something around each match line, otherwise the edn reader will disregard the match result
what I actually want to do is to construct dynamically (based on a edn file) and then to pass through it a bunch of data
user=> (def match-input (read-string "([1 2] \"geronimo\")"))
#'user/match-input
user=> (defn mymatch [[row val]] `(match [1 2] ~(identity row) ~val))
#'user/mymatch
user=> (eval (mymatch match-input))
but couldn’t work out how to define a macro, given it expects the [] form around the pattern row (that’s the left hand side of each match)
@socksy: I created a small repo, take a look here https://github.com/kongeor/dynamic-matching/blob/master/src/dynamic_matching/core.clj
The problem is that when I pass the data from the edn file it fails. I guess I'm missing something about the time the macro expands the code ...
@danielcompton: My understanding is that Leiningen does not read ~/.m2/settings.xml
. Instead, passwords have to be placed in ~/.lein/profiles.clj
Is this a typo on clojuredocs? (clojure.core/lower-case "FOO")
https://clojuredocs.org/clojure.string
@alexmiller: ok, I'll report it
how do i make leiningen discover tools.jar (for com.sun.tools.*
), currently compilation fails
Exception in thread "main" java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine, compiling:(core.clj:1:1)
works fine in repl though 😕I tried adding following to profiles.clj
:resource-paths [(format "file:///%s/../lib/tools.jar" (System/getProperty "java.home"))]
but fails with
java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: clojure.lang.PersistentList
r4um: I think you need to switch to macro land to make that work in a leiningen profile
@r4um: yes, unquote should do it, something like :resource-paths [~(format "file:///%s/../lib/tools.jar" (System/getProperty "java.home"))]
@ordnungswidrig: @nberger: thanks! unqoute worked.
michaeldrogalis: just a quick sanity check - does it make sense to have two separate projects that would share an onyx catalog via a lib that both require, and then interact via onyx? would it make more sense to send requests via eg. zookeeper?
@michaeldrogalis: retagging with @ because I have no idea how this crazy slack thing works really.
@noisesmith: there's a #C051WKSP3 also. Might try there.
oh, cool
Yeah, @noisesmith. Will answer in #C051WKSP3
what's the best way to run a function once every minute?
@mikecarter: ScheduledThreadPoolExecutor
@mikecarter: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html#scheduleAtFixedRate(java.lang.Runnable,%20long,%20long,%20java.util.concurrent.TimeUnit)
thanks @stuartsierra , @ragge!
You're welcome.
does anyone know how to check whether a mvn package is installed in ~/.m2
in leiningen, else I want to run a script to install it?
@denik leiningen will check for you and will install if it doesn't exist in the local repo
@bostonaholic the problem is its not on climate (and can't be due to licensing issues) so I have to manually install it through mvn based on a local jar
so we use :repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
and have a maven_repository
directory in the project for those types
so you could do ./maven_repository/com/example/project/1.0.0/project-1.0.0.jar
etc.
but if you have the jar in the correct place in ~/.m2
then leiningen should be able to find it if you put it in :dependencies
we use the maven_repository
trick b/c we have to check that particular jar into git
yep, @bostonaholic the idea is to build a template that install this one dep locally once
It’s a one time thing, so I will write a separate script to install it in .m2
and skip the check in lein
but for your project to use it, it will need to be in the classpath. and adding it to :dependencies
in your project.clj
is how'd you do that
maybe I'm not fully understanding what or why you're trying to accomplish
@denik: another option is to use https://github.com/technomancy/s3-wagon-private
Odd that not-any?
is in core but any?
is not. I understand that it’s close to some
(def any? (comp boolean some))
, but it’s a slightly confusing inconsistency.
That wouldn't work for the evil nil case.
(any? #(nil? %) [nil]) => false
@jwm @joshg This would probably work:
clojure
(defn any? [f coll]
(cond
(empty? coll) false
(f (first coll)) true
:else (recur f (rest coll))))
there is a stackoverflow on this, http://stackoverflow.com/questions/9491400/why-does-clojure-not-have-an-any-or-any-pred-function
Did I just find a bug in Clojure?
user=> (not-any? nil? [nil])
false
Never mind, that's correct.
Sorry, I had a misunderstanding of what some
returns.