You used (comp :intelligence :attributes) to create a function that returns a character’s intelligence. Create a new function, attr, that you can call like (attr :intelligence) and that does the same thing.
is it now the purpose to make the c-* methods but then without using comp ?
To be honest, this is a pretty poor example. Typically, if you want to access nested maps you would use get-in (and assoc-in and update-in if you need to modify). Using comp here is not idiomatic.
I guess the point of the exercise would be for you to define your own comp or partial (did you see that in previous chapters?) based solution, which is trivial.
The Brave Clojure book is a bit old, and some “best practices” have evolved. In general, you’d try to avoid nesting too deep (this case is ok, but in general, if you have deep nesting, it ends up being painful), and maybe you’d use namespaced keys instead.
Implement the comp function.
Implement the assoc-in function. Hint: use the assoc function and define its parameters as [m [k & ks] v].
Look up and use the update-in function.
Implement update-in.
all very vague. apperently I have to take out the tutorial what all those functions exactly do
Remember to check clojuredocs.org for docs on those functions, and examples of how they work. They are all fairly simple to implement (in a naïve way, at least)…
You’re missing some parens around the f (apply g...). And the case of using comp over multiple functions (you’ll probably want to use reduce for that
Well, it’d be better to avoid explicit recursion (you’re defining your own comp, so using the built-in one sounds like cheating )
Another thing to consider is the arguments you take. comp itself takes just functions, but the function you return should accept any number of arguments, which should be taken by the first function in your composition chain.
If you do get stuck, you can peek at how clojure.core/comp is implemented