Page 1 of 1

Setting up hash items at once

PostPosted: Tue Aug 15, 2017 9:39 am
by vetelko
Hi guys,
is it possible to set hash items at once in hash definition?

Code: Select all
;; this works
(define cities:cities)
(cities "ny" "new york")
(cities "sf" "san francisco")
(println (cities "sf"))

;; this not
(define cities:cities '(
    ("ny" "new york")
    ("sf" "san francisco")))

(println (cities "sf"))

Re: Setting up hash items at once

PostPosted: Fri Aug 18, 2017 8:19 am
by varbanov
Hi,

Try
Code: Select all
(define cities:cities)         ; creates the default functor
(cities '(("ny" "new york") ("sf" "san francisco")))        ; the functor adds the data
(cities)


s.v.

Re: Setting up hash items at once

PostPosted: Fri Aug 18, 2017 10:38 pm
by ralph.ronnquist
And you can of course combine it into a single phrase like
Code: Select all
((or (define cities:cities) cities)
  '(("ny" "new york")  ("sf" "san francisco")))
but it's not very intelligible.