Is there some way to get a continuous range (range of floats) instead of a range of integers?
I’m trying to create a schema for a data structure and say that -1 to 1 are the range of acceptable values for a valence
(range 0 1 0.1)
Hmm so that’s another discrete range with a small increment. Is it possible to get a continuous range? I want to say “This value can be any possible value between -1 and 1”
Alternatively, I could specify a very small interval and also have a function that would round any values to the accepted interval
a predicate satisfies that.
not sure what your requirements are, but enumerating lots of floating points sounds weird for those purposes
#(<= -1 % 1)
or something like that
Ooooh that’s good
Hey, i'm very-very new to clojure, and i'm having issues installing it on windows. Clj -h works just fine, but when i try to run a repl i'm getting 'Error: Could not find or load main class clojure.main'. Any ideas? Any help really appreciated!
you're just running clj
without arguments, right? which version are you using and which Java version?
it's java 8, and clojure 1.10.3
also, when i run ' java -cp .\clojure-tools-1.10.3.855.jar clojure.main ' directly on the jar it starts REPL with no issue
How was clojure installed?
https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows with this
Try the #clj-on-windows channel if you’re still stuck @miskowiec.martyna — folks there are pretty dedicated to getting Windows folks up and running with either the Powershell install or the Scoop package manager.
Hello, I was wondering if there was a guide somewhere to write proper boolean expressions. I am a bit surprised that there is no IN operator (similar to SQL), I was also wondering if there was any way of writing cleanly a bunch of OR expressions.. Any one have a blogpost or tutorial on some advanced conditional logic features of clojure?
the one (obvious?) gotcha with sets as predicates is #{false nil}
- for those values you need contains?
can you explain what a proper boolean expression is?
Clojure sets are functions that can be used to check inclusion
(#{1 2 3 4 5} 1)
or (contains? #{1 2 3 4 5} 1)
if that reads better for you
it will also return a boolean rather than a logical true value (which is generally true of any predicate that ends in ?
)
boolean
is a useful function to convert a logically true value (anything but nil
or false
) to an actual boolean value
What I meant by proper boolean expressions is complex valid boolean expressions. @alexmiller that helps yeah I will make up for many OR by using this set notation. Thank you very much
I assume you're aware of or
and and
if you have an example of a boolean expression from another language i can help you translate it. but it's largely gonna be a 1-1 infix to prefix translation
here's an example from our codebase that i'm looking at right now
(when (and (send-email-on-first-login-from-new-device)
(first-login-on-this-device? login-history)
(not (first-login-ever? login-history)))
these are macros (to do short-circuiting of eval) but can be turned into functions by wrapping in #( )
(with eager eval)
for instance let's say I had if x ==2 or x == 3 or x ==4. In python I could write if x in (2, 3 ,4) instead. Now I can use @alexmiller to write (#{2 3 4} x) which looks good
there's also (if (<= 2 x 4) ...)
that could possibly work depending on the domain (ie, floats aren't going through)
you could also do (some #(= x %) [1 2 3])
which can be generalised beyond equality checks
The resource from “.../js/jquery.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff) I have not run into this problem before, I don't know why the javascript is not loading, firfeox seems to be expecting text/html ... any thoughts?
JS should be served with a MIME type of text/javascript
, not text/html
.
Right... I tried adding type="text/javascript" to the <script> tag but it's still a porblam
What is serving up that JS file? That’s where the problem is.
Hmm. Well other JS files seem to work fine from the same server..
Use curl -I <url of JS file>
to see what the server is sending back.
Well that's weird. my /img/ directory works fine through the CDN but my /js/ directory does not