beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
JohnJ 2021-01-29T00:23:24.132400Z

writing an "idiomatic" wrapper but that can be more taxing than using the lib directly

👍 2
raspasov 2021-01-29T01:05:23.132900Z

Yes. I would say this applies to all languages that deal mainly in references instead of values.

raspasov 2021-01-29T01:07:16.133100Z

Pragmatic techniques: Isolate the scope of those mutable references to one corner of the program and don’t pass them around. If you need to pass them around: convert them to Clojure data first.

👍 1
dgb23 2021-01-29T01:41:32.133400Z

That’s right, after you serialized it, it can’t hurt you anymore!

dgb23 2021-01-29T01:41:41.133700Z

ty for the tip

👍 1
2021-01-29T04:05:00.139500Z

Hi Everyone, i'm really newbie in clojure (i don't have any code exp, except vba & ms. Excel). I'd like to asked several questions 1. lein new app asdf, i do this in my cmd, but how can i do this in atom? is it possible? if not, that's okay. 2. then i create suspects.csv and want to slurp it. but it gives an error. below is the screenshot. I've put this csv in resources, or in src/asdf along with the core.clj, but give same error. PS : I placed my lein.bat & atom repl run in this directory C:\Users\Adrian Imanuel\.atom\packages\proto-repl\proto-no-proj\src thanks a lot for the help

2021-01-29T04:34:26.141300Z

If you do this in your program, or a REPL, it will tell you what the JVM thinks is the current directory (or what it thought was the current directory when your REPL started at least -- it can be changed later): (println (System/getProperty "user.dir"))

2021-01-29T04:34:51.141800Z

That is the directory it is probably trying to read the file from, unless you direct it differently somehow.

2021-01-29T04:41:19.143800Z

