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
; response to https://kaushikghose.wordpress.com/2017/01/18/common-lisp-doesnt-yield/ | |
; write functions which map a function over stuff | |
; use I/O streams | |
(defun map-fastq-stream (in fn) | |
"Map FN over the IN stream. FN gets called on each second line out of four lines." | |
(flet ((fastq-reader (in) | |
(prog2 | |
(read-line in nil) |
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
; Lispworks | |
(defun fastq-reader (fname) | |
(let ((in (open fname))) | |
#'(lambda () | |
(prog2 ; <-- prog1 and prog2 are nifty! | |
(read-line in nil) | |
(read-line in nil) ; <-- this is the sequence line | |
(read-line in nil) |
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
; linear-search returns the position of item in the list | |
(defun linear-search (list item &aux (pos 0)) | |
(dolist (e list nil) | |
(if (eql e item) | |
(return pos) | |
(incf pos)))) | |
(defun linear-search (list item &aux (pos 0)) |
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
; https://z0ltan.wordpress.com/2017/02/24/a-piglatin-translator-in-common-lisp-and-contrasting-it-with-the-racket-version/ | |
#| | |
(defpackage #:piglatin | |
(:use :cl :cl-user)) | |
; using CL-USER makes no sense, it usually does not export anything. | |
(in-package #:piglatin) |
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
(defvar *fli1* | |
(fli:register-module "/Applications/Julia-0.5.app/Contents/Resources/julia/lib/libjulia.0.5.1.dylib")) | |
(fli:define-foreign-function | |
(jl-init "jl_init" :source) | |
((julia-home-dir (:reference-pass :ef-mb-string))) | |
:result-type :void | |
:language :C | |
:calling-convention :cdecl) |
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
#| | |
* (cffi:use-foreign-library "/Applications/Julia-0.5.app/Contents/Resources/julia/lib/libjulia.0.5.1.dylib") | |
#<CFFI:FOREIGN-LIBRARY LIBJULIA.0.5.1.DYLIB-505 "libjulia.0.5.1.dylib"> | |
* (cffi:defcfun ("jl_init" jl-init) :void (julia-home-dir :string)) | |
JL-INIT | |
* (jl-init "/Applications/Julia-0.5.app/Contents/Resources/julia/lib/") |
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-condition invalid-nucleotide-error (error) | |
((nucleotide :initarg :nucleotide))) | |
(defvar *nuc-table* | |
'((#\G . #\C) (#\C . #\G) (#\T . #\A) (#\A . #\U))) | |
(defun transcribe (nucleotide) | |
(or (cdr (assoc nucleotide *nuc-table*)) | |
(error 'invalid-nucleotide-error :nucleotide nucleotide))) |
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
(defun sunset (color &key (shift-list '(1 4/3 4/3))) | |
"Redshifts the #RRGGBB color." | |
(format nil | |
"#~{~X~}" | |
(loop for start in '(1 3 5) and shift in shift-list | |
collect (truncate (parse-integer color | |
:start start | |
:end (+ start 2) | |
:radix 16) | |
shift)))) |
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
(defun hyphae (sand size fn itt rad mid) | |
(let ((curr (make-hash-table :test #'equal)) | |
(hits 0)) | |
(labels ((init (snk n) | |
(loop for i from 0 below n do | |
(setf (gethash | |
(add-vert! snk (rnd-in-box 250 250 :xy '(250 250))) | |
curr) | |
0))) |
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
; https://github.com/inconvergent/snek | |
(proclaim '(inline last1 single append1 conc1 mklist)) | |
(proclaim '(optimize speed)) | |
(asdf:defsystem "snek" | |
:description "SNEK is Not an Acronym" | |
; :version "0.0.1" | |
:author "Anders Hoff" |