Setting up hash items at once

Started by vetelko, August 15, 2017, 02:39:33 AM

Previous topic - Next topic

vetelko

Hi guys,

is it possible to set hash items at once in hash definition?



;; 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"))
newLISP v.10.7.6 64-bit on BSD IPv4/6 UTF-8 libffi

varbanov

#1
Hi,



Try

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


s.v.

rrq

#2
And you can of course combine it into a single phrase like ((or (define cities:cities) cities)
  '(("ny" "new york")  ("sf" "san francisco")))
but it's not very intelligible.