If you want to get it from your resources directory, you can do (require '[<http://clojure.java.io|clojure.java.io> :as io]) in the REPL, or add a similar thing into your ns form of your program's namespace that looks like (:require [<http://clojure.java.io|clojure.java.io> :as io]), then do (slurp (io/resource "suspects.csv"))

2021-01-29T04:42:19.144600Z

Someone else might know the answer to your question about creating new Leiningen projects from within Atom -- I do not. You could also ask in the #atom-editor channel, if no one here knows.

seancorfield 2021-01-29T05:08:32.145400Z

@adrianimanuel With Atom, are you using ProtoREPL or Chlorine?

2021-01-29T05:09:07.145900Z

@seancorfield i'm using ProtoREPL

seancorfield 2021-01-29T05:09:37.146600Z

Hmm, ProtoREPL is unmaintained. I'm a bit surprised it still works with Atom.

2021-01-29T05:11:35.148600Z

@seancorfield whoops, i really didn't know that, should i change IDE? is there any recommendations?

seancorfield 2021-01-29T05:11:37.148700Z

It hasn't been updated in nearly three years now. I was an Atom/ProtoREPL user and I switched to Atom/Chlorine, but that expects you to start the REPL separately, via a terminal (or cmd.exe window in your case).

seancorfield 2021-01-29T05:12:21.149100Z

https://atom.io/packages/chlorine is solid. There's a #chlorine channel.

seancorfield 2021-01-29T05:13:57.150Z

I will caution that Windows is very much a second-class citizen in the Clojure world. If you're on Windows 10 and willing to use WSL2 you'll fare much better.

😮 1
seancorfield 2021-01-29T05:15:00.150900Z

My primary dev env is macOS but my secondary env is Windows with WSL2 (and Ubuntu). I've recently switched from Atom (after several years) to VS Code.

seancorfield 2021-01-29T05:15:58.152200Z

That gives you the option of Calva which is very feature-rich and well-maintained or Clover -- which is essentially Chlorine (for Atom, but ported to VS Code). So that's allowed me to port my exact workflow from Atom to VS Code.

2021-01-29T05:17:18.153300Z

@andy.fingerhut it works... (println (System/getProperty "user.dir")) after locate the REPL I'll try the (require '[<http://clojure.java.io|clojure.java.io> :as io]) now.

2021-01-29T05:18:51.153600Z

why is windows10 isn't suitable env for clojure?

seancorfield 2021-01-29T05:24:36.153800Z

All of the tools and libraries are designed for macOS/Linux because that's what most Clojure developers use.

seancorfield 2021-01-29T05:28:03.154Z

The Clojure CLI (the official offering from Cognitect, rather than Leiningen) has an alpha approach to Windows: https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows via Powershell, but it's just so much easier to give up on Windows and use WSL2/Ubuntu (which is what Microsoft increasingly expect developers to do).

seancorfield 2021-01-29T05:28:32.154200Z

And VS Code has a Remote-WSL2 mode that lets you run "everything" on Ubuntu while VS Code runs on Windows so it's super-slick.

seancorfield 2021-01-29T05:29:51.154400Z

I use VS Code on both Windows and macOS (and it auto-synchronizes the entire setup between the two systems), and on both systems I run everything on the *nix side (Ubuntu on WSL2 on Windows 10 and macOS Terminal).

2021-01-29T05:33:19.154600Z

I'll try to digest this... since i really had no idea, I'm still on progress learning https://www.braveclojure.com/core-functions-in-depth/ 😅, once i got more deeper knowledge then I'll try to move on to macOS. Thanks a lot for the suggestion

2021-01-29T05:38:26.154800Z

cool. The http://clojure.java.io/resource function is useful if you want to get a file handle to a file in your resources directory, but it isn't really needed if you prefer to put the file in the current directory (the one that "user.dir" property shows)

2021-01-29T05:42:55.155Z

thanks a lot for the enlightment! 😆

seancorfield 2021-01-29T05:45:44.155200Z

Happy to answer any Qs since I work on both Windows 10 (WSL2) and macOS 🙂

Sophie 2021-01-29T08:52:25.159400Z

Hello, I'm looking for a way to seperate strings without a specific term and store them. The separation works, but it seems nothing is stored...

(let [mapsx (remove nil? (map #(if-not (clojure.string/includes? % "jpg") ( println % ) ) prae))]
        (println mapsx mapsx))
result:
(
whats
the
problem
here
)()
Any suggestions? Solved it by my own 😊
(let [mapsx (remove nil? (map #(if-not (clojure.string/includes? % "jpg") (conj % ) ) prae))]
        (println mapsx mapsx))

✅ 1
Mno 2021-01-29T10:13:32.159900Z

Nice, you solved it, but you might want to look into filter and group-by, as it might make sense for this use case. this would get you all of the ones that dont include jpg

(filter #(not (clojure.string/includes? % "jpg")) prae)
while group-by would give you a map with those who do and don’t include jpg.

tws 2021-01-29T10:29:10.161400Z

See remove

Mno 2021-01-29T10:51:59.161600Z

I mean remove was used in the original, so I assumed knowledge of it was present. Although, It is good to point out that remove is very much useable as well (since it’s basically the same as filter with the predicate reversed).

teachtyler 2021-01-29T11:08:44.162800Z

hi, what's the terminology for this dot notation and is it conventional or intrinsic? ex:

(use (. express (logger))
      ^

Mno 2021-01-29T11:11:01.163400Z

I believe it’s called the Dot special form, for more reading: https://clojure.org/reference/java_interop#_the_dot_special_form

❤️ 1
🙏 1
Piotr Brzeziński 2021-01-29T11:17:46.164600Z

Hey! I remember seeing a list of OSS clojure/clojurescript repos with issues good for beginners. Could somebody please point me to it?

Piotr Brzeziński 2021-01-29T11:32:42.166700Z

Ah, found it. http://braveclojure.com linked to it, nvm 🙂

👀 1
Christian 2021-01-29T11:43:13.169100Z

When I use clojure.string/replace, is it possible to get the times something was found? Maybe this example helps:

(def teststring "AAABBC")
(str/replace testcode #"\D+" "$1")
I would like to know how many times A was found in a row and use it. Is this possible in regex? I have to code with lots of take-while, count and drop. But this would be a lot more compact

borkdude 2021-01-29T11:58:43.169800Z

@christiaaan You can pass a function as the last arg:

$ bb -e '(str/replace "foo" #"(o)+" (fn [&amp; args]  (prn args) "x"))'
(["oo" "o"])
"fx"

borkdude 2021-01-29T11:59:53.170400Z

$ bb -e '(str/replace "foo" #"o" (fn [match] (prn match) match))'
"o"
"o"
"foo"

Christian 2021-01-29T11:59:58.170500Z

What? That looks like some bash thing. Ah, it's the babashka dude!

Christian 2021-01-29T12:00:40.171200Z

for "oo" i would like to have something like "2o" so I know it has found 2 o

Christian 2021-01-29T12:00:46.171400Z

but how do I get the 2?

borkdude 2021-01-29T12:01:12.171700Z

you mean, you would like to get the amount of replacements?

borkdude 2021-01-29T12:02:02.172Z

I think you might want to use re-seq which gives you all the matches

borkdude 2021-01-29T12:03:27.172200Z

$ bb -e '(re-seq #"\D" "AAABBC")'
("A" "A" "A" "B" "B" "C")

tws 2021-01-29T12:07:02.173Z

Also see keep instead of mapping then removing nils.

Christian 2021-01-29T12:19:49.174100Z

Then I'd still have to count them manually. I was hoping that the regex would somehow offer the amount of replacements, like I can access the groups

raspasov 2021-01-29T12:29:56.174200Z

I would say the most typical thing in Clojure is to simply (count …) the sequence that (re-seq …) returns

borkdude 2021-01-29T12:37:12.174400Z

@christiaaan A little hacky, but you could have a side-effect in the replacement function that increments a counter

👀 1
borkdude 2021-01-29T12:37:24.174600Z

This way you would have replacement + counting in one go

dehli 2021-01-29T13:23:42.176700Z

With spec, can I have the same namespace qualified keyword speced differently in two different contexts? For example in one map I’d want :foo/bar to be string? and in another I’d want :foo/bar to be int? . Ideally they’d be different keywords if they were different types, but curious if something like this is possible.

alexmiller 2021-01-29T13:33:06.177900Z

No, spec encourages you to register a single, well namespaced spec that applies globally

👍 2
dgb23 2021-01-29T13:44:53.179500Z

When I understand correctly, this doesn’t just apply to spec, but is a more general issue about namespaces and namespaced keywords and what they mean right?

alexmiller 2021-01-29T13:54:58.179900Z

Not necessarily

alexmiller 2021-01-29T13:55:18.180400Z

Names need sufficient context

alexmiller 2021-01-29T13:55:53.181400Z

“Sufficient” is highly context dependent

👍 1
dgb23 2021-01-29T14:43:24.182600Z

Shouldn’t we provide context with metadata generally speaking? I don’t think this is possible with keywords as they are interned. But conceptually this would seem useful.

alexmiller 2021-01-29T14:43:58.182800Z

there are many kinds of context

dgb23 2021-01-29T14:44:20.183100Z

context is contextual 😄

dgb23 2021-01-29T14:47:38.183900Z

But yeah, thinking about this it makes more sense to put metadata on a symbol (that points to something) rather than a keyword, which is just a value.

alexmiller 2021-01-29T14:55:22.184200Z

context can just be where/how it's used

alexmiller 2021-01-29T14:55:29.184400Z

it can be implicit

👍 1
2021-01-29T15:50:24.186Z

hi, anyone using spacemacs? been stuck in here forever, why it didn't download? can anyone help?

2021-01-31T15:41:02.271600Z

@jordan.andrew.garriso just installed DOOM, and tried to run repl for clojure, SPC-o-r there's 2 options : Clojure (default), when run said - symbol's function definition is void: cider-current-repl Clojure (cljs)

clyfe 2021-01-31T15:42:10.272Z

enable clojure module, repl is SPC m '

clyfe 2021-01-31T15:44:35.272300Z

also have a clj file opened so you're in clojure mode

2021-01-31T15:48:11.272500Z

the lein executable isn't in you exec-path

2021-01-31T15:48:26.272700Z

where should i put lein.bat?

2021-01-31T15:49:46.272900Z

in .emacs.d/bin or ~/.emacs.d/bin?

2021-01-31T15:53:00.273100Z

gotcha, in ~/.emacs.d/bin

2021-01-31T16:06:56.273400Z

@claudius.nicolae i've tried SPC m ' it showed like this, i didn't see any REPL windows... thanks a lot for the help

clyfe 2021-01-31T16:39:13.279900Z

You have to be in a project (folder with project.clj or deps.edn).

clyfe 2021-01-31T16:39:53.280800Z

Also I see some fonts be missing, check doom doctor

2021-01-31T17:14:16.283300Z

ah allrite, will do

2021-01-31T17:14:40.283500Z

thanks a lot for the guidance

👍 1
2021-02-01T03:17:32.316Z

i've tried to create projects, run the core.clj, but still the repl doesn't show up.

2021-02-01T04:54:12.316400Z

okay, found the solutions https://stackoverflow.com/questions/65566706/error-in-process-sentinel-could-not-start-nrepl-server-java-lang-numberformate 1. start git cmd 2. type >> lein repl >> it'll start repl in git cmd 3. goto doom emacs type [SPC m c] >> cider-connect-clj 4. choose local host 5. type port local host as shown in step 2

clyfe 2021-01-29T15:58:12.186700Z

Use this in the meantime: https://github.com/thanhvg/spacemacs/tree/feature/evil-collection

clyfe 2021-01-29T15:58:46.186900Z

This ate 1 day of my life with %^#&*?!?

2021-01-29T16:07:02.187100Z

alrite, i'll try

2021-01-29T16:07:12.187300Z

thanksss a lotttt for the information

2021-01-29T16:10:00.187500Z

maybe i'll use emacs instead spacemacs... idk what to do (totally clueless), i'll learn it on the go

Jordan Garrison 2021-01-29T16:34:11.187800Z

If you are a previous vim user/like vim’s modal editing then Doom Emacs is another distribution of emacs which might meet what you need. It predownloads/compiles (if you want) packages for you so you get a quick startup (< 1s). It has a prebuilt clojure configuration as well which has worked really well for me out of the box. Repo: https://github.com/hlissner/doom-emacs YouTube series on use/setup: https://www.youtube.com/playlist?list=PLhXZp00uXBk4np17N39WvB80zgxlZfVwj

Mehdi H. 2021-01-29T16:38:42.190400Z

Hey guys, has anyone successfully used miner.ftp library with ftps? I can't find out where to use the function encrypt-channel on the client.... if local data transfer is not forced to SSL, just using the ftps protocol works, but when data should be encrypted it seems compulsory to use this encrypt-channel function.

Mehdi H. 2021-02-01T10:46:34.330900Z

Is no one interacting using ftp or is my lack of profile picture detrimental to getting any feedback 🙂 ?

Mehdi H. 2021-02-01T15:20:41.340500Z

-_-'....

2021-01-29T16:42:41.190500Z

alrite, i'll look into it as well.. I never use any of this before hahhaa.. total newbie... my previous experience is Ms. Excel & VBA.... I'll learn slowly

Joe 2021-01-29T17:28:31.190900Z

Starting from scratch in non-VBA programing and Clojure and Emacs is a lot to chew in a single bite!

👍 1
☝️ 3
clyfe 2021-01-29T17:30:11.191100Z

@adrianimanuel https://calva.io/ may be more suitable for you, it's quite beginner friendly (occasional bugs aside).

👍 2
2
☝️ 2
dharrigan 2021-01-29T21:14:52.192600Z

If you are a (neo)vim user, I can't rate highly enough the #conjure plugin for Vim that really is amazing for developing Clojure with Vim.