AI API 2/9: records and pattern matching #156

Closed
opened 2026-10-02 20:07:39 +00:00 by Winnie · 0 comments
Owner

The code is full of magic tuple indices: (nth o 0) for loan id, (nth o 1) for amount, and so on. Add:

  • (defrecord loan (id amount term defaultn)), (defrecord bond (price size turns-left)), (defrecord offer (price size turns-left))
  • accessors: loan-id, loan-amount, loan-term, loan-default
  • pattern matching: (match loan [(loan id amount term default) ...])

This alone prevents a large class of AI bugs. Acceptance: the market accessors return record-shaped values (or the records are constructible from them), and the brains stop using nth for tuples.

The code is full of magic tuple indices: (nth o 0) for loan id, (nth o 1) for amount, and so on. Add: - (defrecord loan (id amount term defaultn)), (defrecord bond (price size turns-left)), (defrecord offer (price size turns-left)) - accessors: loan-id, loan-amount, loan-term, loan-default - pattern matching: (match loan [(loan id amount term default) ...]) This alone prevents a large class of AI bugs. Acceptance: the market accessors return record-shaped values (or the records are constructible from them), and the brains stop using nth for tuples.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Winnie/bankwars#156
No description provided.