Skip to content

Instantly share code, notes, and snippets.

View lispm's full-sized avatar

Rainer Joswig lispm

  • Germany
View GitHub Profile
#|
* (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/")
(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)
; 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)
; 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))
; 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)
; 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)
(defun abbreviate-butlast (path)
(loop for (item . rest) on path
collect (if (and rest (> (length item) 1))
(subseq item 0 1)
item)))
@lispm
lispm / join.lisp
Last active December 11, 2016 22:02
; a join function using FORMAT
(defun join-aux (stream &rest args)
(declare (ignore args)
(special delim))
(princ delim stream))
(defun join (list delim)
(declare (special delim))
(format nil "~{~a~^~/JOIN-AUX/~:*~}" list))
; https://github.com/alandipert/dotfiles/blob/master/dotfiles/bash/abbrev_pwd.lisp
; original
; splits string into a vector of strings
(defun split-string (str delim-char)
(let* ((num-delims 2)
(delim-idxs (loop with idxs = (list (length str))
for idx from (1- (length str)) downto 0
when (eq (elt str idx) delim-char)
Comparing/explaining the screenshots
http://dustycloud.org/tmp/emacs-and-the-lisp-machine.png
* Left: Document Examniner from Symbolics, a system supplied application of the Genera OS
** Application to browse and read documentation on the Symbolics Lisp Machine
* Right: GNU Emacs