This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # bangalore-clj (1)
- # beginners (88)
- # calva (1)
- # cljdoc (1)
- # cljs-dev (1)
- # cljsrn (2)
- # clojure (88)
- # clojure-berlin (2)
- # clojure-europe (2)
- # clojure-india (1)
- # clojure-spec (3)
- # clojure-uk (3)
- # clojurescript (9)
- # clojureverse-ops (4)
- # clojutre (2)
- # cursive (3)
- # data-science (1)
- # emacs (3)
- # fulcro (12)
- # pathom (4)
- # reitit (1)
- # rum (10)
- # shadow-cljs (9)
- # spacemacs (11)
- # sql (7)
- # tools-deps (16)
- # vim (14)
- # xtdb (3)
- # yada (1)
Hi. Am I correct to claim that clojure is more about [data, its immutability, shape of data (closest term I could find is data driven design)] than about [functional programming]? And that its just FP aspects lend themselves naturally to data management?
@bhootjb You'll probably get a lot of different opinions on that. I think it certainly emphasizes data-driven design but it is definitely a general purpose language. I think the immutability and the functional programming contribute to it's ability to work effectively with data.
Just today I'd been looking at an enhancement request product management had requested and initially I saw it as a process change and it was hard to solve -- but then I took a step back and viewed it as a data-driven change and it became easy, specifically because of immutability and the ability to pass "modified" versions of the control data structure around without affecting other threads (and viewing functions as "data").
Nice! While data orientation is integral to FP, I found that the popular lens of FP has a lot of baggage - strong typing, monads, what not. However, starting out from the shape of data and immutability, other concepts seem to fall in place around that. This was my feeling with redux. It has tons of terminologies, enough to scare a beginner away. But looking at the core of redux as - transition of shape of state/data from one snapshot to another over time - triggered by actions, rest of the concepts then simply enable/facilitate this transition. This thought process is what led me to clojure actually. Only now has it become clear. My initial journey was from the lens of FP oriented language, and led me to Haskell. That jump was stupid. But this data driven perspective seems much more malleable, and it led me to clojure. I hope my beginner's ramblings make some sense haha.
I’m looking for a function that filters and returns two collections - the filter “successes” in one and the “failures” in another. Easy enough to write, but seems common enough that I figure I am just missing it.
What is the best way / easiest way to cycle through a list with an offset? I came up with a kinda overcomplicated solution mapping over the list with a mod calc. Curious to hear your suggestions.
Btw.: my solution looks like this:
(defn getNoteVals [notes offset] (for [n (range (count notes))] (nth notes (mod (+ offset n) (count notes)))))
maybe more idiomatic
(defn getNoteVals [notes offset] (->> (cycle notes) (drop offset) (take (count notes))))
I have a stupid problem again. My repl used to load dependencies automatically, and now it doesn't. Is there any way how to load all clojure files into the repl?
Perhaps I also can run some function automatically on repl start? I only found docs how to set this globally, but not in project.clj
@hoertlehner not quite sure what you mean -- can you give a more concrete example with details of how you have things set up?
I use leiningen. I start the repl with "lein repl". Now for whatever reason the namespaces in my project no longer get loaded.
So I want to do a very simple startup-function that gets started automatically when I run "lein repl"
Clojure repl loads user namespace when starting the process. You can require all namespace that you need on start here. Just create the file user.clj somewhere inside of the root of your classpath (usually src/user.clj or dev/user.clj if you don't want to provide this file as a part of published artifact) declare namespace as (ns user (:require %your dependecies%)) and restart your repl
There is a more complete guide for you https://dev.solita.fi/2014/03/18/pimp-my-repl.html
Your namespaces or external libraries?
Probably your dev classpath is not configured same way as the one used for jar building
I can recommend to check the changes in project.clj happens since last working version
But this is not a silver bullet usually. Ultimate fix - read more about how classpath is constructed by leiningen and eventually everything will be clear)
those dependencies that are not loaded dont load sub dependencies when I do it manually.
that's very strange behavior. if you
(require [the.ns]) it should load any of the dependencies of the.ns
This might be better for #java but I feel pretty beginnery when working with it so--- I happen to have two MIDI devices, and they don't talk to each other; one is on channel 8, and the other is on 10. I figure, hey, put a computer in the middle. So now I'm trying to understand the Kingdom of javax.sound.midi Nouns...
To get started, I'm trying to communicate with my sampler. For now I want to be able to read when I trigger a message with the little drum pads, because I figure, if I can read a MIDI message as data, I can figure out what to do with it
(class (.getTransmitter finger-drums)) => com.sun.media.sound.MidiInDevice$MidiInTransmitter
so here's where I'm stuck: I figured, there must be a way to read whatever the transmitter is sending
So I was hoping to construct a new
Receiver, tell it that its only job is to do some kind of like, println callback when it sees a message, and set it to be the receiver of
so I guess I have a question, "how can I get data off this transmitter", and a metaquestion, "how can I get better at learning to clojurify webs of Java objects"
I'm hoping that if I put in the work to understand these interfaces then I'll have a working instrument by, oh, May 😆
$ indicates a nested class.
"It is a way of logically grouping classes that are only used in one place"... fair enough, that makes sense
It's a subclass I believe?
On my phone -- hard to lookup docs!
I am not doing great at finding the right docs! I was hoping that
javadoc would direct me but I end up at a google search result with allinurl:com/sun/media/sound etc
MidiInTransmitter != MidiDeviceTransmitter... this is what I meant by, I'm mired in nouns
You need to create a receiver object (that will process events) and then call
.setReceiver on that transmitter object to register it.
The transmitter will call
.send on your receiver object for each midi event
https://docs.oracle.com/javase/tutorial/sound/MIDI-messages.html seeeems to suggest, the way to get a receiver from a
but a receiver that is not associated with a device -- it's just something to examine MIDI events to learn what's in them... dunno if that's possible
(I'm just trying to avoid having to understand two devices at once, since I barely know what's happening here)
I don't have any midi devices to test this with, but in Clojure you will
javax.sound.midi.Receiver and implement the
Attach that reified object as a receiver on the transmitter you got from your midi device.
untested, off the top of my head.
(.. device getTransmitter (setReceiver (reify javax.sound.midi.Receiver (close [this]) (send [this message stamp] ... (.getMessage message) ...))))
"something like" is way better than what I had... thanks Sean, will report back after some fiddlin' (so to speak)
.getMessage returns a byte array, FYI.
Yay! Midi event unlocked! 🙂