Fork me on GitHub
#beginners
<
2021-11-07
>
introom04:11:35

How do you add elements to both the end and front of a seq. I saw a trick:

(flatten [1 some-vec 1])
which adds 1 to both end and beginning. Another approach would be
(concat [1] some-vec [1])
Is there any better approach other than the above two?

Ben Sless08:11:55

Just regarding concat, it's not exactly cheapest. It has some implementation details which actually give it nasty overhead and a nasty tendency to realize lazy arguments

Ben Sless08:11:29

Flatten is usually a code smell imo

Ben Sless08:11:33

To add elements to the end of a vector you can just use conj. More information about your use case would help

Ben Sless18:11:34

Yes. It's slower than using (eduction cat ,,,), surprisingly enough

Nathan K05:11:33

Hi all. I’m tempted to try tinkering with a very trivial “https://roamresearch.com/” clone. Would reframe be a good choice?

Benjamin08:11:20

Is there a tool to remove / merge redundant let ?

Geoffrey Gaillard11:11:52

Not that I know of. It would probably look like a compiler pass on the AST. Do you have access to the AST before the problematic code is emitted?

Benjamin13:11:40

no I mean some cider refactor etc. I already use the one to add arities to function and such

sova-soars-the-sora04:11:24

sounds like making a naive "combine these 2 lets into one" would be easy also sounds like a symbol-aware one (make sure one var is not used before another) is hard but maybe a naive one, paired with clj-kondo would be easy. clojure-LSP has some fun things. And integrates nicely with clj-kondo I think smash-lets-together is not yet a feature

Marc Rios11:11:03

I'm doing clojure web development. I'm trying to do authentication. The header setup I've chosen works when the backend server is node.js, but it doesn't work with Clojure's ring. I am able to deliver cookies to the client when the request comes from one of the webpages served from clojure's backend port but it will not issue cookies to requests that come from a different port on localhost. The headers Access-Control-Allow-Credentials = "true" , Access-Control-Allow-Methods is set to "*", Access-Control-Allow-Origin is set to localhost:<the port of the frontend, not clojure>, and "Access-Control-Allow-Headers" is set to "x-requested-with, content-type". Even after making those modifications, clojure still will not serve up a cookie to the frontend.

jumar11:11:06

You should say that you already asked pretty much the same question in #web-security

Marc Rios11:11:23

Sure. I am not familiar with Slack or with this Slack's ettiquette.

Marc Rios11:11:04

BTW, I asked the same question in #web-security and got no reply.

Marc Rios12:11:54

My partner discovered it was an issue with the JS frontend. Thank you for listening.

🎉 1
Benjamin13:11:25

In defense of this slack it is sunday morning 😛

roelof16:11:33

is this is good one to learn clojure and web development : http://www.parens-of-the-dead.com/e1.html ?

drewverlee19:11:55

There is a web development book to. But as a intro im sure that's fine. Web dev is bigger then cljs

roelof20:11:36

yep, but that one costs me a lot of money

zackteo02:11:37

This book is free https://www.learn-clojurescript.com/ but I'm not too sure how good it is compared to the Web Development with Clojure book

orpheus17:11:49

When using lein uberjar what’s the difference between the SNAPSHOT-standalone.jar and the SNAPSHOT.jar? Which one would I use in docker?

alexmiller17:11:41

standalone is the uberjar

alexmiller17:11:52

The other is just the project, no deps

randomm char19:11:42

how do I request a change in clojure. A clarification of a doc on a command (doc take-while) it doesn't explain that it will stop on first false.

pavlosmelissinos19:11:28

https://github.com/clojure/clojure/blob/master/CONTRIBUTING.md#i-want-to-file-a-bug--suggest-an-enhancement > Please file it as a question on https://ask.clojure.org with the tag "problem" (possible bugs) or "request" (enhancements).

pavlosmelissinos19:11:05

How is the docstring misleading though? It seems to me that the function does what it describes? > Returns a lazy sequence of successive items from coll while (pred item) returns logical true

sova-soars-the-sora23:11:18

:thinking_face: the opposite of logical true is logical false

phronmophobic00:11:17

I thought the opposite would be illogical true?

😂 1
Geoffrey Gaillard13:11:36

What is the problematic example?

☝️ 1
randomm char20:11:58

correct but when someone new to programing reads it they assume it goes thru the entire coll, not stop, like filter would , early on this bit me. the reason I want to know, specifically it caused someone else trouble look at https://stackoverflow.com/questions/69845947/why-is-take-while-returning-empty-sequence/69868919#69868919 This causes issues for newbs. thanks pavlosmelissinos

pavlosmelissinos20:11:31

What behaviour would you expect @UE0T2PKJA ? If it didn't terminate on first false how would it be different from filter?

randomm char21:11:25

I'm not expecting any other behavior but for new people the doc isnt clear (just for clarification I didnt post the question on stakoverflow)

👍 1