Zulip Chat Archive
Stream: new members
Topic: test if the first character of a string is an underscore?
Scott Morrison (Mar 05 2019 at 23:17):
I need to filter a big list of name
s, discarding all those whose last component starts with an underscore.
Scott Morrison (Mar 05 2019 at 23:17):
(Throw out all the auto-generated lemmas from the pattern matcher, etc.)
Scott Morrison (Mar 05 2019 at 23:17):
I can use (to_string n.components.ilast).to_list.head ≠ '_'
, but apparently on the scale I'm working this is slow.
Simon Hudon (Mar 05 2019 at 23:17):
That sounds like something that should exist in tactic.basic
Simon Hudon (Mar 05 2019 at 23:18):
A better way of getting the last component is (name.update_prefix
_ n).to_string`
Mario Carneiro (Mar 05 2019 at 23:19):
name.is_internal
?
Scott Morrison (Mar 05 2019 at 23:21):
I guess I need to read the C++ to find out what name.is_internal
actually does. :-)
Scott Morrison (Mar 05 2019 at 23:21):
I'll experiment, instead.
Mario Carneiro (Mar 05 2019 at 23:21):
I think it's exactly what you said
Scott Morrison (Mar 05 2019 at 23:21):
Great.
Scott Morrison (Mar 05 2019 at 23:22):
Any tricks for throwing out all private names? Currently I just do n.components.head ≠ "_private"
Mario Carneiro (Mar 05 2019 at 23:22):
you should probably not go via components
like that
Scott Morrison (Mar 05 2019 at 23:23):
Ok. I'll write my own name.is_private
by pattern matching?
Mario Carneiro (Mar 05 2019 at 23:24):
You could define a function for n.components.head
and then check that it equals "_private"
Scott Morrison (Mar 05 2019 at 23:24):
What should the function for n.components.head
be called?
Simon Hudon (Mar 05 2019 at 23:25):
head
Scott Morrison (Mar 05 2019 at 23:28):
What is name.mk_numeral
, anyway?
Mario Carneiro (Mar 05 2019 at 23:32):
it's an internal thing, you won't see it except in unique names for variables I think
Scott Morrison (Mar 05 2019 at 23:34):
Are names like cases_on
and inj_arrow
going to count as internal names?
Mario Carneiro (Mar 05 2019 at 23:34):
no, I think it's literally what you said
Mario Carneiro (Mar 05 2019 at 23:34):
it just checks for an initial underscore
Last updated: Dec 20 2023 at 11:08 UTC