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
| fun derivative (f : real -> real) (x : real) : real = | |
| let val pos = Real.nextAfter (x, Real.posInf) | |
| val neg = Real.nextAfter (x, Real.negInf) | |
| in | |
| (f pos - f neg) / (pos - neg) | |
| end |
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 sample-list (items &optional (size 1)) | |
| (let ((sample (make-array size :fill-pointer 0))) | |
| (loop for item in items | |
| for enum from 1 | |
| if (<= enum size) | |
| do (vector-push item sample) | |
| else | |
| do (let ((rand (random enum))) | |
| (when (< rand size) | |
| (setf (aref sample rand) item))) |
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> | |
| #define CHAR_TO_BASE(C) (((C) >> 1) & 3) | |
| enum base { | |
| A = CHAR_TO_BASE('A'), | |
| C = CHAR_TO_BASE('C'), | |
| G = CHAR_TO_BASE('G'), | |
| T = CHAR_TO_BASE('T'), | |
| }; |
OlderNewer