Fork me on GitHub
#beginners
<
2021-11-27
>
Muhammad Hamza Chippa11:11:23

I am getting the string from substring like `(subs (first x) 9)` which is time like 16000 `(*int (subs (first x) 9))`is not working on it it is saying "Expected number or character received string" ?* any alternate ?

pavlosmelissinos11:11:01

Sorry, I don't understand what you're trying to do. What does x look like and what do you expect to get back in the end?

Ed11:11:58

int doesn't convert a string to a number. It will cast from other numerical types into an int. What you're probably looking for is Long/parseLong ... https://docs.oracle.com/javase/7/docs/api/java/lang/Long.html

1
👀 1
Ziad Salah13:11:29

Hello, say I have a collection of a collection of maps, i.e:

[[{} {} ...] [{} {} ...] ...]
And I'd like to get the first map from every collection that satisfies some predicate. I've done that by mapping a filter on the main collection, then mapping first on the result. Is there a nicer or more idiomatic way of doing this?

Fredrik14:11:25

Idiom for filtering out the first element has been rejected in the past https://clojure.atlassian.net/browse/CLJ-2056, due to poor performance of linear search. Consider whether you could represent your data so you can do a lookup instead of searching. Having said that, you could use a reduce

(map (fn [list-of-maps]
       (reduce (fn [_a m]
                 (when (predicate m)
                   (reduced m)))
               nil
               list-of-maps))
     list-of-list-of-maps) 

delaguardo14:11:50

It is idiomatic. Also you can use transducers here to avoid intermediate collections - https://clojure.org/reference/transducers

Ziad Salah11:11:55

Thank you all

Michael14:11:50

Hi, I am a beginner in clojure. I'm finding Emacs so hard to use

sheluchin14:11:43

Yeah, learning Clojure and Emacs at once is a bit much IMO. You may want to try a simpler editor. https://github.com/BetterThanTomorrow/calva is popular.

sb14:11:20

If you are not familiar with emacs.. then it might be not a best idea start with emacs. I did this mistake. Try to use VSCode + REPL from terminal. Later you can use Calva. IntelliJ+Cursive a good option too. And after this you could learn emacs too

delaguardo14:11:21

Which editor are you using most of the time?

Michael15:11:14

@UPWHQK562 thanks gonna check it out

Michael15:11:45

@U2T2ZEVPC @U04V4KLKC currently trying to get used to Emacs, I used both Emacs and VScode. But I heard Emac itself is written in lisp and understand lisp structure very well but it very hard for me to get use to

adi17:11:28

@U02PG1GLZGQ Emacs Lisp and Clojure are two very different languages. So I suggest not making that the basis for you editor choice. I agree with the others here. Since you are new to Clojure, I'd say use VSCode + Calva. That said, as a happy Emacs user, I'd say please also mess around with Emacs, but don't let it be a blocker for your Clojure study! Welcome to Clojure, all the best and have fn! :)

👍 1
Michael18:11:02

@U051MHSEK okay noted. Thanks

seancorfield20:11:36

If you're used to VS Code, stick with it for Clojure and use Calva -- it's awesome! There's a #calva channel if you need help with it.

1
❤️ 1
sheluchin14:11:38

What's the Clojure approach to pulling secrets out of the environment and into EDN config files? I found https://github.com/sultanov-team/secret-keeper but I'm wondering if there's a more common approach that people use.

dorab16:11:06

For configuration management, take a look at juxt/aero. Among other things, you can have environment variables inserted into config files. In the docs, there is also a suggested way of storing credentials in a separate file (so you can keep it out of version control) and then incorporate the secrets into the config.

2
adi17:11:30

@UPWHQK562 +1 to @U0AT6MBUL's suggestion. Here's a real example of a config file I wrote for juxt/aero, which pulls secrets from a separate secrets.edn file (which is .gitignored and not tracked in version control): https://gitlab.com/nilenso/cats/-/blob/master/resources/config.edn#L1

sheluchin17:11:04

Thanks everyone, I had not heard of aero. Will check that out.

sheluchin17:11:49

@U6T7M9DBR thanks, I've used that extensively before. There is also https://github.com/StackExchange/blackbox, which you might find of interest.

sheluchin18:11:02

I just noticed that since I'm using Fulcro, it already has this built in: https://book.fulcrologic.com/#_server_configuration > Values can take the form :env/VAR, which will use the string value of that environment variable as the value. > Values can take the form :env.edn/VAR, which will use read-string to interpret the environment variable as the value. False alarm 🙂 just leaving this here for posterity.

John Bradens22:11:51

Hi I'm a beginner that's created some web apps in Clojure. I'm curious about the metaverse thing and how to develop an AR app. Is this possible using clojure? Or what languages do people typically use to make an AR or VR app? Are there any resources you can point me to, like a beginner how-to? I feel passionate about Clojure & fascinated by the new AR/VR stuff, so I think it would be super cool to make some kind of basic metaverse apps using clojure just as personal projects. I just don't know where to start or if it's even possible or been done before.

emccue22:11:05

So there are a few layers to this

emccue22:11:31

one is yes, you can make at least VR apps with Javascript and we have a dialect of clojure which compiles to javascript

emccue22:11:50

there are a few proof of concepts out there and it will probably take some build system tinkering to get that up and running, but its definitely doable

emccue22:11:09

as far as i know there isn’t any beginner todo for that in particular

emccue22:11:06

the other is a challenge to you: define “metaverse”

emccue22:11:33

i take a very, very, very dim view of that particular direction of hype

4
emccue22:11:51

and if you have some picture in your head of the kind of VR/AR app you hope to make, its probably better to focus on that than “the metaverse”

John Bradens00:11:43

Cool, thank you @U3JH98J4R. I'm glad to hear that it's doable & that I can use javascript/clojurescript? I'll try to find the proof of concepts. I think I'm most curious about making an AR app, and I'm not sure about correct terminology. I thought "metaverse" is just a term for the 3D AR/VR space, can you please tell me what the direction of hype is? Is it related to the facebook meta stuff? Does it make more sense for me to just say "AR or VR app" and avoid the whole metaverse thing? I appreciate hearing your thoughts about it. On google I'm having trouble finding real information amongst clickbait articles but I'll keep searching there too

emccue00:11:04

metaverse has some roots in scifi, but its been entirely co-opted by facebook’s whole deal. It doesn’t super work as a blanket term for the whole space. "AR or VR app" is good.

emccue00:11:51

I don’t know much about AR devices - which one(s) do you have available to prototype on? That would probably influence what you are able to do

emccue00:11:23

In my brain AR is anything where the “information” either doesn’t take up your whole visual space or is overlayed onto the environment

✔️ 1
emccue00:11:29

so like pokemon go

emccue00:11:58

HoloLens and stuff seem to be “mixed reality”, but im unclear if thats just in reference to it being strapped to your head

John Bradens01:11:20

I haven't gotten a device to prototype on yet, still researching to pick one. And ok thanks, that's good to know. I think for my use cases I'm most curious about things overlayed into the environment. Early stages of looking into all this. Thanks for the info!

thom07:11:17

There was a project to create Clojure bindings for Unity, although I'm not sure it's maintained anymore: https://github.com/arcadia-unity/Arcadia. But that'd give you a leg up for 3D stuff, and Unity has explicit AR and VR support.

John Bradens07:11:20

@UTF99QP7V thanks I'll look into that!