mchartable_map(3m17n)

πŸ“¦
version 1.8.4 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

mchartable_map β€” it's giving "map a function over a chartable" energy, bestie πŸ’… (the original page left the one-liner blank, so we're keeping it iconic and mysterious, fr fr)


🌸 SYNOPSIS 🌸

int mchartable_map (MCharTable * table, void * ignore, void(*)(int, int,
void *, void *) func, void * func_arg)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. mchartable_map() calls the function func for characters in the chartable table. That's the whole vibe. πŸ’–

Here's the lil catch tho: if a character in table has the value ignore, then no function call happens for it. None. Skipped. Not invited to the party. πŸ™ˆ

And the way it checks whether a character's value is ignore? It literally just uses the operator ==. That's it. So be careful when you use string literals or pointers β€” because == on those does not compare what you think it compares, and that's a you problem, not a mchartable_map() problem. 😭

Now the glow-up part ✨: instead of calling func once per character (so extra, so many function calls), mchartable_map() tries to optimize the number of function calls. How? It makes a single function call for a whole chunk of characters whenever those consecutive characters all have the same value. Efficiency queen. πŸ‘‘

No matter how long that character chunk is β€” tiny baby chunk, absolutely massive chunk, doesn't matter β€” func is always called with four arguments:

  • from
  • to
  • val
  • arg

from and to (both inclusive, bestie, don't forget) define the range of characters that have the value val. And arg is the exact same thing as func_arg. Periodt. πŸ’…


⭐ RETURN VALUE ⭐

This function always returns 0. Always. Every single time. No drama, no surprises, just a solid zero. 🫢


Copyright (C) 2001 Information-technology Promotion Agency (IPA)

Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>.


aaaand that's the whole page, bestie πŸŽ€ it's from Version 1.8.4, dated Mon Sep 25 2023, and it lives in The m17n Library manual β€” mchartable_map(3m17n), no cap. go forth and map those characters πŸ’œπŸŒˆ

πŸ“¦ where this page comes from