Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
alexandria
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Momchil Ivanov
alexandria
Commits
d92432dd
Commit
d92432dd
authored
Dec 21, 2011
by
Ryan Davis
Committed by
Nikodemus Siivola
Jan 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert ENSURE-GETHASH into a macro
Evaluate the default-form only if we actually use it.
parent
77b219a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
hash-tables.lisp
hash-tables.lisp
+5
-5
No files found.
hash-tables.lisp
View file @
d92432dd
...
...
@@ -89,11 +89,11 @@ PLIST. Hash table is initialized using the HASH-TABLE-INITARGS."
(
setf
(
gethash
(
car
tail
)
table
)
(
cadr
tail
)))
table
))
(
def
un
ensure-gethash
(
key
hash-table
&optional
default
)
(
def
macro
ensure-gethash
(
key
hash-table
&optional
default
)
"Like GETHASH, but if KEY is not found in the HASH-TABLE saves the DEFAULT
under key before returning it. Secondary return value is true if key was
already in the table."
(
multiple-value-bind
(
value
ok
)
(
gethash
key
hash-table
)
(
if
ok
(
values
value
ok
)
(
values
(
setf
(
gethash
key
hash-table
)
default
)
nil
))))
`
(
multiple-value-bind
(
value
ok
)
(
gethash
,
key
,
hash-table
)
(
if
ok
(
values
value
ok
)
(
values
(
setf
(
gethash
,
key
,
hash-table
)
,
default
)
nil
))))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment