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 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))))) |
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
;; 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 |
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 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 |
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
;; 前置きとして… | |
;; どんな言語にもあると思いますが、 Common Lisp にも一般的なスタイルがあります。 | |
;; まずは、それに目を通すことをおすすめします。 | |
;; | |
;; Google Common Lisp Style Guide | |
;; en: https://google-styleguide.googlecode.com/svn/trunk/lispguide.xml | |
;; jp: http://lisphub.jp/doc/google-common-lisp-style-guide/ | |
;; | |
;; Tutorial on Good Lisp Programming Style | |
;; en: http://www.norvig.com/luv-slides.ps |
この文章は、 Lisp Advent Calendar 2014 の 12/11 担当分の記事として書かれました。
C系言語から Common Lisp に移行した時、「どうして Lisp はこんなに書き辛いんだ?」と思っていたことを記憶しています。
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
(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)))) |
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
(in-package :cl-user) | |
#| | |
(ql:quickload :chirp) | |
(setf chirp:*oauth-api-key* "**************************" | |
chirp:*oauth-api-secret* "***************************" | |
chirp:*oauth-access-token* "*******************************" | |
chirp:*oauth-access-secret* "***************************") | |
|# |
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
;; http://d.hatena.ne.jp/yarb/20110202/p1 | |
;; http://okajima.air-nifty.com/b/2011/01/2011-ffac.html | |
;;; solving time (19 chain) -- 1h26min :/ | |
;; -rw-r--r-- 1 y2q staff 4656 5 16 04:58 puyopuyo.lisp | |
;; -rw-r--r-- 1 y2q staff 22 5 16 03:32 puyopuyo.lisp~ | |
(ql:quickload "alexandria") | |
(in-package :cl-user) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
static char* instruction = NULL; | |
static size_t instruction_size = 0; | |
#define DEFAULT_DATA_SIZE 30000 | |
static char data[DEFAULT_DATA_SIZE]; |