Created
September 13, 2023 04:21
-
-
Save singaltanmay/1a549f55d3b8e44c7d5616cb7769709a to your computer and use it in GitHub Desktop.
Non-encrypted public and private account values in Scratch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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