Comments (2)
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.
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)
- Maybe do not use &REST as a lexical variable
- Improve documentation string for generic function FINISH
- In make-keyword-argument, handle base cases first
- Starting ASDF system definitions by (in-package #:asdf-user) HOT 2
- Improve comment for make-keyword-arguments
- Hard to parse phrase in the documentation string of add-relations.
- Incorrect indentation in add-relations
- Incorrect indentation of class-initarg-and-relation-slots HOT 2
- Definition of relation-slot? looks very strange. HOT 2
- Hard to understand documentation string of cardinality-case. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from architecture.builder-protocol.