Fork me on GitHub
#clojure
<
2020-10-10
>
vncz16:10:15

I remember there was a function in Clojure that would be like if (cond) f(a) else a

vncz16:10:25

but I can't find it anymore…anybody has that on top of his head?

teodorlu16:10:21

@vincenz.chianese is cond-> what you want?

(cond-> 10
  true inc)
;; => 11

(cond-> 10
  false inc)
;; => 10

vncz16:10:44

Aha! I think so!

👍 3
Ivan Fedorov18:10:00

moved to #leiningen

Burin18:10:11

Is there a library that parse the fixed with file in Clojure?

Burin18:10:52

Quick google gave me this article - http://www.lexicallyscoped.com/2015/01/05/parsing-flat-files-in-clojure.html but it seems to be overkill for me.

zilti18:10:19

You'll probably have to do that yourself, and read each line's fields with subs

zilti18:10:27

At least that's how I'd do it

zilti18:10:06

Should be quite straightforward actually.

Burin18:10:51

Thanks will give that a try then.

zilti18:10:30

Yes, read in the file with slurp, then do a (str/split yourstring #"\n") so you have one array entry per line, then just use subs with whatever field length you have repeatedly over each line

Burin19:10:19

I am reading in huge file, so will do that lazily

teodorlu19:10:30

@U39K1NXHP line-seq lets you handle a line at a time lazily https://clojuredocs.org/clojure.core/line-seq

👍 3
craftybones18:10:14

You could also get fancy with a spec and use conform

Setzer2221:10:45

Any way I can use REBL to develop on a remote machine?

seancorfield22:10:25

@setzer22 REBL works "in process" so you could use it on the remote machine if you can "project" the UI from that machine onto yours (say via X11 if it's a *nix machine or remote desktop if it's Windows/Mac)...

👍 3
Setzer2208:10:58

thanks! I'll see if I can pull off X11 forwarding on this machine

seancorfield22:10:14

When I'm on my Windows laptop, I use Xlaunch so that I can run X11 UIs from WSL2 and then appear under Windows. Similar concept but not really "remote".