Fork me on GitHub
#clojure
<
2017-10-31
>
qqq00:10:29

@noisesmith @smith.adriane: I forgot to mention, this is a *.cljc file, so I need jvm + js // I guess I should now look into js regex libraries 🙂

qqq00:10:37

re-find has been great so far in that it works in both

noisesmith00:10:23

@qqq also double check if subs is actually a problem - it should be cheap (on the jvm at least) since java strings are immutable

qqq00:10:31

@noisesmith: some-> is precisely what I need -- thanks

qqq00:10:48

though it appears that example can besimplified to (some-> x f)

noisesmith00:10:00

I like to use parens with arrow macros, it's a personal style preference

leonoel09:10:45

Hi, is there a name for the common design pattern of letting an HOF accept extra arguments that will be applied to the given function, e.g swap! or update ?

pesterhazy11:10:37

The succession model is a term I've heard

bronsa11:10:19

that has more to do with describing behaviour than api

beoliver12:10:36

if I have a local jar file, how can I include it in a project? i.e where should the jar be located and what do I need to add to the project file? (lein 2)

beoliver13:10:15

Yeah, I just wasnt sure if 2011 was out of date...

slipset13:10:12

Playing around with clj, so I needed to figure out how it works, so I did

slipset13:10:17

14:27 $ clj --help
Usage: java -cp clojure.jar clojure.main [init-opt*] [main-opt] [arg*]

slipset13:10:14

I might understand why clj --help mentions java, but I'd expect it to have a more specific help message?

beoliver13:10:40

Is it really so convoluted to add a local jar to a project?

josh_tackett14:10:42

Does anyone familiar with the salesforce API, know what would happen if I have push topic's set up to sync salesforce data to a standalone db, then a user's permissions change and the user is now long has access to a specific record, would the push topic send a delete update for the request that the user can no longer view?

mbjarland14:10:08

A noob question: is it possible to make a http HEAD request in clojure without reverting to javaland (HttpURLConnection) or pulling in a third party dependency?

mpenet14:10:22

clojure.core has no http client unless you count slurp as one, and slurp doesn't support http methods options

mpenet14:10:48

so yeah, interop or clj-http&co

qqq14:10:44

I find myself writing a lot of code of the form {:tag kw kw data ... other attribs ... } for ecample {:tag :pat :pat .... :name .... } thi seems a bit redundant

devrandomguy16:10:04

Good morning 🙂 Is anyone here familiar with Neanderthal? I'm trying to find some missing constants that are required in order to run the hello-world example. (require '[uncomplicate.clojurecl.core :as uc]) from a repl in the example project gives me a CompilerException java.lang.Exception: No namespace: uncomplicate.clojurecl.constants, compiling:(uncomplicate/clojurecl/core.clj:1:1). There is no constants namespace defined anywhere in the Neanderthal repo, and I can't find a repo in the Uncomplicate org that looks like it might have those constants.

lovuikeng16:10:07

Obviously @devrandomguy you haven't got the correct setup to use neanderthal http://neanderthal.uncomplicate.org/articles/getting_started.html#installation ClojureCL (OpenCL) not installed correct

lovuikeng16:10:52

you might like to try #uncomplicate

devrandomguy17:10:29

Maybe I should go over the opencl install again via the Neandertal instructions. I already have webcl working in Firefox, and opencl working from Python.

devrandomguy17:10:39

Thanks for the room link, I almost missed that

qqq17:10:53

is there a good word for 'compute a bunch of auxiliary / derived data for caching purposes' ? (informatically theoretically, it adds nothing new, but it precomputes a bunch of lookup tables / caches)

noisesmith17:10:36

it’s similar to how dynamic programming works, right? - organizing things so you can save and reuse partial calculations

qqq17:10:11

'dynamic programming' is a very specific class of algorithms; where you save computation by remembering it in my case, I'm pre-building lookup tables -- it's not quite the same

qqq17:10:18

best word I have so far, is 'prep'

noisesmith17:10:58

any reason you aren’t using memoize?

qqq17:10:47

err, so I have this structure which represents the 'precedence of each operator'

qqq17:10:12

so it's something like: [[:right "^"] [:left "*" "/"] [:left "+" "-"]]

qqq17:10:47

now, given two ops, I want to know which has a higher precedence .. so I need to 'invert' the above vector of vectors, and cache the results, to get something like: ^ -> 3 * -> 2 / -> 2 + -> 1 - -> 1

qqq17:10:09

so I'm literally precomputing a map

qqq17:10:41

I'm not particularly happy with 'prep', but it's the best word I can think of

noisesmith18:10:17

why generalize it, why not just call it “build-precedence-map” or something mundane like that

noisesmith18:10:25

do you anticipate this being a common type of task?

qqq18:10:48

1. why do you believe i'm trying to 'generalize' it? 2. 'build-inverse-precedence-map' is perfectly valid, but I was hoping for a shorter word

qqq18:10:13

I'm not trying to 'write a more general function', I'm literally looking for a shorter func name.

dpsutton18:10:29

tough if we don't know exactly what it returns and how you'll use it. If it just returns -1,0,1, compare-by-precedence. If it returns the lower of the two lower-precedence, if it returns a vector of the two ops sorted, sort-be-precedence. If it returns a map that allows you to lookup by operator token then make-precedence-map

qqq18:10:10

ah, I see, I should have been clearer on input/output

input:
{:tag :grammar
...
:precs [[:right "^"] [:left "*" "/"] [:left "+" "-"]]
}

output
add a field
:inv-precs { "^" [3 :right] "*" [2 :left] "/" [2 :left] "+" [1 :left] "-" [1 :left]]

joshkh18:10:24

i'm getting a compilation error in 1.9.0-beta3: Caused by: java.lang.ClassNotFoundException: clojure.pprint i definitely see it in the source/tests, and it's basically a new/empty project. any idea what i'm doing wrong?

seancorfield18:10:37

@joshkh How did you create the project? Have you edited it at all? What command are you using that produces that error? What does the source look like that it is complaining about?

joshkh18:10:38

i used the lein-re-frame template and added just a few deps. you have a good point though... i'll start with a barebones project and rule out any weird dependency problems first.

noisesmith18:10:05

sounds like some code was assuming clojure.pprint is loaded on startup (a bad assumption)

joshkh18:10:34

dumb question i know, but why is that a bad assumption?

noisesmith18:10:58

there’s some tooling which requires clojure.pprint, that often runs on startup, but it’s not something you can count on

noisesmith18:10:12

if you use a namespace, you should explicitly require it, even if it comes with clojure.core

joshkh18:10:25

ahh okay, thank you

noisesmith18:10:04

even for namespaces like http://clojure.java.io that are loaded by clojure.core itself, there’s no explicit promise that will be the case with the next clojure release, so it’s better to require it if you access it

joshkh19:10:06

got it 🙂

joshkh19:10:26

(by the way, that was exactly the problem)