Fork me on GitHub
#beginners
<
2016-04-28
>
bones07:04:42

It sounds like you’ve got 2 web servers, is that correct? One accepting outside requests which forwards to a VHOST which is another?

bones07:04:43

.. am I also right in thinking that PHP doesn’t usually have this architecture because it’s a module INSIDE the web server?

dharrigan07:04:14

Say I have a vector of maps [{:key :A01, name: "Foo"} {:key :B01, name: "Bar"}] and I want to pull out of that vector only the map entry that has a specific key, what's the way in Clojure to do this? I've tried (get-in my-data :B01), but getting Don't know how to create ISeq from Keyword error.

sveri07:04:37

@dharrigan: lookup filter, it filters a seq based on a predicate, which is basically what you want.

st07:04:40

get-in is used to retrieve a value inside one nested map. e.g:

(get-in {:a {:b 1}} [:a :b])
=> 1
In your case, if I understood what you want to do (filter elements of a vector with a specific value for a key), you could do (as @sveri suggested)
(filter #(= "Bar" (:name %))
        [{:key :A01, :name "Foo"} {:key :B01, :name "Bar"}])
=> ({:key :B01, :name "Bar”})
BTW, your map was not an correct clojure map (key name: should be :name)

dharrigan07:04:00

ah yes, sorry, typo on that.

dharrigan07:04:03

thanks everyone!

dharrigan07:04:25

filter works great - thanks again!

Chris O’Donnell12:04:27

@bones: I don't know how PHP deployment works, but yes that's the idea of it for clojure.

bones12:04:07

@codonnell: I did quotation cause at the way I’m aware of deploying PHP is FTP ha ha

bones12:04:04

But they’re more “web pages” not “web apps” I guess

bojan.matic12:04:11

I don’t think even PHP guys deploy using FTP anymore

bojan.matic12:04:56

oh, just saw you were talking more about pages

bojan.matic12:04:07

then FTP can be ok 😄

entrobe14:04:45

Is there a way to simplify (if x (f y) y)

mfikes14:04:56

@entrobe: Not sure if simpler, but (cond-> y x f)

entrobe14:04:52

oh, cool. thank you!