This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-07
Channels
- # aleph (19)
- # aws (1)
- # beginners (75)
- # boot (28)
- # cider (1)
- # cljs-dev (12)
- # cljsrn (20)
- # clojure (350)
- # clojure-argentina (1)
- # clojure-chicago (2)
- # clojure-dev (2)
- # clojure-russia (5)
- # clojure-spec (2)
- # clojure-uk (14)
- # clojure-ukraine (3)
- # clojurescript (68)
- # component (87)
- # core-async (25)
- # core-logic (13)
- # cursive (4)
- # data-science (72)
- # datascript (59)
- # datomic (15)
- # defnpodcast (7)
- # emacs (33)
- # hoplon (5)
- # immutant (73)
- # jobs (21)
- # klipse (6)
- # lumo (14)
- # off-topic (26)
- # om (23)
- # onyx (6)
- # parinfer (37)
- # protorepl (4)
- # re-frame (13)
- # ring (2)
- # rum (3)
- # spacemacs (2)
- # specter (22)
- # sql (47)
- # uncomplicate (10)
- # unrepl (79)
- # untangled (66)
- # vim (47)
- # yada (17)
some other options to consider: JavaFX (there are a couple Clojure wrappers), Swing (Seesaw), Vaadin (functional-vaadin)
I have a list of maps:
({:name "cash", :newamount 12500/3} {:name "cash", :newamount 500} {:name "vanguard", :newamount 500} {:name "house", :newamount 0})
and for each :name
that’s the same, i’d like to add the :newamount
s together. so the output should be
({:name "cash", :newamount 14000/3} {:name "vanguard", :newamount 500} {:name "house", :newamount 0})
i’ve been futzing around with merge
and merge-with
and i can’t get it right. i also have a suspicion i should be using reduce
.
something like ben ashford’s group-by-better
: http://benashford.github.io/blog/2014/12/27/group-by-and-transducers/@mfm I think you want to group-by :name and then reduce each group
Look at this example for how group-by works https://clojuredocs.org/clojure.core/group-by#example-542692cdc026201cdc326cd4
Guys, could you help me how to learn easy .. integrate Java SDK to Clojure? (I don’t have java dev background)
@sb what do you mean by integrate?
@sb Accessing Java from Clojure is really nice. You can find good starting points here https://clojure.org/reference/java_interop and here http://www.braveclojure.com/java/
thanks @hansen-pansen I see that will be more time than I thought to understand fully. I will test it.
@sb, you need to make sure that Clojure can see Java. You should be able to install Java SDK from sun and then it should be available on your PATH. The Clojure should be able to see it (java) when you run Clojure.
john: this reply makes no sense to me at all. Clojure is a java library that creates and executes byte code, if clojure is running it has access to java directly.
When I hear sb say "integrate Java SDK to Clojure," I imagine he or she has downloaded the clojure.jar (or something similar) and has now also downloaded the Java SDK and now he or she doesn't know how to proceed.
But in general, I was thinking perhaps sb wasn't even as far along as thinking about interop. Hard to tell though.
So I need to download the java things and drop in the project.clj the path and I try to drop to core.clj .. like import (?)
That is the main question how to understand the java specification and implement in clojure
You want a solution where you can deploy both your clojure app and it's java dependency to your users?
@sb http://www.braveclojure.com/ is popular
the easier way to do it is to make a Skype SDK project and add clojure.jar as a dep
because clojure works standalone, and it’s an easy lib to use
I’d skip lein for this actually, just use clojure.jar as a dep in your java project
it’s a lot less headache than using skype from lein would be
at least a little - it’s easy to put clojure into a java project and do most of the work into clojure code though
this shows how to use clojure from java, it’s very easy - just use Var to get require, and require to get your code https://clojure.org/reference/java_interop#_calling_clojure_from_java
Ok I try to do, learn this @noisesmith
Thanks @noisesmith @U050PJ2EU
So if I want a function to run continuously in another thread until I stop it, is future and future-cancel the proper way to do this, or is there another more proper way?
@fingertoe if your continuous operation is in the shape of a loop, you should check for a cancellation signal before processing the next item
@fingertoe future cancellation is not guaranteed... you can't really stop threads in java anymore, you can Thread.interrupt() them tho
@vitruvia all the args but the last return functions
It's best to use a queue and check for a sentinel STOP/POISON item, or read a shared global stop flag / core.async channel
@ghadi agreed with the caveat that sleep and IO are both interruptable, so in practice I’ve had good luck stopping threads from the outside as long as they stop for io or call Thread/sleep. This comes up in particular for me when using core.async thread to run something that I might want to consider timed out if the IO takes too long
no, I’m cancelling the thread, and counting on it calling a cancellable method
(well, future task, not thread etc.)
👌 future.cancel(mayInterrupt) <- will interrupt a thread in interruptible methods (I/O, sleep etc.)
right
oh - even if called on something outside a go block?
@noisesmith I'm not sure what you mean. more
is supposed to be a list of predicates and other-preds
should take these predicates and turn them into functions according to its definiton
but your reduce returns either x or nil
nil isn’t a function, and I’m not certain x is a function?
the reduce function (that is, other-preds
)should have another function inside
in order to return a function
but I don't want to return a function. I want to return x
if the value of pred is true
but what your reduce returns is what your function returns
all the other branches of the function return functions, but your reduce returns nil or x
x may be callable, nil is not
@gonewest818 I have, because of work requirements Electron is out. Not familiar with Reagent. I am hoping to persuade management to use a Web UI, but that won't be for this iteration
@alexmiller Thanks, will check out Vaadin. What I have working so far is straight JavaFX, but would love more of a wrapper.
fwiw Rich likes Vaadim and the Datomic Console is written with it
Vaadim or https://vaadin.com/home?
i note in passing that vaadin's website, like datomic's, is quite mobile-unfriendly. :(
also Vaadin produces a web application which doesn’t seem to meet the requirement stated earlier… ?