;;;; Copyright (C) 2020 Julien Lepiller ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public ;;;; License as published by the Free Software Foundation; either ;;;; version 3 of the License, or (at your option) any later version. ;;;; ;;;; This library is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;;; Lesser General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Lesser General Public ;;;; License along with this library; if not, write to the Free Software ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;;;; (define-module (jsonld term-selection) #:use-module (jsonld json) #:export (term-selection)) (define* (term-selection inverse-context var containers type/language preferred-values) (let ((container-map (assoc-ref inverse-context var)) (result #nil)) ;; 2 (for-each (lambda (container) ;; 2.1 (when (json-has-key? container-map container) ;; 2.2 (let* ((type/language-map (assoc-ref container-map container)) ;; 2.3 (value-map (assoc-ref type/language-map type/language))) (for-each (lambda (item) (when (json-has-key? value-map item) (unless result (set! result (assoc-ref value-map item))))) preferred-values)))) containers) ;; 3 result))