diff --git a/data/combination.lisp b/data/combination.lisp index 3aea09bd8a85d1154a5c0f961b138cb67ca5481b..79252250b3d89efd192af5b02f7e02c33898b654 100644 --- a/data/combination.lisp +++ b/data/combination.lisp @@ -1,6 +1,6 @@ ;; Combinations ;; Liam Healy, Sun Mar 26 2006 - 11:51 -;; Time-stamp: <2010-06-29 08:55:43EDT combination.lisp> +;; Time-stamp: <2010-06-29 19:48:55EDT combination.lisp> ;; ;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy ;; Distributed under the terms of the GNU General Public License @@ -95,6 +95,7 @@ "Initialize the combination c to the lexicographically last combination, i.e. (n-k,n-k+1,...,n-1).") +#| (defmfun grid:copy-to-destination ((source combination) (destination combination)) "gsl_combination_memcpy" (((mpointer destination) :pointer) @@ -107,6 +108,7 @@ :documentation ; FDL "Copy the elements of the combination source into the combination destination. The two combinations must have the same size.") +|# ;;;;**************************************************************************** ;;;; Combination properties @@ -154,28 +156,28 @@ (defmfun combination-next (c) "gsl_combination_next" (((mpointer c) :pointer)) - :c-return :success-failure + :c-return (crtn :int) :inputs (c) :outputs (c) + :return ((when (success-failure crtn) c)) :documentation ; FDL - "Advance the combination c to the next combination - in lexicographic order and return T and c. If no further - combinations are available it return NIL and c with - c unmodified. Starting with the first combination and - repeatedly applying this function will iterate through all possible + "Advance the combination c to the next combination in lexicographic + order and return c. If no further combinations are available + it returns NIL. Starting with the first combination and repeatedly + applying this function will iterate through all possible combinations of a given order.") (defmfun combination-previous (c) "gsl_combination_prev" (((mpointer c) :pointer)) - :c-return :success-failure + :c-return (crtn :int) :inputs (c) :outputs (c) + :return ((when (success-failure crtn) c)) :documentation ; FDL - "Step backwards from the combination c to the - previous combination in lexicographic order, returning - T and c. If no previous combination is available it returns - NIL and c with c unmodified.") + "Step backwards from the combination c to the previous combination + in lexicographic order, returning c. If no previous combination is + available it returns NIL with c unmodified.") ;;;;**************************************************************************** ;;;; Examples and unit test @@ -188,15 +190,15 @@ (size comb)) (let ((comb (make-combination 4 2))) ; init-first, combination-next (init-first comb) - (loop collect (copy-seq (cl-array comb)) + (loop collect (grid:contents comb) while (combination-next comb))) (let ((comb (make-combination 4 2))) ; init-last, combination-previous (init-last comb) - (loop collect (copy-seq (cl-array comb)) + (loop collect (grid:contents comb) while (combination-previous comb))) (loop for i from 0 to 4 ; combination-next append (let ((comb (make-combination 4 i))) (init-first comb) - (loop collect (copy-seq (cl-array comb)) + (loop collect (grid:contents comb) while (combination-next comb))))) diff --git a/gsll.asd b/gsll.asd index 7357de6c901c9502aedad8d63793028d8ab6330a..b4acbe947e26f292892be1cfd7d4ef7573f30f10 100644 --- a/gsll.asd +++ b/gsll.asd @@ -1,6 +1,6 @@ ;; Definition of GSLL system ;; Liam Healy -;; Time-stamp: <2010-06-28 21:18:11EDT gsll.asd> +;; Time-stamp: <2010-06-29 19:26:27EDT gsll.asd> ;; ;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy ;; Distributed under the terms of the GNU General Public License @@ -81,7 +81,7 @@ ;(:file "copy-cl") (:file "array-tests" :depends-on ("both")) (:file "permutation" :depends-on ("foreign-array" "array-structs")) - ;(:file "combination" :depends-on ("foreign-array" "array-structs")) + (:file "combination" :depends-on ("foreign-array" "array-structs")) )) #+(or) (:file "polynomial" :depends-on (init data)) diff --git a/init/interface.lisp b/init/interface.lisp index f251e524c3784b5d78e2e4ecd5fcb9fac1e7121a..2f130de0265b57bfd11648d0d9781ac5bb4228f1 100644 --- a/init/interface.lisp +++ b/init/interface.lisp @@ -1,6 +1,6 @@ ;; Macros to interface GSL functions, including definitions necessary for defmfun. ;; Liam Healy -;; Time-stamp: <2010-06-27 18:03:21EDT interface.lisp> +;; Time-stamp: <2010-06-29 19:42:14EDT interface.lisp> ;; ;; Copyright 2009 Liam M. Healy ;; Distributed under the terms of the GNU General Public License @@ -59,7 +59,8 @@ (defun success-failure (value) "If status is either +success+ or +continue+, return T; otherwise, return NIL." - (member value (list +success+ +continue+))) + (when (member value (list +success+ +continue+)) + t)) (defun success-continue (value) "If status is +success+, return T, otherwise return NIL."