Fork me on GitHub
#beginners
<
2015-10-19
>
lucaska16:10:34

I’m running through the Clojure Koans right now, and I’m getting an error on 2 when trying to Eval expressions using string.

lucaska16:10:41

(ns koans.02-strings
  (:require [koan-engine.core :refer :all]
            [clojure.string :as string]))

lucaska16:10:26

That looks right, but trying to eval something like

(string/reverse "hello”)
gets me a
CompilerException java.lang.RuntimeException: No such namespace: string

lucaska16:10:43

Did I do something wrong with Leiningen?

lucaska17:10:25

Nevermind. I figured it out. The file wasn’t loaded in the REPL. Derp.

jeremyraines19:10:14

I am having some trouble translating a java class to clojure using (gen-class)

jeremyraines19:10:54

specifically, all the class does is define a static variable, then call super with a few args

jeremyraines19:10:02

I think I need to do something with exposes-methods but I’m not sure what exactly - like what is the name of the parent class’s constructor? just the name of the class?

jeremyraines19:10:09

also (I’m new at Java interop having mostly worked in cljs so far)

jeremyraines19:10:52

how would I translate this into a let binding? private static final Set<String> supportedApplicationIds = new HashSet<String>();

jeremyraines19:10:55

would it be like (let [supportedIds (HashSet.)] … ? If so, where does Set<String> come into play here?

danielcompton20:10:41

@jeremyraines: does the consuming code need a HashSet specifically? Clojure’s set implements Java set interface

jeremyraines20:10:42

I’m not sure. This is the entire class I’m trying to convert (it’s an example that Amazon gives for something you can stick on Lambda to respond to Alexa speech events):

jeremyraines20:10:22

I could try it out as a plain Clojure set, but first I need to understand how to represent that super call in my -init function (I think)

jeremyraines20:10:29

basically: :exposes {super-method-name exposed-method-name} but I don’t know what to put in that map. I assume the latter is -init or maybe init but how do I refer to the superclass’s constructor fn?

jeremyraines20:10:53

sorry :expose-methods . . .

jeremyraines20:10:36

all but the middle

jeremyraines20:10:30

I think it would be clear if the function of the superclass were anything other than its constructor. I don’t know how to refer to it

jeremyraines20:10:17

maybe I can just not extend anything and just make my -init body be (SpeechRequestStreamHandler. (HelloWorldSpeechlet.) supportedIds)

roberto22:10:38

Given a tuple of maps with the following keys, how do I attach another key to each tuple indicating if they have to largest :total_size or the smallest? [:id :play_url :recording_start :recording_end :topic :total_size]

roberto22:10:14

for example:

(def my-typle [{:total_size 20 :id 1} {:total_size 10 :id 2}])

(attach-label my-tuple) => [{:total_size 20 :id 1 :label “larger”} {:total_size 10 :id 2 :label “smaller”}]