Skip to content

Instantly share code, notes, and snippets.

@urbanslug
Created July 3, 2019 17:27
Show Gist options
  • Save urbanslug/6271580b91a6b7bd45e1bbbfbc5caccb to your computer and use it in GitHub Desktop.
Save urbanslug/6271580b91a6b7bd45e1bbbfbc5caccb to your computer and use it in GitHub Desktop.
;; TODO: represent bases in binary
(serializable-struct
node*
(sequence id offset edges)
#:transparent)
;; adjacent-nodes is a set of edges out of the node
;; Should I replace UUID with a cryptographic hash of the sequence?
;; a negative offset means the offset for the node isn't yet determined
(define (node sequence [id (uuid-generate)] [offset -1] (adj (set)))
(node* sequence id offset adj))
;; doesn't mutate the node
;; not allowed to change node id
;; if you want to do that remove the node and generate a new one?
;; What about all adjacent nodes? how do we update those?
;; how can we make this faster?
(define (update-node n #:sequence [seq false] #:offset [offset false] #:edges [edges false])
(let ([s (or seq (node*-sequence n))]
[i (node*-id n) ]
[o (or offset (node*-offset n))]
[e (or edges (node*-edges n))])
(node s i o e)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment