feat: add path and collection standard library helpers

This commit is contained in:
Hermes Agent
2026-07-09 21:04:25 -06:00
parent f907cfb63c
commit c66c122c30
10 changed files with 182 additions and 42 deletions
+16
View File
@@ -0,0 +1,16 @@
IMPORT "lib/path.claro" AS path
CALL path.join WITH "notes", "today.txt"
SAY RESULT
CALL path.basename WITH "notes/today.txt"
SAY RESULT
CALL path.dirname WITH "notes/today.txt"
SAY RESULT
CALL path.ext WITH "notes/today.txt"
SAY RESULT
CALL path.stem WITH "notes/today.txt"
SAY RESULT
CALL path.absolute WITH "/home/learner"
SAY RESULT
CALL path.absolute WITH "notes/today.txt"
SAY RESULT
+7
View File
@@ -0,0 +1,7 @@
notes/today.txt
today.txt
notes
txt
today
YES
NO
+31
View File
@@ -0,0 +1,31 @@
IMPORT "lib/collections.claro" AS collections
SET words AS LIST OF TEXT TO LIST
ADD "Ada" TO words
ADD "Grace" TO words
ADD "Lin" TO words
CALL collections.length WITH words
SAY RESULT
CALL collections.contains WITH words, "Grace"
SAY RESULT
CALL collections.index WITH words, "Lin"
SAY RESULT
CALL collections.join WITH words, " | "
SAY RESULT
CALL collections.reversed WITH words
SET backwards TO RESULT
GET backwards AT 1 AS first
SAY first
SET scores AS MAP OF NUMBER TO MAP
PUT scores KEY "math" VALUE 95
PUT scores KEY "science" VALUE 88
CALL collections.has_key WITH scores, "math"
SAY RESULT
CALL collections.get WITH scores, "science", 0
SAY RESULT
CALL collections.keys WITH scores
SET subjects TO RESULT
COUNT subjects AS subjectCount
SAY subjectCount
+8
View File
@@ -0,0 +1,8 @@
3
YES
3
Ada | Grace | Lin
Lin
YES
88
2