OSDN Git Service

10f7e8a95c530dec3e1e01e0a8c2430e2eafa98b
[rulp/rulp.git] / data.lisp
1 ;;;; Ru*** roLeplay Playground virtual tabletop
2 ;;;; Copyright (C) 2022  Zull
3 ;;;;
4 ;;;; This program is free software: you can redistribute it and/or modify
5 ;;;; it under the terms of the GNU General Public License as published by
6 ;;;; the Free Software Foundation, either version 3 of the License, or
7 ;;;; (at your option) any later version.
8 ;;;;
9 ;;;; This program is distributed in the hope that it will be useful,
10 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ;;;; GNU General Public License for more details.
13 ;;;;
14 ;;;; You should have received a copy of the GNU General Public License
15 ;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
16 (in-package :core)
17
18
19
20 ;; posso usare le hash piuttosto che interpretarlo sul momento. Infatti creerò un metodo che
21 ;; analizza json e lo traduce in una tabella hash e una funzione che prende la hash e crea
22 ;; l'oggetto tramite i metodi standard.
23 ;;
24 ;; (defparameter a (make-hash-table)) ; crea una hash con make-hash-table
25 ;; (gethash 'key a) ; recupera la hash con chiave key, questa è settable
26 (defun parse-list (linput)
27   (if (listp (car linput))
28       (loop :for l :in linput
29             :do
30                (parse-list l))
31       (FORMAT t "TEXT IS ~A, ~A AND ~A~%" (CAR LINPUT) (CADR LINPUT) (CADDR LINPUT)) ; devi ricordanti che i campi non sono (a b c) ma sono ((a1 . a2) (b1 . b2) (c1 . c2))
32       ))
33
34 (defun decompose-alist (alist search-list)
35   (apply 'concatenate 'list
36          (loop :for search-term :in search-list
37                :collect
38                (when (assoc search-term alist)
39                  (list search-term
40                        (cdr (assoc search-term alist))))
41                )))