On 9/26/24 4:51 PM, Lawrence D'Oliveiro wrote:
On Thu, 26 Sep 2024 16:18:01 GMT, Charlie Gibbs wrote:
One of the favourite functions in my library pulls the next token from a
delimited string, but as opposed to strtok() it does it
non-destructively and can handle empty strings.
Use a high-level language which has all this and more:
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
Output:
the
quick
brown
fox
In Python, strings are objects, and that applies to string expressions
(including string literals) as well.
Ya know ... most of Python IS 'C'-based libs.
Never really looked into it, but the 'advanced'
Python function may just be strtok() with a
lot of handy fixes/cheats in disguise :-)
First you make COPIES of the source string ...
Look, then look DEEPER.
WAY back, latter 70s, Bill Gates used to participate
in 'contests' to see How To Do It In The Least
Bytes/Cycles/Mem - and often won. I do REMEMBER his name
from Way Back When. As such, despite all after, I do
NOT doubt his coding acumen.
The follow-on that a LOT of today's code is
STILL Bill Gates code - just adapted for a
particular chip. Smart ASM that got put
into the libs for almost every computer
language/OS/BIOS and whatever.
There IS 'depth' to all this.
Microprocessors CHANGED EVERYTHING.
Oh, Python 'strings' are ULTIMATELY just
a stretch of memory filled with various
values. The "object" stuff, a carefully-
crafted ILLUSION :-)
I started with ASM ... pre-4004/8008 ... as
such I see things more at their basic level.
Oh, recently found an ADVERT for a "desktop",
more an entire DESK, 8008 all-purpose/wonderful
8008 system. You could buy it with a nice serial
terminal AND a - gasp ! - floppy-disk drive
or, cheap-asses, a tape CASSETTE drive :-)
The first 'floppies' of MY experience were 8-inch
floppies. Huge, actually "floppy", didn't hold much
of DICK.
Ah how times have changed ! You don't even have to
solder-together your own I/O boards anymore !
SO boring ......