summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-12-19 21:31:02 -0500
committerLLLL Colonq <llll@colonq>2025-12-19 21:31:02 -0500
commit0a6ce352be7d0a8a2cdb2f9a3ae3b0189c5f23b5 (patch)
treedc79bf6249ba90a384794954c1a06568a9ef6aa8 /src
parent2dfa52e475fbc5614f92cfbc42d5b25fc5b8eff2 (diff)
Add pit_plist_get
Diffstat (limited to 'src')
-rw-r--r--src/library.c8
-rw-r--r--src/runtime.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/src/library.c b/src/library.c
index 9a40646..5b04e51 100644
--- a/src/library.c
+++ b/src/library.c
@@ -325,13 +325,7 @@ void pit_install_library_io(pit_runtime *rt) {
static pit_value impl_plist_get(pit_runtime *rt, pit_value args) {
pit_value k = pit_car(rt, args);
pit_value vs = pit_car(rt, pit_cdr(rt, args));
- while (vs != PIT_NIL) {
- if (pit_eq(k, pit_car(rt, vs))) {
- return pit_car(rt, pit_cdr(rt, vs));
- }
- vs = pit_cdr(rt, vs);
- }
- return PIT_NIL;
+ return pit_plist_get(rt, k, vs);
}
void pit_install_library_plist(pit_runtime *rt) {
/* property lists / keyword arguments */
diff --git a/src/runtime.c b/src/runtime.c
index fcfe81a..86c5fea 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -701,6 +701,15 @@ pit_value pit_contains_eq(pit_runtime *rt, pit_value needle, pit_value haystack)
}
return PIT_NIL;
}
+pit_value pit_plist_get(pit_runtime *rt, pit_value k, pit_value vs) {
+ while (vs != PIT_NIL) {
+ if (pit_eq(k, pit_car(rt, vs))) {
+ return pit_car(rt, pit_cdr(rt, vs));
+ }
+ vs = pit_cdr(rt, vs);
+ }
+ return PIT_NIL;
+}
pit_value pit_free_vars(pit_runtime *rt, pit_value bound, pit_value body) {
i64 expr_stack_reset = rt->expr_stack->top;