Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fuck You, Write Code

Name: Anonymous 2013-05-29 1:07

/prog/, I throw down a gauntlet to you.

From http://esolangs.org/wiki/Category:Unimplemented , select a programming language. Write an implementation for it and post it. If you want to pick something else and implement it better than what's already there, go for it. No prizes or shit, because real EXPERT PROGRAMMERS do it for the thrill of the chase.

(No, I'm not L.A. Calculus, I'm not angry enough.)

I'll throw my hand in as well, so you can at least get the satisfaction of laughing at me.  I might do CAT or Knight Shuffling Tower.

Name: Anonymous 2013-06-06 13:11

Oh, I wrote a P′′ interpreter in Haskell a couple of days ago, but had forgotten to post it here:

{-# LANGUAGE TypeOperators #-}

module P'' where

import Control.Category ((>>>))
import Control.Lens hiding (Tape)
import Control.Monad

data Term = R | Lam | Seq Term Term | Loop Term
type Tape = Top :>> [Int] :>> Int

-- Run a P'' term over a tape, in an alphabet of size n.
-- Returns Nothing if the program moves off the tape. Note
-- that directions are flipped; the left-infinite tape is
-- implemented as a right-infinite list zipper.
runTerm :: Int -> Term -> Tape -> Maybe Tape
runTerm n R         = leftward
runTerm n Lam       = focus %~ (\x -> succ x `mod` n) >>> rightward
runTerm n (Seq p q) = runTerm n p >=> runTerm n q
runTerm n (Loop p)  = \tape ->
    case tape ^. focus of
        0 -> Just tape
        _ -> runTerm n p >=> runTerm n (Loop p) $ tape

-- Run a P'' program over an empty tape.
runP'' :: Int -> Term -> Maybe Tape
runP'' n p = runTerm n p blankTape
    where blankTape = zipper (repeat 0) & fromWithin traverse

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List