STRANAXFRM(3pub)

✨ STRANAXFRM ✨ (that's stranaxfrm from section 3pub of the C Programmer's Manual, bestie πŸ’–)


🌸 NAME 🌸

stranaxfrm β€” the glow-up function that turns a string into its canonical form so you can do anagram comparisons πŸ‘‘πŸ¦‹


πŸ’… SYNOPSIS πŸ’…

#include <publib.h>
char *stranaxfrm(char *str);

πŸŽ€ DESCRIPTION πŸŽ€

okay so. stranaxfrm takes a string and transforms it into a canonical form for anagram comparisons. that's the whole vibe. ✨

want to know if two strings are anagrams of each other? (iykyk: same characters, just shuffled around, different order, chaos.) then you literally just compare their canonical forms. that's it. that's the trick. πŸ’–

and what is the canonical form, you ask? it's the string with all its characters sorted into ascending order. periodt. πŸŽ€

so say you want to write a program that finds anagrams. here's the main character plan:

  1. convert a word list into canonical order first 🌈
  2. then look up words in that version of the word list, by transforming each word you're checking into canonical order too

boom. matching canonical forms = anagrams. slay. πŸ”₯


πŸ’œ RETURN VALUE πŸ’œ

stranaxfrm returns its argument. yes, the same pointer you handed it. it just hands it right back. 🫢


πŸ’€ BUGS πŸ’€

This function is of a whimsical nature. πŸ™ˆ

that's it. that's the bug report. it's silly on purpose, bestie. no cap.


🌈 SEE ALSO 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Lars Wirzenius (lars.wirzenius@helsinki.fi) πŸ’œ


okay that's the whole page, bestie, you ate it πŸ“βœ¨ this was STRANAXFRM(3pub) from the Publib C Programmer's Manual β€” mwah, go sort some characters πŸ’…πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from