Changes between Version 40 and Version 41 of Clojure Client Tutorial


Ignore:
Timestamp:
Aug 8, 2011 11:54:29 AM (13 years ago)
Author:
kedwar10
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Clojure Client Tutorial

    v40 v41  
    271271}}}
    272272
    273 Partitioning these into a map is going to be a little more difficult as multiple positions will need to be stored at each key.  However, we know already that the initial data structure to be a hash-map and the keys need to be the item type.
     273Partitioning these into a map is going to be a little more difficult as multiple positions will need to be stored at each key.  However, we know already that the initial data structure needs to be a hash-map and the keys need to be the item type.
    274274
    275275{{{
     
    291291
    292292{{{
    293 client.core=> (send-and-get :Bob :radar :now [8000] {} (fn [prev [_ item-type & pos]] (merge-with concat prev {item-type (list pos)})))
     293client.core=> (send-and-get :Bob :radar :now [8000]
     294                            {}
     295                            (fn [prev [_ item-type & pos]]
     296                              (merge-with concat prev {item-type (list pos)})))
    294297{"quagent_item_gold" (("375.085327" "56.309933" "1.374918") ... (output truncated)
    295298client.core=> (pp)
     
    310313}}}
    311314
     315These positions can't be used as strings, however, and will need to be converted to doubles.
     316
     317{{{
     318client.core=> (send-and-get :Bob :radar :now [8000]
     319                            {}
     320                            (fn [prev [_ item-type & pos]]
     321                              (merge-with concat
     322                                          prev
     323                                          {item-type (list (map #(Double/parseDouble %)
     324                                                                pos))})))
     325{"quagent_item_gold" ((375.085327 56.309933 1.374918) (1019.278626 42.455196 0.505915) ... (output-truncated)
     326client.core=> (pp)
     327{"quagent_item_gold"
     328 ((375.085327 56.309933 1.374918)
     329  (1019.278626 42.455196 0.505915)
     330  (905.141357 8.130102 0.569713)),
     331 "quagent_item_treasure"
     332 ((572.16864 20.462269 0.901278) (697.711304 63.434952 0.739097)),
     333 "info_player_deathmatch"
     334 ((32.000244 -90.0 0.223811) (0.125 0.0 90.0)),
     335 "player" ((768.875366 90.065201 0.0) (32.0 -90.0 0.0))}
     336nil
     337
     338}}}
     339
    312340
    313341