# Code Monkey Have Fun

Posts
• #### If you can’t beat ‘em, join ‘em

I’ve had fun making the little DCPU emulator (past couple of posts: 1 , 2 ), but sadly, I’ve had no time to make a Forth for it. But hey, Matt Hellige has already done it ! I just took his GoForth and got it up and going. Just grab the image from here...
• #### Speech Grammars in F#

People say that Vim keys are a grammar for talking to your editor and that's exactly what they are. One weekend some time back I had fun making VimSpeak to see how well mapping English words to Vim keys would work. It turned out quite nice and some pieces...
• #### Tearing Away the Scaffolding

[The seventh in a series of posts on the evolution of TransForth ] At this point we have a reasonably complete Forth that’s pretty fun to play with. Like I said in the first post though, we don’t just want to build a Forth in F#. Stopping...
• #### Project Euler Problem #14

Longest hailstone sequence with starting number under one-million. let hailstone n = Seq.unfold ( function 0L -> None | 1L -> Some(1L, 0L)                                     ...
• #### Project Euler Problem #11

Greatest product of four adjacent numbers (up, down, left, right, or diagonally) in this 20x20 grid: let grid = [|08;02;22;97;38;15;00;40;00;75;04;05;07;78;52;12;50;77;91;08; 49;49;99;40;17;81;18;57;60;87;17;40;98;43;69;48;04;56;62;00; 81;49;31;73;55;79;14;29;93;71;40;67;53;88;30;03;49;13;36;65;...
• #### Functional I/O (Historical Debugging)

[Part 14 of the FScheme series ] Historical Debugging in VS2010 is quite the engineering feat! We can actually pull off something similar in our interpreter with amazing ease. Because of the pure nature of our functional I/O system (last two posts...
• #### 8-Queens in 8 Lines

Brushing up on “whiteboard coding” for internal interviews… Inspired by Hal Ableson’s streams-based solution to this old classic in the SICP lectures, here’s a pretty concise n-Queens solution: let rec Solutions n...
• #### Turtles All The Way Down

What do you think this “code” does? 0(1adf89r)720x Well, it’s a ridiculously terse, stack-based Logo-like language with single character commands. Beginning with 0, it repeatedly (720 times) increments the top stack value and moves forward by that amount...
• #### Going “Retro” and Loving It!

Continuing my concatenative language kick, I’ve been having fun playing with Retro ( http://www.retroforth.com ) and couldn’t resist making an F#-based VM on which to run it. It is an elegant, minimal Forth with an important twist. What caught...
• #### Multiply-step Instruction

Fourth in a series on colorForth and GreenArrays hardware . This time, how the multiply-step instruction works on the F18. Bit Twiddling is Fun! Here's a bit-twiddly interview question for you: Design an algorithm to multiply fixnum integers in...
• #### F18 Variables

Variables on the F18 are not like regular Forth variables. Usually a variable is a word returning the address of its value used along with fetch ( @ ) and store ( ! ) words. On the F18 the idiomatic approach is to have individual variable-specific fetch...
• #### What’s a computer without I/O? Hot Silicon At Best…

[FYI: Matt Hellige’s excellent GoForth runs on this ] I’m completely astonished at how quickly a community has sprung up around Notch’s DCPU-16 . In the first 24 hours there were already tens of implementations in various languages ( including mine )...
• #### TinyRPN Calculator

It’s fun dorking around with the HP 41CX emulator on the iPhone. It’s a near-perfect rendition. I forgot how much I loved RPN calculators. The 48GX looks even more interesting with Reverse Polish Lisp but I haven’t figured out how to use it yet. The 41CX...
• #### Cryptarithm

A recent post to the Puzzles and Logic Problems alias at work: The problem below is an example of a cryptarithm – a basic math problem made more difficult by obscuring each digit with a letter or other symbol. B A R...
• #### Recursion Is The New Iteration

I remember the strange feeling as a kid the first time I saw structured BASIC after having been doing everything with line numbers. Any time I happened to walk into a Radio Shack in the early 80s I’d just have to leave this behind:   I was in a GOTO...
• #### What's Lisp Without Lists?!

[Part 6 of the FScheme series ] Once again, I must plug Bill Hails’ book Lists How could we even be pretending this is Lisp when we have yet to add lists! We need to add the standard ‘cons’, ‘car’, and ‘cdr’...
• #### Just ‘let’ Me Be Already!

[Part 2 of the FScheme series ] Still working through Bill Hails’ awesome book . Adding to the FScheme interpreter from this previous post . Now we’ll add ‘let’. To do this we’re changing the evaluation model into an environment...
• #### Lambda the Ultimate!

[Part 3 of the FScheme series ] Continuing along in Bill Hails’ book . Be sure to follow the previous posts . Lambda Now we’re going to add the all-powerful ‘lambda’! Since we’ve already done all the environment...
• #### Rinse and Recurse

[Part 4 of the FScheme series ] Recursive ‘let’ Normal ‘let’ can’t be used to bind names to recursive expressions (ones referring back to the names) because the expressions end up being evaluated in the calling environment...
• #### What ‘letrec’ Can’t Do

[Part 5 of the FScheme series ] In this series I’m glossing over all the gory details. You really should read Bill Hails’ book ! Simultaneous 'let' We just added ‘letrec’ to solve the issue of bindings referring back to...
• #### Project Euler Problem #7

Find the 10001st prime let naturals = Seq.unfold ( fun i -> Some(i, i + 1 )) let primes = naturals 2 |> Seq.filter ( fun n -> seq { 2.. int (sqrt (float n)) } |> Seq.forall ( fun x -> n % x <> 0 )) Seq.nth 10000 primes
• #### Towers of Hanoi

A friend of mine is starting a pretty fun looking math blog . His first post is on Towers of Hanoi . I'm sure he'll tackle it with some slick mathematics, but my usual M.O. is to convert everything to code. I remember this "Hello Recursive World" from...