This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-10
Channels
- # announcements (9)
- # aws (11)
- # babashka (37)
- # beginners (97)
- # biff (2)
- # calva (73)
- # clj-kondo (17)
- # cljfx (3)
- # clojure (89)
- # clojure-europe (45)
- # clojure-norway (12)
- # clojurescript (17)
- # datahike (8)
- # datomic (13)
- # deps-new (4)
- # figwheel-main (1)
- # graalvm (2)
- # hyperfiddle (8)
- # introduce-yourself (6)
- # leiningen (38)
- # lsp (57)
- # malli (13)
- # nbb (46)
- # off-topic (40)
- # pathom (3)
- # polylith (8)
- # rum (4)
- # shadow-cljs (14)
- # spacemacs (1)
- # sql (11)
- # xtdb (10)
what would have to be installed for it to work. Is it better to just avoid it? Basically, I like test.check and would like to use it but seems like too much complication, not possible just to do an npm install
on the other side and have it working
I don't think test.check currently works with nbb... does it? I'd be surprised if it did
sounds good, but I am not sure if I can create a simple, self-contained package with babashka that someone who is used to the node ecosystem (npm install level of involvement:))
you could also create a self-contained executable for a babashka program: https://github.com/babashka/babashka/wiki/Self-contained-executable but this means you'd have to create one for every OS/arch you'd like to support
yeah, there are definitely use cases where I would take that route, but this would be some tech test for interview
finally finished it, but as a beginner, I would really appreciate some reviews on it, if anyone has the time and inclination https://github.com/ashnur/nimble-tt
in valid-rank?
you've written (and (< 1 rank) (> 15 rank))
which you could write as (< 1 rank 15)
... but shouldn't that be (< 0 rank 15)
? I would have thought that 1
was a valid card rank to have.... ah ... no ... sorry ... just spotted that you're turning 1 into 14 in hand-result
forcing aces to be high ... does that mean you can't have a flush of 1 2 3 4 5
?
(seq (filter (complement valid-rank?) ranks))
is can be shortened to (seq (remove valid-rank?) ranks)
but I think it would be clearer to write (every? valid-rank? ranks)
I can't even find any documentation on it, like different dir structures used differently, and what is the appropriate namespacing for them
The file layout convention comes from the Java world where it's common to have a src
directory with all your application code in and a test
directory with your tests in. Often in Clojure land you'd describe the directory layout and dependencies for your project in a deps.edn
file (https://clojure.org/reference/deps_and_cli#_paths) The relationship between the namespace and the filename is generally a directory for each of the parts of the namespace when separated with a .
except the last one, which will be a file. So (ns foo.bar.baz ,,,)
will be in src/foo/bar/baz.clj
and you'd probably put tests for that ns in (ns foo.bar.baz-test ,,,)
/ test/foo/bar/baz_test.clj
- and there we find the next wrinkle. For namespaces that have a -
in them we need to replace it with a _
in the filename. This is because of a restriction in the jvm, and ClojureScript has followed the same convention to stay compatible. There's some more info here: https://www.clojure.org/guides/learn/namespaces#_loading ... does that make sense?
> err... not flush, straight, but I got your meaning yeah ... sorry - I'm not so good at poker 😉
Yeah, it is an easy fix in clojure, I just added an (or (= ranks [2 3 4 5 14])), since it's ordered, should be fine
I think I'm general the src
directory is used to keep the code you're intending to ship to production and the test
directory is for your tests that you probably won't include in the deployable artifacts. In development they both paths should be on the list of places that would get searched for namespaces.
it's exactly the kind of stuff that's complicated in js but in clojure it will be very short
@ashnur I found this one: https://github.com/leebyron/testcheck-js
there are a couple ones in js https://www.npmjs.com/package/fast-check
I haven't actually tried to run from source, but I'd expect there to be something non-compatible
$ npx nbb --classpath src/main/clojure -e "(require '[clojure.test.check])"
----- Error --------------------------------------
Message: Could not find namespace: goog.math.Long
Hmm ok, that's the first issueWriting a build script that fetches some json, formats it to edn, then wraps it in a (def some-data ...edn-data... )
. Trying to think of a way to format it. Maybe call pprint and leverage quoting so it treats the outer (def some-data ...)
as a list?
> Maybe call pprint and leverage quoting so it treats the outer (def some-data ...)
as a list?
That's what I'd do. Though I think I'd quote the whole EDN thing as well, producing (def some-data (quote literal-edn))
This will fail when trying to read :items
:
user=> (clojure.pprint/pprint (list 'def 'some-data {:point {:x 1 :y 2} :name "Harold" :items (range 20)}))
(def
some-data
{:point {:x 1, :y 2},
:name "Harold",
:items (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)})
This should work fine:
user=> (clojure.pprint/pprint (list 'def 'some-data (list 'quote {:point {:x 1 :y 2} :name "Harold" :items (range 20)})))
(def
some-data
'{:point {:x 1, :y 2},
:name "Harold",
:items (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)})
Landed on the following:
(pprint-str `(def ~'cloud-services ~cloud-services-json))
then can use the replace function to clean that upfinally finished it, but as a beginner, I would really appreciate some reviews on it, if anyone has the time and inclination https://github.com/ashnur/nimble-tt