Created
June 13, 2016 06:12
-
-
Save michaelbartnett/1c17b402041adeba6718fcfd8170332d to your computer and use it in GitHub Desktop.
Elisp function to generate CC codes (e.g. FOURCC, SIXTEENCC) from string input. Endianness is probably broken, *shrug*
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 make-cc-code (input-string) | |
| (let ((charlist (mapcar (lambda (c) (coerce c 'character)) | |
| (split-string input-string "" t)))) | |
| (loop for c in charlist | |
| for i below (length charlist) | |
| collect (lsh c (* i 8)) into shifted-charcodes | |
| finally return (apply #'logior shifted-charcodes)))) | |
| (mapcar #'make-str-codes '("NONE" "STRN" "INT4" "FLT4" "BOOL" "ENUM" "ARRY" "COMP" "UNON")) | |
| ; => (1162760014 1314018387 877940297 877939782 1280266050 1297436229 1498567233 1347243843 1313820245) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment