Fork me on GitHub
#beginners
<
2015-11-19
>
roelof07:11:18

why does the contents of final-body-parts not get printed on line 7 of this code : http://lpaste.net/145556

ian08:11:50

@roelof: surely that must give an error. Watch your use of parentheses. (println (["foo" "bar"])) is essentially what you're calling right now.

roelof09:11:58

oke, what is then the best way to print the contents of the final-body-parts. I have to use println because otherwise cursive will not give output

cjmurphy10:11:58

@roelof (println ["foo" "bar"]) would be the best way.

cjmurphy10:11:30

i.e. (println final-body-parts)

ian11:11:29

and to be painfully explicit, this is because (println (final-body-parts)) will try to call final-body-parts as a function (as PersistentVector implements IFn), and you actually get an ArityException thrown. one would hope that would be apparent through some means with cursive, but I've never used it.

roelof11:11:58

oke, I have a problem with another ide

roelof11:11:41

I have this project,clj which resides in the root of the project :

roelof11:11:42

FROM binduwavell/codenvy-alfresco-base:0.3 MAINTAINER Bindu Wavell <[email protected]> RUN sudo apt-get update && \ sudo apt-get install -y emacs && \ sudo apt-get clean && \ sudo rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/* RUN mkdir /home/user/bin ENV PATH /home/user/bin:$PATH RUN echo "export PATH=$PATH" >> /home/user/.bashrc RUN wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O /home/user/bin/lein && \ chmod 755 /home/user/bin/lein && \ /home/user/bin/lein && \ timeout 30 /home/user/bin/lein repl :headless ; \ /bin/cat /dev/null RUN wget https://github.com/boot-clj/boot-bin/releases/download/2.4.2/boot.sh -O /home/user/bin/boot && \ chmod 755 /home/user/bin/boot && \ /home/user/bin/boot && \ /home/user/bin/boot ENV CODENVY_APP_BIND_DIR /home/user/application VOLUME ["/home/user/application"] ENV CODENVY_APP_PORT_8080_HTTP 8080 EXPOSE 8080 CMD sleep 365d

roelof11:11:51

sorry, wrong paste

roelof11:11:04

right paste :

roelof11:11:05

(defproject app "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"]] :main ^:skip-aot app.core :target-path "target/%s" :profiles {:uberjar {:aot :all}})

roelof11:11:39

I have this is my src/app/core.clj :

roelof12:11:06

(ns app.core (:gen-class)) (defn -main "I don't do a whole lot ... yet." [& args] (println "Hello, World!"))

roelof12:11:56

but when I do lein run I see this error message : no :main namespace specified in the project.clj

roelof12:11:06

how to solve this one :

roelof12:11:59

found it. I have to do lein run into the directory

ian12:11:10

where were you running lein run?

ian12:11:33

it needs to be in the project root directory, yeah.

roelof12:11:09

Lets go back to the printing problem on cursive

roelof12:11:09

but still I see no output at all

ian12:11:00

what do you mean you see no output?

ian12:11:09

I've never used cursive, but that code is fine.

ian12:11:15

it prints the vector of maps like it should. I don't know how cursive works, though.

roelof12:11:15

aha, I had to do (println (symmetrize-body-parts asym-hobbit-body-parts))

roelof12:11:24

now I see the output as I was expected

ian12:11:26

that doesn't seem right.

ian12:11:38

the return value of symmetrize-body-parts is nil

roelof12:11:14

the "old" code or the solution I found

ian12:11:12

http://lpaste.net/145565 (also, why use a haskell-oriented paste service? do you have a haskell background?)

roelof12:11:36

I did haskell before I made the switch to clojure

ian12:11:44

ah, neat.

roelof12:11:53

which paste I can better use then

ian12:11:57

it's an open source clojure pasting service made by a pretty active member of the clojure community.

roelof12:11:12

oke, I will make the switch

ian12:11:12

https://github.com/Raynes/refheap for the source, if you're curious.

ian12:11:39

anyway, symmetrize-body-parts returns nil because of the call to println.

roelof12:11:28

oke, When you switch to this code : https://www.refheap.com/111861 , it works fine

ian12:11:24

that's different from what you pasted earlier, though.

roelof12:11:03

yes the println is away and I use another function to call the right function with the right arguments

ian12:11:11

the true branch in that version returns final-body-parts, a vector.

roelof12:11:33

correct, but the function needs a argument and it seems I forget to feed the right argument to the function

roelof12:11:43

and then final-body-parts is empty

ian12:11:03

which function?

roelof12:11:31

symmetrize-body-parts

ian12:11:20

I'm confused I think by what you mean about forgetting to give the right argument?

ian12:11:41

do you mean you were trying to call symmetrize-body-parts with something other than asym-hobbit-body-parts?

roelof12:11:19

nope, that is what I mean , When you do say to clojure that the function needs the asym-hobbit-body-parts the output will be empty

ian12:11:53

so if you call (symmetrize-body-parts asym-hobbit-body-parts), it doesn't return anything?

roelof12:11:40

then it will return the right answer. if you do not do use it this way the output is empty

ian12:11:22

oh, of course.

roelof12:11:09

I hope one day I learn how to do this function call in a main function

roelof12:11:30

At this moment. IM happy. the function works as expected

ian12:11:36

symmetrize-body-parts takes a vector of maps, and the maps are expected to be of shape {:name s :size n}

ian12:11:53

were you wanting to just call it like (symmetrize-body-parts) with no arguments?

roelof12:11:13

no, the function call is allright as it is

ian12:11:32

if that were the case, symmetrize-body-parts would need to know about asym-hobbit-body-parts, and then the function and data are too closely related. at least as far as the author of CFTBAT is concerned (and most here would agree). it's almost always better if the function doesn't have intimate knowledge of other data in the program.

ian12:11:45

I think I'm misunderstanding you somewhere, I'm not sure.

roelof12:11:08

What im was saying the function is allright.

roelof12:11:14

Thanks for the help

ian12:11:13

oh okay haha

roelof12:11:18

but I was curious if I could do the (println (symmetrize-body-parts asym-hobbit-body-parts)) hidden in a main function

ian12:11:27

oh, sure you can.

roelof12:11:30

so I could do lein run

ian12:11:14

(defn -main [& args] (println (symmetrize-body-parts asym-hobbit-body-parts))) should be fine.

roelof12:11:06

Thanks, now time for a late lunch

roelof13:11:36

someone who wants to help me solving this :

roelof13:11:37

6.Create a function that generalizes symmetrize-body-parts and the function you created in Exercise 5. The new function should take a collection of body parts and the number of matching body parts to add. If

roelof13:11:14

I could use something like repeatly but then I loose the abilty to rename the parts

progzilla17:11:46

Somebody help me out pls...i tried to refresh my package list in emacs but it keeps hanging "Contacting Host: http://elpa.gnu.org:80"

roelof17:11:08

sorry, I cannot help you. I do not use emacs

colin.yates17:11:46

@progzilla: Sometimes the sites go down. Go grab a coffee and try in 30 minutes? Also note that there is a specific #C099W16KZ channel.

progzilla18:11:21

Oh ok..I'll go there thanks

progzilla18:11:42

Thanks @colin.yates

roelof18:11:24

no one who can help me ?

surreal.analysis19:11:03

@roelof: In your example, you rename things to right, right-2, etc. Is there a reason they can't just be renamed to 1- and 2-, e.g. 1-arm, 2-leg

alexmiller19:11:09

those are not valid symbols - can't start with a number

surreal.analysis19:11:37

Oh, I may have missed the point

meikemertsch19:11:37

They’re not symbols but strings

surreal.analysis19:11:40

I thought these were just strings

alexmiller19:11:12

then never mind :)

surreal.analysis19:11:32

If that's the case, then something along the lines of (apply set part (map #(matching-part part (str %)) (range n))) should help get you there. Could definitely use to be cleaned up, but that's the core of what you want.

surreal.analysis19:11:18

If you really want to keep the right / left / center, I'd define another function that takes in a number and returns the prefix string.

roelof19:11:03

oke,thanks, I will try it that way