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
;;; CL utility snippets -- MIT LICENSE | |
;;; | |
;;; originally starting from porting p59c.hs (https://gist.github.com/nfunato/9559350#file-p59c-hs) to CL, | |
;;; which uses | |
;;; delay, force (promise.lisp) | |
;;; xsequence (xsequence.lisp) | |
;;; xtranspose (xtranspose.lisp) | |
;;; groups-of, xsplit, xmerge (groups-of.lisp) | |
;;; 2015-09-27 tconc and lconc (xconc.lisp, xconc.scm) | |
;;; 2015-09-29 random test stuff (for-random-test.lisp) |
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
\ FizzBuzz in Forth by @nfunato on 2015-04-30 | |
\ http://golf.shinh.org/p.rb?FizzBuzz#Forth | |
\ Execution rule: | |
\ 1. invoke shell | |
\ 2. exec gforth this-file -e bye | |
\ : x | |
\ 101 1 do | |
\ 1 |
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
;;; Five programming problems every Software Engineer should be able to | |
;;; solve in less than 1 hour | |
;;; Problem 1 (SUM) | |
;;; Write three functions that compute the sum of the numbers in a given | |
;;; list using a for-loop, a while-loop, and recursion. | |
(defun sum-r (l &optional (s 0)) (if(null l) s (sum-r (cdr l)(+ (car l) s)))) | |
(defun sum-for (l) (loop for i in l sum i)) | |
(defmacro while (xs &body body) |
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
;;; CAUTION: this code is not fully tested! | |
(ql:quickload | |
;; FIXME: use lquery rather than plump if preferable | |
'( | |
:drakma ; a full-featured common lisp http client | |
:plump ; a parser for HTML/XML like document | |
:clss ; a DOM traversal engine based on CSS selectors | |
:cl-redis ; a client library for Redis database, an advanced K/V store | |
;; :chirp ; a twitter client library for common lisp |
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
;;; -*- Mode: Lisp; Syntax: Common-Lisp -*- | |
;;; sutra transcribing of cl-overload w/ a bit of re-factoring | |
;;; in order to understand its specification | |
;;; 2015-08-22 @nfunato | |
;;; original code is cl-overload.lisp show-matz/CL-OVERLOAD commit 91af6928e5 | |
;;; (formally 91af6928e538cfcf9634d7cbb47771dc4cfa3dcd) as of 2015-07-26 | |
(provide :cl-overload) |
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
;; checked under Emacs24 | |
(defun eisuu-hankaku-region (from to &optional ascii-only) | |
"Convert JP `zenkaku' eisuu ([A-Z0-9a-z]) and some other chars, which does | |
not include punctuation chars, in the region to `hankaku' chars. | |
`Zenkaku' chars belong to `japanese-jisx0208' | |
`Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'. | |
NOTE: Optional argument ASCII-ONLY is ignored here." | |
(interactive "r\nP") | |
(save-restriction | |
(narrow-to-region from to) |
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
#!/usr/local/bin/sbcl --script | |
;; The exercise in http://d.hatena.ne.jp/eel3/20151102/1446476928 | |
;; https://github.com/mrkkrp/unix-opts/blob/master/example/example.lisp | |
(load "unix-opts") ; or (ql:quickload "unix-opts") | |
;;------------------------------------------------------------------- | |
;; Essential processing | |
;; Similar to the following Haskell expression, but in somewhat eager: |
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
原文:[http://www.paulgraham.com/lwba.html Lisp for Web-Based Applications] | |
;; updated by nfunato on 2015-11-27 | |
---- | |
[http://practical-scheme.net/trans/beating-the-averages-j.html 普通のやつらの上を行け]へのリンクがslashdotにアップされた後に、何人かの読者は、私たちがViawebでLispを使ったことで得られた固有の技術的なアドバンテージについて、さらに詳しく聞きたがった。 | |
興味を持つ人のために、私が2001年4月にマサチューセッツ州ケンブリッジのBBN研究所で行った講演の要約を以下に示す。 | |
---- |
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
;;; -*- coding:utf-8; mode:lisp -*- | |
;; This is a secondary work for d.hatena.ne.jp/masatoi/20160106/1452057909. | |
;; See for the article regarding the copyright. | |
;; 2015-01-09 @nfunato | |
;; オリジナルに対する本質的な変更は無く、 | |
;; 実質的な変更点は、以下の手法で焦点でない細部を見えないようにしたこと | |
;; - 数値ベクトルへのarefアクセスは、calc- という関数に分離した | |
;; - 数値ベクトル以外のarefアクセスはstructure accessor経由にした |
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
-- a study for http://morishin.hatenablog.com/entry/haskell-poem-generator | |
-- 2016-03-09 @nfunato | |
module Lib (generatePoem) where | |
import System.Random (randomRIO) | |
import Data.Maybe (maybe) | |
import Data.List (foldl', tails) | |
import Data.Map (Map) | |
import qualified Data.Map as Map |