Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
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
Model registry
Operate
Environments
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
Tej Chajed
stdpp
Commits
963a070d
Commit
963a070d
authored
8 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Function to break a string up into words.
parent
d566b5f1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/strings.v
+15
-1
15 additions, 1 deletion
theories/strings.v
with
15 additions
and
1 deletion
theories/strings.v
+
15
−
1
View file @
963a070d
...
...
@@ -25,6 +25,21 @@ Fixpoint string_rev_app (s1 s2 : string) : string :=
end
.
Definition
string_rev
(
s
:
string
)
:
string
:=
string_rev_app
s
""
.
(* Break a string up into lists of words, delimited by white space *)
Fixpoint
words_go
(
cur
:
option
string
)
(
s
:
string
)
:
list
string
:=
match
s
with
|
""
=>
option_list
(
string_rev
<$>
cur
)
|
String
" "
s
=>
option_list
(
string_rev
<$>
cur
)
++
words_go
None
s
|
String
a
s
=>
words_go
(
Some
(
default
(
String
a
""
)
cur
(
String
a
)))
s
end
.
Definition
words
:
string
→
list
string
:=
words_go
None
.
Ltac
words
s
:=
match
type
of
s
with
|
list
string
=>
s
|
string
=>
eval
vm_compute
in
(
words
s
)
end
.
(** * Encoding and decoding *)
(** In order to reuse or existing implementation of radix-2 search trees over
positive binary naturals [positive], we define an injection [string_to_pos]
...
...
@@ -71,4 +86,3 @@ Program Instance string_countable : Countable string := {|
encode
:=
string_to_pos
;
decode
p
:=
Some
(
string_of_pos
p
)
|}
.
Solve
Obligations
with
naive_solver
eauto
using
string_of_to_pos
with
f_equal
.
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