Skip to content

Instantly share code, notes, and snippets.

@nfunato
nfunato / fa.hs
Created October 1, 2012 19:57
Filling up for instructional automata paper in Haskell
{- ported from and/or filled for
"Regular Expressions and Automata using Haskell, Simon Thompson (Jan 2000)",
by @nfunato on 2012/04/07 -}
{- this code is provided "as-is". -}
import Data.List (foldl', nub, sort, sortBy, groupBy, elemIndex, findIndex)
import Data.Set (Set, empty, size, singleton, fromList, toList, toAscList,
elems, member, findMin, insert, union, intersection,(\\))
import qualified Data.List as L -- L.map
@nfunato
nfunato / a-part-of-dot-emacs.el
Created October 20, 2012 18:42
whitespace busters for Emacs
(defvar undesirable-ws-cleanup-wo-choice-modes
'(lisp-mode))
(defvar undesirable-ws-cleanup-w-check-modes
'(org-mode))
(defun undesirable-ws-cleanup ()
(interactive)
(save-excursion
(when (or (member major-mode undesirable-ws-cleanup-wo-choice-modes)
@nfunato
nfunato / util-recons.lisp
Created October 27, 2012 19:15
recons / relist / relist*
;;; 2012/10/27 @nfunato
;;; Probably I first saw them at Xerox PCL about 25 years ago.
;;; I think almost same code can be seen in many places, including CLtL2.
;;; recons / relist / relist*
(defun recons (x a d)
(destructuring-bind (xa . xd) x
(if (and (eql xa a) (eql xd d))
x
@nfunato
nfunato / cal-short.hs
Last active October 13, 2015 06:37
Unix cal(1) knockoff in Common Lisp / Haskell
import Data.List (transpose, unfoldr, intercalate)
import Data.Time.Calendar (gregorianMonthLength, fromGregorian)
import Data.Time.Calendar.WeekDate (toWeekDate)
-- utilities
dow y m d = pred $ trd $ toWeekDate $ fromGregorian y m d where trd(_,_,x) = x
groupsOf n | n>0 = unfoldr $ \x -> if null x then Nothing else Just(splitAt n x)
-- essential start of cal.hs --------------------------------------
type Month = (Integer,Int) -- a local definition of handy month
@nfunato
nfunato / tofu.lisp
Created December 10, 2012 07:46
The "Retro" Tofu Shop Game in Iscandar
;;; -*- Mode: Lisp -*-
;;; The Tofu Shop Game in Iscandar
;;; Copyright (C) 1978-2012 by Nobuhide Tsuda
;;; (see also http://vivi.dyndns.org/tofu/tofu.html)
;;;
;;; Revision History:
;;; 1978 Design & Implemented by Nobuhide Tuda (ntsuda at beam.ne.jp),
;;; as a sort of business strategy simulation game, assuming
;;; MC6800(1MHz) and RAM 4-32K bytes w/o secondary storage
@nfunato
nfunato / google CL style guide in JP
Last active December 10, 2015 16:38
Google Common Lisp Style Guide (a translation in Japanese)
Note:
The original document is a section of CLOS in "Google Common Lisp Style Guid",
http://google-styleguide.googlecode.com/svn/trunk/lispguide.xml (v1.17)
This translation is based on a Japanese translation
http://google-common-lisp-style-guide-ja.cddddr.org/?showone=CLOS#CLOS
as of 2013/01/05 23:00 JST
CC-By 3.0 License
@nfunato
nfunato / 00_history.org
Last active August 31, 2021 09:21
The "Retro" Tofu Shop Game in Iscandar (in ANS Forth)

Revision History – the “Retro” tofu shop game in Iscandar (in ANS Forth)

このページは イスカンダルのトーフ屋ゲーム からリンクされています。

2020-11-15

  • Thinking Forth を (初めて)通読して、痛く反省したので refactoring してみた (tofu.fthのみ)
  • ファイル構成等の詳細は、tofu.fth の heading comment を参照 (なお、旧版(2013,2019)のgist filesは 目の毒なので、このgist entryの表向きからは消した)
@nfunato
nfunato / forth-web-pages.html
Last active December 12, 2015 02:38
Some Forth pages to go
<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja" dir="ltr">
<html>
<head>
<meta charset="UTF-8">
<title>
Some Forth pages to go
</title>
</head>
<body>
@nfunato
nfunato / life-rosetta.fth
Last active April 28, 2019 21:54
Conway's Game of Life in FORTH (essentially same with one in rosesttacode)
\ -*- Mode: Forth -*-
\ Conway's Game of Life
\ originally from http://rosettacode.org/wiki/Conway's_Game_of_Life#Forth
\ see also http://en.wikipedia.org/wiki/Conway's_Game_of_Life
\ -------------------------------------------------------------------
\ The fast wrapping requires dimensions that are powers of 2.
\ (for playing just size, you may set terminal size to 64x17)
@nfunato
nfunato / _contents
Last active December 21, 2015 04:09
Handy implementations of famous macros for Common Lisp (and-let, destructure-case)
with-gensyms, once-only (with-gensyms.lisp -- from Practical Common Lisp by Peter Seibel)
destructure-case (destructure-case.lisp)
and-let* (and-let.lisp)