Skip to content

Instantly share code, notes, and snippets.

@singaltanmay
Created September 13, 2023 04:21
Show Gist options
  • Save singaltanmay/1a549f55d3b8e44c7d5616cb7769709a to your computer and use it in GitHub Desktop.
Save singaltanmay/1a549f55d3b8e44c7d5616cb7769709a to your computer and use it in GitHub Desktop.
Non-encrypted public and private account values in Scratch
(define faceted_bal '(25 10))
(define get_balances
(lambda (is_private)
(if (eqv? is_private #t)
(car faceted_bal)
(cadr faceted_bal))))
(define deposit
(lambda (amount)
(let ((new-pub-val (+ (car faceted_bal) amount))
(new-priv-val (+ (cadr faceted_bal) amount)))
(set! faceted_bal (list new-pub-val new-priv-val)))))
(define withdraw
(lambda (amount)
(let ((current-pub-val (car faceted_bal))
(current-priv-val (cadr faceted_bal)))
(set! faceted_bal (list (- current-pub-val amount) (- current-priv-val amount))))))
(display "Balances before deposit:\n")
(display (get_balances #t))
(display "\n")
(display (get_balances #f))
(display "\n")
(deposit 17)
(display "Balances after deposit:\n")
(display (get_balances #t))
(display "\n")
(display (get_balances #f))
(display "\n")
(exit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment