This file contains hidden or 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
#include <stdio.h> | |
#include <stdint.h> | |
struct foo | |
{ | |
char b; | |
__int128_t bar; | |
char baz; | |
__int128_t barz; | |
char barzz; |
This file contains hidden or 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
def decorator(d): | |
"""This is a decorator that will decorate all decorators. This will add update_wrapper | |
to all decorators. | |
(fun) -> fun | |
""" | |
def _d(f): | |
return update_wrapper(d(f), f) | |
return update_wrapper(_d, d) |
This file contains hidden or 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
Show hidden characters
[ | |
{"keys": ["super+alt+ctrl+d"], "command": "add_date_time_stamp" }, | |
{"keys": ["super+alt+d"], "command": "add_date_stamp" }, | |
{"keys": ["super+alt+t"], "command": "add_time_stamp" } | |
] |
This file contains hidden or 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
(defun double (n) | |
(+ n n)) | |
(defun halve (n) | |
(/ n 2)) | |
;;; Normal | |
(defun mul (a b) | |
(if (= b 1) | |
a |
This file contains hidden or 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
(defun fast-exponential-iter (b n) | |
(labels ( | |
(iter (a x n) | |
;; x to the power of n, with a being accumulator | |
;; the number a * x^n should always be constant | |
;;(format t "~&A: ~A ~&X: ~A ~&N:~A ~&A*X^n: ~A" a x n (* a (expt x n))) | |
(cond ((= n 1) (* a x)) | |
((evenp n) (iter a (square x) (/ n 2))) | |
(t (iter (* a x) x (- n 1)))))) | |
(iter 1 b n))) |
This file contains hidden or 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
SICP3> (time ( crazy-func 30)) | |
Evaluation took: | |
1.004 seconds of real time | |
0.996835 seconds of total run time (0.995984 user, 0.000851 system) | |
99.30% CPU | |
2,263,991,379 processor cycles | |
496 bytes consed | |
61354575194 | |
SICP3> (time ( crazy-func-iter 30)) |
This file contains hidden or 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
(defun crazy-func (n) | |
(cond ((< n 3) n) | |
(t (+ (crazy-func (- n 1)) | |
(* 2 (crazy-func (- n 2) )) | |
(* 3 (crazy-func (- n 3))))))) | |
(defun crazy-func-iter (n) | |
(crazy-iter 2 1 0 3 n)) | |
;;; iter alogrithm: |
This file contains hidden or 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
(defun count-change (amount) | |
(labels ( | |
(count-change-rec (amt coins) | |
(cond ((= amt 0) 1) | |
((single? coins) 1) | |
((< amt 0) 0) | |
(t (+ (count-change-rec amt (rest coins)) | |
(count-change-rec (- amt (first coins)) coins)))))) | |
(count-change-rec amount coins))) |
This file contains hidden or 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
SICP3> (time (fib-iter 10000)) | |
Evaluation took: | |
0.011 seconds of real time | |
0.005020 seconds of total run time (0.004394 user, 0.000626 system) | |
45.45% CPU | |
24,709,407 processor cycles | |
4,575,696 bytes consed | |
33644764876431783266621612005107543310302148460680063906564769974680081442166662368155595513633734025582065332680836159373734790483865268263040892463056431887354544369559827491606602099884183933864652731300088830269235673613135117579297437854413752130520504347701602264758318906527890855154366159582987279682987510631200575428783453215515103870818298969791613127856265033195487140214287532698187962046936097879900350962302291026368131493195275630227837628441540360584402572114334961180023091208287046088923962328835461505776583271252546093591128203925285393434620904245248929403901706233888991085841065183173360437470737908552631764325733993712871937587746897479926305837065742830161637408969178426378624212835258112820516370298089332099905707920064367426202389783111470054074998459250360633560933883831923 |
This file contains hidden or 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
(defun fib-loop (num) | |
(do ((n 0 (1+ n)) | |
(cur 0 next) | |
(next 1 (+ cur next))) | |
((= num n) cur))) |
NewerOlder