Bugfixes: add cljQuot/cljRem to runtime, quot/rem to interpreter. Cleanup: remove unused processAgentActions and sequtils import. 164 tests pass.

This commit is contained in:
2026-05-08 20:45:36 +03:00
parent 30fde68fed
commit 88866872be
6 changed files with 42 additions and 17 deletions
+16 -14
View File
@@ -281,6 +281,22 @@ proc cljMax*(args: seq[CljVal]): CljVal =
if args[i].kind == ckInt and result.kind == ckInt:
if args[i].intVal > result.intVal: result = args[i]
proc cljQuot*(a, b: CljVal): CljVal =
if a.kind == ckInt and b.kind == ckInt:
if b.intVal == 0:
raise newException(CatchableError, "Division by zero")
cljInt(a.intVal div b.intVal)
else:
raise newException(CatchableError, "quot requires integers")
proc cljRem*(a, b: CljVal): CljVal =
if a.kind == ckInt and b.kind == ckInt:
if b.intVal == 0:
raise newException(CatchableError, "Division by zero")
cljInt(a.intVal mod b.intVal)
else:
raise newException(CatchableError, "rem requires integers")
# ---- Comparison ----
proc cljNumEq*(args: seq[CljVal]): CljVal =
@@ -1011,20 +1027,6 @@ proc cljAgent*(v: CljVal): CljVal =
result = CljVal(kind: ckAgent, agentVal: v, agentBusy: false)
initLock(result.agentLock)
proc processAgentActions(agent: CljVal) =
withLock agent.agentLock:
while agent.agentQueue.len > 0:
let action = agent.agentQueue[0]
agent.agentQueue.delete(0)
var fargs = @[agent.agentVal]
fargs.add(action.args)
if action.fn.kind == ckFn:
agent.agentVal = action.fn.fnProc(fargs)
elif action.fn.kind == ckList:
# fn form: (fn [params] body) — use interpreter
discard
agent.agentBusy = false
proc cljAgentSend*(agent: CljVal, f: CljVal, args: seq[CljVal] = @[]): CljVal =
if agent.kind != ckAgent:
raise newException(CatchableError, "send requires an agent")