Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.misc > #11872
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.lang.misc, comp.lang.c++ |
| Subject | Re: Resources to learn common lisp? |
| Date | 2026-09-18 10:25 +0000 |
| Organization | Stefan Ram |
| Message-ID | <filter-20260918111700@ram.dialup.fu-berlin.de> (permalink) |
| References | (20 earlier) <87fr01mplp.fsf@nightsong.com> <87tsogiuxx.fsf@safunu.org> <expressiveness-20260827111602@ram.dialup.fu-berlin.de> <expressiveness-20260827113139@ram.dialup.fu-berlin.de> <HE1rS.267354$nBp.117827@fx02.ams4> |
Cross-posted to 2 groups.
"Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> wrote or quoted:
>> // Helper to sanitize a word to lowercase alphanumeric characters
>> auto sanitize = [](std::string w) {
>> auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
>> | std::views::transform([](char c) { return std::tolower(c); });
>> return std::string(clean.begin(), clean.end());
>> };
>Here, it seems the variable /clean/ is completely superfluous [1].
I'm not sure I know what code you have in mind that does not use
that variable.
>Wouldn't it be much better if std::string() -- the constructor -- could
>just use the filter directly? I mean, something like this, instead; un-
>tested.
> return std::string( w | filter | transform ) ;
Well, one /can/ write
auto sanitize = []( ::std::string w ) {
return w | std::views::filter( []( char c ){ return ::std::isalnum( c ); })
| std::views::transform( []( char c ){ return ::std::tolower( c ); })
| std::ranges::to< ::std::string >();
};
.
> auto sanitize = []( ::std::string w ) return ::std::string( w | filter |
> transform ) ;
So, I assume that you would still have to define that "filter"
does "isalnum" and that "transform" does "tolower" somewhere?
What you can do is to define,
inline constexpr auto filter = std::views::filter( []( char c ){ return ::std::isalnum( c ); });
inline constexpr auto transform = std::views::transform( []( char c ){ return ::std::tolower( c ); });
, outside of a function (before "int main()") and then use,
auto sanitize = []( ::std::string w ) {
return w | filter | transform | ::std::ranges::to< ::std::string >();
};
.
Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 19:38 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 12:22 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 21:04 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 13:18 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 22:16 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 20:10 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-25 10:34 +0800
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-24 17:10 -0700
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-25 10:41 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-25 09:22 +0000
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-25 22:13 -0700
Re: Resources to learn common lisp? Anton Antimo <anton@safunu.org> - 2026-08-26 15:43 -0300
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-26 18:23 -0700
Re: Resources to learn common lisp? Anton Antimo <anton@safunu.org> - 2026-08-28 17:29 -0300
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-08-27 10:17 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-08-27 10:47 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 10:49 +0800
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 10:25 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 11:05 +0800
Re: Resources to learn common lisp? red floyd <no.spam.here@its.invalid> - 2026-09-17 21:43 -0700
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 10:28 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-18 21:33 +0800
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 13:51 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 14:23 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 15:18 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 00:07 +0800
Resources to learn Japanese (was: Resources to learn common lisp?) ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 16:52 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-18 15:11 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 15:25 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-18 15:49 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 16:05 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-19 08:29 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 16:50 +0800
Re: Resources to learn common lisp? David Brown <david.brown@hesbynett.no> - 2026-09-18 18:18 +0200
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 00:35 +0800
Why no string switch? (was: Resources to learn common lisp?) ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-19 12:46 +0000
Re: Why no string switch? (was: Resources to learn common lisp?) boltar@caprica.universe - 2026-09-19 14:47 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 23:39 +0800
csiph-web