Fork me on GitHub
#clojure
<
2018-08-22
>
didibus01:08:24

Is there something equivalent to lazy-seq, but which does not do chunking?

didibus01:08:57

I basically want a sequence that gets the next element from a remote server, but I want it to get exactly one element at a time, not in chunk

ilikeOPHeroines02:08:18

Has anyone read Paradigms in AI programming? Would the exercises/knowledge apply over to clojure or no

ilikeOPHeroines02:08:33

I see that on github there are people who did the exercises in clojure

didibus02:08:47

Hum, actually it looks like my problem is either with apply or concat

didibus02:08:58

It seems to always process four elements

bmaddy02:08:31

I'm hoping someone can tell me what the name is of this clojure or clojurescript library I'm trying to remember. I came across it recently (don't remember where) and it has to do with using excel-like formulas in spreadsheets (things like =POW(2, 3)). I believe it was being used so that users could enter these formulas into web apps. Does anyone know what that might be?

didibus02:08:46

I think it was axel-f

bmaddy02:08:54

Yes! That's totally it--thank you!

henrik05:08:48

Is it possible to have a global deps.edn? Stuff that gets merged in every call to clojure.

mping11:08:34

Hi, anybody using funcool/cats around here?

octahedrion11:08:11

@henrik ~/.clojure/deps.edn I think

restenb11:08:49

is there a "better" way of chaining calls to map on a list?

restenb11:08:27

like, currently I'm doing (->> lst (map :thing) (map first) (map :stuff) (map some-fn)) ...

restenb11:08:37

which I guess is fine, but ...

manutter5111:08:02

I believe that’s equivalent to (comp (map :thing) (map first) (map :stuff) (map some-fn) ...) i.e. using transducers.

manutter5111:08:46

Or I should say ((comp (map :thing) (map first) (map :stuff) (map some-fn) ...) lst)

gaverhae11:08:43

You could also go (map (comp some-fn :stuff first :thing)) though the ordering thing may make it confusing

restenb12:08:30

yeah, you'll have to reverse the function calls with comp

restenb12:08:38

still useful if there's lots of repetition though

manutter5112:08:02

The transducers version does not require you to reverse the order (which hurts my brain, but it’s true), and it’s a bit more efficient.

manutter5112:08:35

Just don’t comp transducers and non-transducers in the same comp, or it really hurty-brain.

manutter5112:08:14

the other caveat with transducers is that comp of transducers produces another transducer, so you have to use it in a transducing context like into

urbanslug12:08:55

Which linting tool is most common? eastwood?

urbanslug12:08:57

"Eastwood supports only Clojure on Java, not ClojureScript or Clojure/CLR."

jpmonettas12:08:49

Hello everybody! is there a way to run a app with clojure tool cli from github if it contains java sources? I would like to do clj -Sdeps {:deps {may-app {:git/url "...." :sha "..."}}} -m my-app.main

gaverhae13:08:37

As far as I understand handling Java sources, as in actual source files you want to compile locally, is outside the scope of clj. It focuses on dependency resolution, not build.

jpmonettas16:08:43

yeah imagined that. thanks @U061HGP8C

patrkris12:08:41

Hi everyone. Is there a way to create namespace aliases for use in namespaced keywords without creating a new Clojure namespace? I know that I can use in-ns to create the namespace and then create an alias for that, but is that the idiomatic approach?

dominicm14:08:07

https://clojuredocs.org/clojure.core/create-ns with https://clojuredocs.org/clojure.core/alias clojure/data.xml uses this method to have XML namespaces (which are urls)

jpmonettas12:08:08

you don't need to create a namespace for namespaced keywords

jpmonettas12:08:31

can just do :whatever/keyword

patrkris12:08:36

I know. It’s just the aliasing feature I would like, e.g., to avoid writing a long namespace again and again

Andreas Liljeqvist13:08:23

Running (def a ( "/home/user/file.txt" :encoding "cp850")) and then lsof | grep file.txt I get a whole lot of threads using file.txt

Ben Hammond13:08:24

if I want a function to gain access to the namespace in which it is being declared, I can define something like this

(def my-ns (str *ns*))
(defn namespacify-symbol
  "if the symbol is missing a namespace, lend it ours"
  [s]
  (if (nil? (namespace s))
    (symbol my-ns (str s))
    s))

Ben Hammond13:08:00

is there a nicer way? (I'd like to avoid the specific declaration of my-ns if I can)

Ben Hammond13:08:27

oh I suppose I can use a let statement instead

Ben Hammond13:08:04

(let [my-ns (str *ns*)]
  (defn namespacify-symbol
    "if the symbol is missing a namespace, lend it ours"
    [s]
    (if (nil? (namespace s))
      (symbol my-ns (str s))
      s)))

dominicm13:08:08

I'd be inclined to use (name s) because I think it is closer to your intention, but in practice yours is fine.

👍 1
Ben Hammond15:08:55

you can't do (name *ns*) but you can do (name s)

Ben Hammond15:08:25

cannot do (namespace *ns*) neither which I thought was quite interesting

dominicm15:08:26

I've run into that before, it's a bit annoying

dominicm15:08:17

(.-name *ns*) gets you the name property of a namespace

dominicm15:08:33

or, (.getName *ns*) gives you the symbol, but not string

ben16:08:49

Is there any (easy) way to call FORTRAN code from clojure, or is this a Bad and Dumb Idea?

polymeris16:08:51

It's probably possible via JNI, but not sure if Easy

polymeris16:08:05

That is, clj->java->JNI->C->fortran

ben16:08:46

That sounds pretty grim… So probably out of reach for a relative beginner in clojure?

polymeris16:08:55

Most of the complexity would probably be in the JNI->C part, so not even very accessible for someone experienced in clojure.

polymeris16:08:28

The clj->java part is relatively straightforward, I think

mpenet17:08:12

I did exactly that in the past, clj - java - jni - c - fortran, luckily for me the c part was already written

mpenet17:08:31

JNI is quite easy to use, depending on how large the api you need to cover is. Also depending on your requirements you can prolly get away with jna or better, jnr

mpenet17:08:23

Another idea I was toying with lately is to use luajit for the ffi and fennel-lang for these kind of things, but if you need stuff from java land this is a no go

gigasquid17:08:10

I think you might be able to execute Fortran on Graal

gigasquid17:08:44

so maybe you could do something like that using polyglot Clojure https://github.com/gigasquid/graal-test/blob/master/src/graal_test/core.clj

gigasquid17:08:41

Would be interesting to try 🙂

gaverhae18:08:08

Maybe looking at core.matrix -> clatrix -> jblas -> LAPACK can provide useful insights?

jsa-aerial18:08:03

If that (matrix math on the metal) is what you are looking for, I'd strongly recommend having a look at Neanderthal

ben09:08:48

Wow, thanks everyone - it looks like I have a lot to look through 🙂