beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
2021-06-03T00:11:37.301300Z

Is there some way to get a continuous range (range of floats) instead of a range of integers?

2021-06-03T00:14:07.302Z

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

dpsutton 2021-06-03T00:24:52.302200Z

(range 0 1 0.1)

2021-06-03T00:41:46.303700Z

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”

2021-06-03T00:49:59.305Z

Alternatively, I could specify a very small interval and also have a function that would round any values to the accepted interval

dpsutton 2021-06-03T00:51:02.305200Z

a predicate satisfies that.

dpsutton 2021-06-03T00:51:22.305700Z

not sure what your requirements are, but enumerating lots of floating points sounds weird for those purposes

dpsutton 2021-06-03T00:51:40.306100Z

#(<= -1 % 1) or something like that

2021-06-03T01:50:53.306400Z

Ooooh that’s good

Martyna Miśkowiec 2021-06-03T12:01:20.309800Z

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!

Juλian (he/him) 2021-06-03T12:36:39.310200Z

you're just running clj without arguments, right? which version are you using and which Java version?

Martyna Miśkowiec 2021-06-03T12:42:54.310400Z

it's java 8, and clojure 1.10.3

Martyna Miśkowiec 2021-06-03T12:43:19.310600Z

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

ghadi 2021-06-03T12:55:31.311400Z

How was clojure installed?

Martyna Miśkowiec 2021-06-03T12:56:29.311600Z

https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows with this

seancorfield 2021-06-03T16:03:39.311900Z

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.

Erik B Good 2021-06-03T21:36:51.314100Z

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?

2021-06-04T17:37:59.336400Z

the one (obvious?) gotcha with sets as predicates is #{false nil} - for those values you need contains?

dpsutton 2021-06-03T21:38:18.314200Z

can you explain what a proper boolean expression is?

alexmiller 2021-06-03T21:42:00.314500Z

Clojure sets are functions that can be used to check inclusion

alexmiller 2021-06-03T21:42:30.314700Z

(#{1 2 3 4 5} 1)

alexmiller 2021-06-03T21:43:21.314900Z

or (contains? #{1 2 3 4 5} 1) if that reads better for you

alexmiller 2021-06-03T21:43:57.315100Z

it will also return a boolean rather than a logical true value (which is generally true of any predicate that ends in ?)

alexmiller 2021-06-03T21:45:01.315300Z

boolean is a useful function to convert a logically true value (anything but nil or false) to an actual boolean value

Erik B Good 2021-06-03T21:45:18.315500Z

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

alexmiller 2021-06-03T21:45:49.315700Z

I assume you're aware of or and and

dpsutton 2021-06-03T21:46:05.315900Z

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

dpsutton 2021-06-03T21:46:52.316100Z

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)))

alexmiller 2021-06-03T21:47:03.316300Z

these are macros (to do short-circuiting of eval) but can be turned into functions by wrapping in #( ) (with eager eval)

Erik B Good 2021-06-03T21:47:30.316500Z

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

dpsutton 2021-06-03T21:48:51.316800Z

there's also (if (<= 2 x 4) ...) that could possibly work depending on the domain (ie, floats aren't going through)

yuhan 2021-06-03T23:35:15.317100Z

you could also do (some #(= x %) [1 2 3]) which can be generalised beyond equality checks

sova-soars-the-sora 2021-06-03T23:50:30.318Z

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?

seancorfield 2021-06-03T23:52:29.318100Z

JS should be served with a MIME type of text/javascript, not text/html.

sova-soars-the-sora 2021-06-03T23:53:05.318300Z

Right... I tried adding type="text/javascript" to the <script> tag but it's still a porblam

seancorfield 2021-06-03T23:53:23.318500Z

What is serving up that JS file? That’s where the problem is.

sova-soars-the-sora 2021-06-03T23:54:34.318700Z

Hmm. Well other JS files seem to work fine from the same server..

seancorfield 2021-06-03T23:55:33.318900Z

Use curl -I &lt;url of JS file&gt; to see what the server is sending back.

sova-soars-the-sora 2021-06-03T23:58:30.319100Z

Well that's weird. my /img/ directory works fine through the CDN but my /js/ directory does not