Skip to content

Instantly share code, notes, and snippets.

View y2q-actionman's full-sized avatar
🕹️
👾👾👾👾👾👾👾👾👾

Yokota Yuki y2q-actionman

🕹️
👾👾👾👾👾👾👾👾👾
View GitHub Profile
@y2q-actionman
y2q-actionman / gist:11133761
Last active August 29, 2015 14:00
Ubuntu 12 上の SBCL で ncurses が FFI から読めない問題

Ubuntu 12 上の SBCL で ncurses が FFI から読めない問題

症状

cl-charms (CFFI + ncurses) の場合

Common Lisp から、 NCURSES を触りたくなった。早速、Quicklisp で、 cl-charms をインストールしてみよう:

 * (ql:quickload "cl-charms")
To load "cl-charms":
@y2q-actionman
y2q-actionman / revattack.lisp
Created August 11, 2014 10:49
簡易 method chain 的なやつ in Common Lisp
(defun suffix-transpose1 (form terminal)
(if form
(suffix-transpose1 (cdr form)
(list (cons (car form) terminal)))
terminal))
(defun suffix-transpose (form)
(car (suffix-transpose1 (cdr form)
(list (car form)))))
@y2q-actionman
y2q-actionman / dollar_sign.lisp
Created August 12, 2014 03:06
Haskell の $ もどき in Common Lisp
;; Haskell の $ もどき in Common Lisp
;; http://practical-scheme.net/wiliki/wiliki.cgi?Gauche%3A%24
;; (fn1 $ fn2 $ fn3 $ fn4 x) -> (fn1 (fn2 (fn3 (fn4 x))))
(defun $-expand (forms)
(cond ((null forms)
nil)
((eq '$ (car forms))
(list ($-expand (cdr forms))))
(t
@y2q-actionman
y2q-actionman / join.lisp
Created October 25, 2014 07:34
cl:reduce で文字列として join する。
(defun join (lis &optional (sep " "))
(reduce #'(lambda (x y)
(concatenate 'string
(princ-to-string x) sep (princ-to-string y)))
lis))
#|
CL-USER> (defun join (lis &optional (sep " "))
(reduce #'(lambda (x y)
(concatenate 'string
(in-package :cl-user)
;; https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
;; 1:00
(defun problem1-for (numlist)
(let ((ret 0))
(dolist (n numlist ret)
(incf ret n))))
@y2q-actionman
y2q-actionman / example2.lisp
Created December 13, 2012 13:03
example2 : DOLIST マクロ
(in-package :cl-user)
;; 表示してまわったり
(dolist (p '(1 2 3))
(print p))
;; 和をとってみたり
(let ((accum 0))
(dolist (p '(1 2 3 4 5))
(incf accum p))
@y2q-actionman
y2q-actionman / example3.lisp
Created December 13, 2012 13:06
example3 : DESTRUCTURING-BIND マクロ
(in-package :cl-user)
(destructuring-bind (a b c)
'(1 2 3)
(print a) ; 1
(print b) ; 2
(print c)) ; 3
(terpri)
@y2q-actionman
y2q-actionman / example1.lisp
Created December 13, 2012 13:00
example1 : LIST 関数
(in-package :cl-user)
(setf lis1 (list 1 2 3))
(print lis1) ; (1 2 3)
(setf lis2 (list 1 (list 2 3) (list 4 5)))
(print lis2) ; (1 (2 3) (4 5))
@y2q-actionman
y2q-actionman / adv_sample_3_1.cc
Created December 13, 2012 15:22
Lisp advent calender 2012 sample : 実例3
#include <iostream>
#include <cassert>
#include <cstring>
#include <iterator>
class Cons;
enum class Tag { int_, cons, string };
class Lisp_ptr {
@y2q-actionman
y2q-actionman / adv_sample_2_2.cc
Created December 13, 2012 15:15
Lisp advent calender 2012 sample : 実例2-2
#include <iostream>
#include <cassert>
#include <cstring>
#include <iterator>
class Cons;
enum class Tag { int_, cons, string };
class Lisp_ptr {