Created
May 14, 2017 08:35
-
-
Save useronym/9d79cc2769e57d02e41b5144b6267fb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro tupleize-record (rec-name) | |
`(lambda (rec) | |
,(lists:map (lambda (field-name) | |
(tuple field-name (rec-get rec-name field-name))) | |
(rec-fields rec-name)))) | |
(defmacro rec-fields (name) | |
`(,(ltoa (++ "fields-" (atol name))))) | |
(defmacro rec-get (name field) | |
`(lambda (rec) (,(ltoa (++ (atol name) "-" (atol field))) rec))) | |
(defun atol (a) | |
(atom_to_list a)) | |
(defun ltoa (l) | |
(list_to_atom l)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment