SHARE
TWEET

Untitled

a guest Jun 12th, 2013 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;How can I make [transactions] not an external reference in my deftype Portfolio?
  2.  
  3. (defrecord Tx [date symbol type qty price])
  4. (defrecord Tick [date symbol price])
  5.  
  6. (defprotocol IPortfolio
  7.         (add [this tx] "Add transaction to portfolio")
  8.         (del [this index] "Remove transaction from portfolio")
  9.         (size [this] "Number of transactions")
  10.         (view [this] "Return all transactions")
  11.         )
  12.        
  13.  
  14. ;transactions - ref to vector
  15.  
  16. (deftype Portfolio [transactions]
  17.         IPortfolio
  18.         (add [this transaction]
  19.                 (dosync (alter transactions conj transaction)))
  20.                
  21.         (del [this index]
  22.                 (dosync (commute transactions delete-element index)))
  23.                
  24.         (size [this]
  25.                 (count @transactions))
  26.                
  27.         (view [this]
  28.                 @transactions)
  29. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top