site-josuah

/usr/josuah
Log | Files | Refs

commit 469c1b4c21fad9b22508f94c4a3aef6d00a3b6b3
parent 5f22f6ce9c4f95b913c7b60ac753e215ea878566
Author: Josuah Demangeon <me@josuah.net>
Date:   Wed, 24 Jun 2020 21:19:59 +0200

split static data into an array

Diffstat:
Mwiki/awk/index.md | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/wiki/awk/index.md b/wiki/awk/index.md @@ -50,7 +50,7 @@ $ awk ' UCL-style configuration ----------------------- -Parsing data that is not organised with line-column is also convenient and +Parsing data that is not organised with line-column is also convenient and efficient with awk, convenient for selecting one kind of value out of a configuration file: @@ -241,9 +241,21 @@ user 0m 3.00s sys 0m 0.10s ``` +Fill a static array +------------------- +With C and many other languages, there are convenient concise syntax such as +`{ "a", "b", "c", ...}`to fill an array with values. An well-known way is: + +``` +array["len"] = split("a b c ...", array, " ") +``` + +Then `array["len"]` contains the length (`length(array)` is unportable), +`array[1]` the first element `"a"`, `array[2]` the second, etc. + A fold_line() function ----------------------- -Convenient to work with text documents or emails. This version does not +Convenient to work with text documents or emails. This version does not truncate very long words, such as some https:// links. ``` @@ -407,7 +419,7 @@ leading Organization Unique Identifier (OUI) of 3 bytes and a trailing 3-byte number, unique for that OUI. Each vendor has its own OUI, so each OUI maps to a vendor. With the reference -list the [IEEE](https://ieee.org/) publishes, it is possible to convert MAC +list the [IEEE](https://ieee.org/) publishes, it is possible to convert MAC address OUI digits to a human-readable name: ```