Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
Created June 13, 2016 06:12
Show Gist options
  • Select an option

  • Save michaelbartnett/1c17b402041adeba6718fcfd8170332d to your computer and use it in GitHub Desktop.

Select an option

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*
(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