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 -*- | |
;;; 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 |
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
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 |
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
<!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> |
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
with-gensyms, once-only (with-gensyms.lisp -- from Practical Common Lisp by Peter Seibel) | |
destructure-case (destructure-case.lisp) | |
and-let* (and-let.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
{-# LANGUAGE FlexibleInstances #-} | |
-- ================================================================== | |
-- Memo module | |
-- the code from http://www.sampou.org/cgi-bin/haskell.cgi?Memoise | |
-- with non-essential patches by @nfunato on 2013-09-07 | |
-- | |
module Memo | |
( |
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
-- CSV file parser (as an exercise of Text.ParserCombinators.ReadP) | |
-- 2013-09-21 @nfunato | |
import Text.ParserCombinators.ReadP | |
import Control.Applicative ((<$>), (<*>), (<*), (*>)) | |
-- NOTE: | |
-- The code here is baesd on d.hatena.ne.jp/kazu-yamamoto/20100104/1262597082 | |
-- which shows code for Parsec2, not ReadP | |
-- BUGS: |
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
{-- Just a porting from http://norvig.com/sudoku.html, Dec 2011 by @nfunato --} | |
import Data.List ((\\), delete, nub, null) | |
import Data.Map ((!)) | |
import qualified Data.Map as M -- Map, adjust, fold, fromList, toList | |
import Control.Exception (assert) | |
import Text.Printf (printf) | |
import Data.Maybe (mapMaybe) | |
import Control.Monad (foldM, msum) | |
type Square = (Char,Char) |
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
p17 = p17' [1..1000] | |
p17' = sum . map (length . filter(`notElem` " -") . itoa) | |
itoa i | |
| i < 0 = "minus " ++ itoa (-i) | |
| i < 20 = smalls i | |
| i < 100 = f (quotRem i 10) tens "-" smalls | |
| i < 1000 = f (quotRem i 100) ((++" hundred").smalls) " and " itoa | |
| i ==1000 = "one thousand" | |
| otherwise = error "unsupported range" |
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
-- O(n) revTake and revDrop using list-numeral alike Church-numeral | |
-- (from Richard O'Keefe's post to haskell-cafe, i.e. | |
-- http://www.haskell.org/pipermail/haskell-cafe/2010-September/083905.html) | |
-- | l | | |
-- +----------------+-----+ | |
-- | l-n (_:m) n | | |
revTake n xs = drop' (drop n xs) xs | |
where drop' (_:m) (_:xs) = drop' m xs |