Changeset 12092


Ignore:
Timestamp:
May 19, 2009, 9:18:56 PM (10 years ago)
Author:
gz
Message:

Public interface to populations

Location:
branches/working-0711/ccl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/lib/ccl-export-syms.lisp

    r12091 r12092  
    418418     *static-cons-chunk*
    419419     static-cons
     420
     421     population
     422     make-population
     423     population-type
     424     population-contents
    420425
    421426     compiler-let
  • branches/working-0711/ccl/lib/misc.lisp

    r11089 r12092  
    658658
    659659
     660
     661(defun make-population (&key (type :list) initial-contents)
     662  (let* ((ntype (ecase type
     663                  (:list $population_weak-list)
     664                  (:alist $population_weak-alist)))
     665         (list (if (eq type :alist)
     666                 (map 'list (lambda (c) (cons (car c) (%cdr c))) initial-contents)
     667                 (if (listp initial-contents)
     668                   (copy-list initial-contents)
     669                   (coerce initial-contents 'list)))))
     670    (%cons-population list ntype)))
     671
     672(defun population-type (population)
     673  (let ((ntype (population.type (require-type population 'population))))
     674    (cond ((eq ntype $population_weak-alist) :alist)
     675          ((eq ntype $population_weak-list) :list)
     676          (t nil))))
     677
     678(declaim (inline population-contents (setf population-contents)))
     679
     680(defun population-contents (population)
     681  (population.data (require-type population 'population)))
     682
     683(defun (setf population-contents) (list population)
     684  (setf (population.data (require-type population 'population)) (require-type list 'list)))
     685
     686
     687
     688
    660689(defun get-string-from-user (prompt)
    661690  (with-terminal-input
Note: See TracChangeset for help on using the changeset viewer.