Git Product home page Git Product logo

Comments (2)

robert-strandh avatar robert-strandh commented on July 18, 2024

Here is a complete version with improved comments and with appropriate
markup:

;;; This function exists solely for efficiency reasons. Given keyword
;;; arguments with sequences of values such as
;;;
;;;   (:KEY₁ (VALUE₁₁ VALUE₁₂ …) :KEY₂ (VALUE₂₁ VALUE₂₂ …) …)
;;;
;;; , this function constructs a keyword argument list of the form
;;;
;;;   (:KEY₁ VALUE₁₁ :KEY₂ VALUE₂₁ …)
;;;
;;; and a function that destructively replaces each value with the
;;; next value.  This function returns two values.  The first value is
;;; initially (:KEY₁ NIL :KEY₂ NIL …) and the second values is the
;;; destructive function.  An initial call to the destructive function
;;; replaces the NILs in the first value by VALUE₁₁ and VALUE₂₁.  Once
;;; all the VALUES of a list have been exhausted, a call to the
;;; destructive function inserts a NIL as the VALUE.
(defun make-keyword-arguments (multi-keyword-arguments)
  (loop for (keyword values) on multi-keyword-arguments by #'cddr
        ;; The following two clauses construct the initial list
        ;;(:KEY₁ NIL :KEY₂ NIL …) to be retuned as the first value.
        collect keyword into result
        collect nil into result
        ;; This clause constructions a list
        ;; ((VALUE₁₁ VALUE₁₂ …) (VALUE₂₁ VALUE₂₂ …) …)
        ;; to be traversed by the destructive function.
        collect values into values-list
        finally (return (values result
                                (lambda ()
                                  (loop ;; Loop over subsequent tails of
                                        ;; the returned list so that the
                                        ;; CAR of the first CONS cell of the
                                        ;; tail should be updated.
                                        for rest on (cdr result) by #'cddr
                                        ;; And loop over subsequenct tails
                                        ;; of the values list, so that the
                                        ;; CAR of of the first CONS cell of
                                        ;; the tail should be popped.
                                        for values on values-list
                                        do (setf (car rest) (pop (car values)))))))))

from architecture.builder-protocol.

robert-strandh avatar robert-strandh commented on July 18, 2024

Don't feel you need to take the iterative version over the existing one. It
is just how I may have written it myself.

from architecture.builder-protocol.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.