yaltik_odoo_custom/hy_odoo/mgeneral.hy

23 lines
642 B
Hy

;; Copyright 2021-2022 Fabien Bourgeois <fabien@yaltik.com>
;;
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at https://mozilla.org/MPL/2.0/.
" Hy General Macros "
(defmacro instance? [type record] `(isinstance ~record ~type))
(defmacro hydict [dic]
"Generate dict with mangled keys, from HyDict list"
(setv mangled-dic
(list
(map
(fn [pair]
(if (even? (nth pair 0))
(hy.mangle (nth pair 1))
(nth pair 1)))
(enumerate dic))))
`{~@mangled-dic})