-
01_robots.lisp
古典的Robot Game.
本(Land of Lisp)にあるオリジナル(http://landoflisp.com/robots.lisp) は、
わずか42行の圧縮気味のコードなのを、読みやすく refactorしたもの. -
02a_robots.fs, 02b_prelude.fs
上記 01_robots.lisp を GForthに移植したもの. -
04_robots.go
| anew =============================robots============================= | |
| \ refactored the following a bit | |
| \ https://gist.github.com/nfunato/39490e1e5d41a9a2d8b0f614a46feeea#file-02a_robots-fs | |
| \ ------------------------------------------------------------------- | |
| \ General utils | |
| : not ( v -- f ) 0= ; | |
| : 3dup ( a b c -- a b c a b c ) dup 2over rot ; |
| ;; based on https://marui.hatenablog.com/entry/2022/12/13/222030 | |
| (defun mapfn-into (arr fn &rest args) | |
| (loop for i below (array-total-size arr) | |
| do (setf (row-major-aref arr i) (apply fn args)) | |
| finally (return arr))) | |
| (defun box-muller-random-sampling () | |
| "Return a pair of independent, standard, normally distributed | |
| (zero expectation, unit variance) random number, using a random |
| ;;; dunm.scm | |
| ;;; - cwd傘下のnode_modulesディレクトリのdisk usageを調べる | |
| ;;; - usageに基づいて、(確認後に)消せるようにする | |
| ;;; (report-stats [#f]) | |
| ;;; (report-stats #t) | |
| ;;; 傘下のnode_modulesディレクトリのdisk usageをプリントする。 | |
| ;;; arg1が#fのときは、1ヶ月以上アクセスしていないもののみを対象とする。 | |
| ;;; 結果の情報は、変数 *result* に格納されている。 |
| \ FizzBuzz in OJ-FORTH ( on top of GFORTH ) | |
| include oj-forth.fs | |
| \ FORTHには、ほぼ文法が無い(ワードしかない)ということがよく分かると思う | |
| \ なお以下の例で使っているワード 「を」 「まで」 「から」 は、純粋に飾り(NOP)である | |
| わたくし で割り切れるの ( i n -- b ) を | |
| mod 0= | |
| と定義しましてよ |
| import React, { createContext, useState, FC } from "react"; | |
| import uuidv4 from "uuidv4"; | |
| import { getInitialColorDataList } from "./ColorDataList"; | |
| export type ColorDataTyp = { | |
| id: string; | |
| title: string; | |
| color: string; | |
| rating: number; | |
| }; |
このgist entryには、 ここ(zenn) にある記事の参照用コードが含まれています。
- 1. README.org
このファイル
| \ a study of github.com/robertpfeiffer/forthsnake, although essentially the same | |
| include random.fs \ the only line depending on GFORTH | |
| : not ( b -- b ) 0= ; \ changed since the def. in the original means INVERT | |
| : myrand ( fr to -- r ) swap dup >r - 1+ random r> + ; \ random at [fr,to] | |
| 200 constant snake-size | |
| 50 constant xdim | |
| 20 constant ydim | |
| create snake snake-size cells 2* allot does> swap snake-size mod cells 2* + ; |
| ------------------------------------------------------------------ | |
| 以下の翻訳文は、Felix Winkelmann の Thoughts on Forth Programming | |
| (http://call-with-current-continuation.org/articles/forth.txt) の | |
| 翻訳であり、原著者の許可を得て公開するものです。 | |
| 2021-09-01 Nobuhiko FUNATO (nfunato @ acm . org) | |
| 更新履歴: | |
| 2021-09-02(rev10): Shiro Kawaiさんにご指摘いただいた誤訳訂正/改善を反映 | |
| 2021-09-02(rev09): 公開初版 | |
| ------------------------------------------------------------------ |
From Gforth 0.7.3 manual
This section presents the structure package that comes with Gforth. A version of the package implemented in ANS Forth is available in `compat/struct.fs’. This package was inspired by a posting on comp.lang.forth in 1989 (unfortunately I don’t remember, by whom; possibly John Hayes). A version of this section has been published in M. Anton Ertl, Yet Another Forth Structures Package (http://www.complang.tuwien.ac.at/forth/objects/structs.html), Forth Dimensions 19(3), pages 13-16. Marcel Hendrix provided helpful comments.
ここではGforthに付属する構造体パッケージを紹介する。ANS Forth で実装されたこのパッケージのバージョンは,`compat/struct.fs’ にあります.このパッケージは,1989年に comp.lang.forth に投稿されたものに触発されたものです(残念ながら誰が書いたのかは覚えていませんが,おそらく John Hayes 氏でしょう)。このセクションのバージョンは、M. Anton Ertl, Yet Another Forth Structures Package (http://www.complang.tuwien.ac.at/forth/objects/structs.html), Forth Dimensions 19(3), pages 13-16に掲載されています。Marcel Hendrix が参考となるコメントを提供してくれました。