Hi,
The challenge is to get the server name part of a collection of strings of fully qualified domain names.
From: ["server1.oo.com" "s2.ee.com"]
To: ["server1" "s2"]
I can do this to a single element as:
(subs "server1.oo.com" 0 (str/index-of "server1.oo.com" \.))
or
(subs "server1.oo.com" 0 (#(str/index-of % \.) "server1.oo.com"))
But nested #()
functions seem not to be possible.
(#(subs % 0 (#(str/index-of % \.) "server1.oo.com")) "server1.oo.com")
returns an error.
When using the collection, something like this works:
(let
[s-col ["server1.oo.com" "s2.ee.com"]]
(map #(subs % 0 5) s-col))
But, how can I use the (str/index-of % \.)
instead of that hard-coded 5
?
All my attempts were unsuccessful.