Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;How can I make [transactions] not an external reference in my deftype Portfolio?
- (defrecord Tx [date symbol type qty price])
- (defrecord Tick [date symbol price])
- (defprotocol IPortfolio
- (add [this tx] "Add transaction to portfolio")
- (del [this index] "Remove transaction from portfolio")
- (size [this] "Number of transactions")
- (view [this] "Return all transactions")
- )
- ;transactions - ref to vector
- (deftype Portfolio [transactions]
- IPortfolio
- (add [this transaction]
- (dosync (alter transactions conj transaction)))
- (del [this index]
- (dosync (commute transactions delete-element index)))
- (size [this]
- (count @transactions))
- (view [this]
- @transactions)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement