Skip to content

Instantly share code, notes, and snippets.

@lgaff
Created October 29, 2019 04:13
Show Gist options
  • Save lgaff/95d08dab5278fdfbfc54711b6bfbece5 to your computer and use it in GitHub Desktop.
Save lgaff/95d08dab5278fdfbfc54711b6bfbece5 to your computer and use it in GitHub Desktop.
(defn ram [start length & {:keys [paged-in bank tag]
:or {paged-in false
bank 0}}]
;; I want to check here if :tag was added or not. But also i don't want to because style
(make-memory start length paged-in bank :text (vec (replicate length 0)) :writable true))
(defn- make-memory [start length paged-in bank & {:keys [text writable tag]}]
;; TODO: Maybe check that length and end - start are the same; fill with zeros if not.
{:start start
:end (+ start length)
:bank bank
:writable writable
:text text
:paged-in false}
; :tag would go here if it were passed. Or not elsewise.
)
@bfabry
Copy link

bfabry commented Oct 29, 2019

(defn ram [start length {:keys [paged-in bank] :or [page-in false bank 0] :as mem-map}]
  (make-memory start length (assoc mem-map :paged-in paged-in :bank bank))

(defn make-memory [start length mem-map]
  (assoc mem-map :start start :end (+ start length)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment