GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) πŸ’–

ok so bestie, welcome to the GOLF(2gg) page, living under Development in section 2gg πŸŽ€ this one's about the delete-tree fam and it's honestly so useful, no cap.


✨ NAME ✨

delete-tree β€” like, the tree one? 🫢 (that's literally what the original says: "delete-tree - (tree)", so yes, it's giving tree energy)


🎯 PURPOSE 🎯

Delete a node from a tree. that's it. that's the whole vibe. πŸ’…


🌸 SYNTAX 🌸

delete-tree <tree> key <key> \
    [ status <status> ] \
    [ value <value> ] \

πŸ’œ DESCRIPTION πŸ’œ

ok so delete-tree will go search <tree> for the string <key>, and if it finds it? it deletes that node (and yes, the key inside it comes along too, bye bye πŸ‘‹), sets <value> (that's the one in the "value" clause) to the node's value, and sets the <status> number (the one in the "status" clause) to GG_OKAY. slay.

but listen, if <key> is not found, then <status> is gonna be GG_ERR_EXIST 😭 like the key just wasn't there bestie.

and the important little caveat: if <status> is not GG_OKAY, then <value> is unchanged. so don't be out here reading <value> expecting fresh data when the status said no. πŸ‘‘ that's the rule, periodt.


πŸ¦‹ EXAMPLES πŸ¦‹

delete a node with key "123", and get its value back:

set-string k = "123"
delete-tree mytree key k value val status st
if-true st not-equal GG_OKAY
   @Could not find key <<print-out k>>
   exit-handler
end-if
// display key/value deleted
@Deleted key <<print-out k>> with value <<print-out val>>
// delete the original value
delete-string val

see how it checks st first before trusting val? that's the whole point, main character behavior fr fr. πŸ”₯


🌈 SEE ALSO 🌈

  • Tree 🌳
  • delete-tree get-tree new-tree purge-tree read-tree use-cursor write-tree
  • See all documentation

πŸ’Œ little reminder bestie: this whole thing lives in the GOLF(2gg) manual, under Development, and it's sourced from $DATE / $VERSION β€” that's the version stamp, iykyk. go delete some tree nodes, you got this πŸ’–βœ¨πŸŽ€
πŸ“¦ where this page comes from