Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
5af76d1a
Commit
5af76d1a
authored
24 years ago
by
pw
Browse files
Options
Downloads
Patches
Plain Diff
Fix butlast and nbutlast to be correct for NIL argument.
parent
d1d6f622
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/list.lisp
+27
-25
27 additions, 25 deletions
code/list.lisp
with
27 additions
and
25 deletions
code/list.lisp
+
27
−
25
View file @
5af76d1a
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
;;;
(
ext:file-comment
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.2
2 1998/05/09 22:16:45
pw Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.2
3 2000/11/15 11:36:34
pw Exp $"
)
;;;
;;;
;;; **********************************************************************
;;; **********************************************************************
;;;
;;;
...
@@ -359,34 +359,36 @@
...
@@ -359,34 +359,36 @@
"Returns a new list the same as List without the last N conses.
"Returns a new list the same as List without the last N conses.
List must not be circular."
List must not be circular."
(
declare
(
list
list
)
(
type
index
n
))
(
declare
(
list
list
)
(
type
index
n
))
(
let
((
length
(
do
((
list
list
(
cdr
list
))
(
unless
(
null
list
)
(
i
0
(
1+
i
)))
(
let
((
length
(
do
((
list
list
(
cdr
list
))
((
atom
list
)
(
1-
i
)))))
(
i
0
(
1+
i
)))
(
declare
(
type
index
length
))
((
atom
list
)
(
1-
i
)))))
(
unless
(
<
length
n
)
(
declare
(
type
index
length
))
(
do*
((
top
(
cdr
list
)
(
cdr
top
))
(
unless
(
<
length
n
)
(
result
(
list
(
car
list
)))
(
do*
((
top
(
cdr
list
)
(
cdr
top
))
(
splice
result
)
(
result
(
list
(
car
list
)))
(
count
length
(
1-
count
)))
(
splice
result
)
((
=
count
n
)
result
)
(
count
length
(
1-
count
)))
(
declare
(
type
index
count
))
((
=
count
n
)
result
)
(
setq
splice
(
cdr
(
rplacd
splice
(
list
(
car
top
)))))))))
(
declare
(
type
index
count
))
(
setq
splice
(
cdr
(
rplacd
splice
(
list
(
car
top
))))))))))
(
defun
nbutlast
(
list
&optional
(
n
1
))
(
defun
nbutlast
(
list
&optional
(
n
1
))
"Modifies List to remove the last N conses. List must not be circular."
"Modifies List to remove the last N conses. List must not be circular."
(
declare
(
list
list
)
(
type
index
n
))
(
declare
(
list
list
)
(
type
index
n
))
(
let
((
length
(
do
((
list
list
(
cdr
list
))
(
unless
(
null
list
)
(
i
0
(
1+
i
)))
(
let
((
length
(
do
((
list
list
(
cdr
list
))
((
atom
list
)
(
1-
i
)))))
(
i
0
(
1+
i
)))
(
declare
(
type
index
length
))
((
atom
list
)
(
1-
i
)))))
(
unless
(
<
length
n
)
(
declare
(
type
index
length
))
(
do
((
1st
(
cdr
list
)
(
cdr
1st
))
(
unless
(
<
length
n
)
(
2nd
list
1st
)
(
do
((
1st
(
cdr
list
)
(
cdr
1st
))
(
count
length
(
1-
count
)))
(
2nd
list
1st
)
((
=
count
n
)
(
count
length
(
1-
count
)))
(
rplacd
2nd
())
((
=
count
n
)
list
)
(
rplacd
2nd
())
(
declare
(
type
index
count
))))))
list
)
(
declare
(
type
index
count
)))))))
(
defun
ldiff
(
list
object
)
(
defun
ldiff
(
list
object
)
"Returns a new list, whose elements are those of List that appear before
"Returns a new list, whose elements are those of List that appear before
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment