Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kamil Shakirov
alexandria
Commits
549dd8e1
Commit
549dd8e1
authored
Apr 02, 2016
by
Jan Moringen
Browse files
make STARTS-WITH-SUBSEQ not cons unnecessarily
parent
5a17c072
Changes
1
Hide whitespace changes
Inline
Side-by-side
sequences.lisp
View file @
549dd8e1
...
...
@@ -280,16 +280,22 @@ sequence, is an empty sequence, or if OBJECT cannot be stored in SEQUENCE."
:datum
sequence
:expected-type
'
(
and
proper-sequence
(
not
(
satisfies
emptyp
))))))))
(
defun
starts-with-subseq
(
prefix
sequence
&rest
args
&key
(
return-suffix
nil
)
&allow-other-keys
)
(
defun
starts-with-subseq
(
prefix
sequence
&rest
args
&key
(
return-suffix
nil
return-suffix-supplied-p
)
&allow-other-keys
)
"Test whether the first elements of SEQUENCE are the same (as per TEST) as the elements of PREFIX.
If RETURN-SUFFIX is T the function
s
returns, as a second value, a
If RETURN-SUFFIX is T the function returns, as a second value, a
displaced array pointing to the sequence after PREFIX."
(
remove-from-plistf
args
:return-suffix
)
(
declare
(
dynamic-extent
args
)
)
(
let
((
sequence-length
(
length
sequence
))
(
prefix-length
(
length
prefix
)))
(
if
(
<=
prefix-length
sequence-length
)
(
let
((
mismatch
(
apply
#'
mismatch
prefix
sequence
args
)))
(
let
((
mismatch
(
apply
#'
mismatch
prefix
sequence
(
if
return-suffix-supplied-p
(
remove-from-plist
args
:return-suffix
)
args
))))
(
if
mismatch
(
if
(
<
mismatch
prefix-length
)
(
values
nil
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