Fork me on GitHub
#beginners
<
2017-06-23
>
vitruvia00:06:28

how can I stop strings from converting to raw characters when I operate on them with nth, reverse, drop and other sequence functions?

noisesmith00:06:16

you can’t, because strings are a subclass of CharSequence, but if needed you can call str on each char, or apply str to a sequence of chars

noisesmith00:06:16

as in (apply str (map f some-string)) if f takes a char and returns a char or string

vitruvia00:06:38

alright, thank you!

stardiviner02:06:37

How to calculate time between two timestamps in video? I want to calculate the time between two timestamps like 00:23:45:00 ~ 00:29:56:34 .

matan09:06:57

Hi, I've lately written a small project for large repeat numeric computations over data. Shortly after writing it for an immediate project's cause, did I turn to making it a library. The library itself (https://github.com/Boteval/compare-classifiers) I might publish to clojars after some more love, even if not more than a handful would ever use it, hopefully not much of an eco footprint... But I've summarized my experience in turning a codebase into a library here, in case anyone has comments to it ― might be cool https://github.com/matanster/split-a-library 🙂 Being kind of new to clojure, I figured #beginners might be fine.

matan09:06:13

Moreso, if you have any reference for, or your own related best practices for authoring a clojure library, I'd be very interested in learning!

nmax13:06:49

Hi, I use :gen-class so that I can use clojure from java. The problem is that all methods parameters as well as constructors parameters look like s1, s2, s3 in java, i.e. parameters names are changed from meaningful to generic ones. So :constructors {[String] []} looks like Foo(String s1) :methods [[bar [String Long] void ]] looks like foo.bar(String s1, Long l1) The situation is the same if I extends some java class or implement an interface. public interface Foo { void bar(String meaningfulParameterName); } in clojure: :implements "a.b.c.Foo" the method when clojure jar imported in java will still have corrupted parameter name. So the question is: is it possible to save parameters names?

fmnoise16:06:17

not sure as clojure allows identifiers which are not valid in java

noisesmith16:06:58

what a silly bot

=> (munge 'typical-clojure-name!)
typical_clojure_name_BANG_

noisesmith16:06:24

point being, we have built in stuff for translating things to be sure they are “java safe”

fmnoise17:06:29

hm, why then it's not munged while generating java code

fmnoise17:06:59

as it seems easier than generating s1, s2 etc

noisesmith17:06:19

but in the example above the params don’t even have names…

fmnoise18:06:00

@nmax more detailed example please?

grierson18:06:35

Is there anything like “Units of Measure” in F# for Clojure?

eriktjacobsen18:06:21

normal as transducer

nbardy19:06:34

Is there a function for this pattern? (if (fn? valfn) (valfn value) value)

mfikes17:06:06

nbardy: FWIW, oftentimes you will see cond-> used when you want to conditionally do something to a value. So (cond-> value (fn? valfn) valfn) is an equivalent way to write that, and fairly idiomatic.

mfikes17:06:37

cond-> for the above, is often actually written without newlines

eriktjacobsen20:06:12

Can't think of one, it looks a bit dodgy to me. (probably should know whether valfn is fn or not). Another way of looking at it would be replacing valfn with identity, like (let [fun (if (fn? valfn) valfn identity)] (fun value)) That way you'd get the same call structure surrounding value