Posts
  • Code Monkey Have Fun

    IF … ELSE … THEN

    • 0 Comments
    [The fifth in a series of posts on the evolution of TransForth ] Sadly (or happily), we’ve come to a point at which we need to begin thinking like an assembly programmer in order to appreciate the mechanics of Forth’s control flow...
  • Code Monkey Have Fun

    Turtles All The Way Down

    • 1 Comments
    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...
  • Code Monkey Have Fun

    Lambda the Ultimate!

    • 1 Comments
    [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...
  • Code Monkey Have Fun

    Project Euler Problem #14

    • 2 Comments
    Longest hailstone sequence with starting number under one-million. let hailstone n = Seq.unfold ( function 0L -> None | 1L -> Some(1L, 0L)                                     ...
  • Code Monkey Have Fun

    : REFACTOR TRIM BUILD ;

    • 2 Comments
    [The third in a series of posts on the evolution of TransForth ] Now that we have Forth hobbling along, we can start to peel away the scaffolding. Some of the things we’ve defined in F# can now be redefined in Forth instead. As we go along, I...
  • Code Monkey Have Fun

    What’s a computer without I/O? Hot Silicon At Best…

    • 1 Comments
    [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 )...
  • Code Monkey Have Fun

    Project Euler Problem #8

    • 2 Comments
    Largest products of five consecutive digits in this 1000-digit number. open System.Numerics let digits n = Seq.unfold ( fun i – > if i = 0I then None else Some(i % 10I, i / 10I)) n let consecutive = Seq.unfold ( function (a : BigInteger) ...
  • Code Monkey Have Fun

    Project Euler Problem #13

    • 0 Comments
    First ten digits of sum of following one-hundred 50-digit numbers. It would be interesting to do without BigInts. Could use doubles with enough precision for just the first ten digits or some such thing, but just wanted the correct answer to plug into...
  • Code Monkey Have Fun

    Tearing Away the Scaffolding

    • 2 Comments
    [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...
  • Code Monkey Have Fun

    No Wait, Macro the Ultimate!

    • 0 Comments
    [Part 7 of the FScheme series ] The Soul of Scheme We’re now getting into the language-oriented features of Scheme. This is why Scheme is one of my very favorite languages. Scheme is of course a multi-paradigm language; functional, imperative...
  • Code Monkey Have Fun

    Going “Retro” and Loving It!

    • 1 Comments
    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...
  • Code Monkey Have Fun

    : HELLO FORTH WORLD ;

    • 0 Comments
    [The second in a series of posts on the evolution of TransForth ] In the last post we completed the tokenizer/parser and the REPL along with some baked in primitives. We now want to be able to add to the dictionary of known words from within Forth...
  • Code Monkey Have Fun

    VARIABLE X

    • 0 Comments
    [The fourth in a series of posts on the evolution of TransForth ] We’re getting very close to the point at which we’ll need to start moving closer to the machine with things like direct memory access. Implementing IF / ELSE / THEN ,...
  • Code Monkey Have Fun

    Project Euler Problem #12

    • 0 Comments
    First triangle number to have over five hundred divisors. let naturals = Seq.unfold ( fun i -> Some(i, i + 1)) 1 // from prob7 let triangleNums = Seq.scan (+) 0 naturals let isFactor n d = n % d = 0 let factors n = seq { 1..int (sqrt (float n))...
  • Code Monkey Have Fun

    Functional I/O (or at least “O”)

    • 2 Comments
    [Part 12 of the FScheme series ] I just watched Matthias Felleisen’s talk on Functional I/O and read this paper and decided to bolt on a little I/O system to the FScheme interpreter we’ve been building. It’s a pretty nice FRP-type...
  • Code Monkey Have Fun

    Spanning Two Worlds

    • 0 Comments
    [The ninth in a series of posts on the evolution of TransForth ] The dictionary we have at the moment is split across two worlds. The definitions are in Forth-world; packed into plain memory. But we still have the F#-world mapping of WordRecord s to those...
  • Code Monkey Have Fun

    Functional I/O (Historical Debugging)

    • 2 Comments
    [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...
  • Code Monkey Have Fun

    Project Euler Problem #11

    • 2 Comments
    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;...
  • Code Monkey Have Fun

    Project Euler Problem #10

    • 0 Comments
    Sum of primes below two-million. Easy problem, but way too slow (taking several minutes) with the naïve prime number generator from problem 7 . This new version is 10x faster, based on this paper: http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP...
  • Code Monkey Have Fun

    Just ‘let’ Me Be Already!

    • 1 Comments
    [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...
  • Code Monkey Have Fun

    What's Lisp Without Lists?!

    • 1 Comments
    [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’...
  • Code Monkey Have Fun

    Project Euler Problem #9

    • 0 Comments
    Pythagorean triplet where a + b + c = 1000 (2, 1) |> Seq.unfold ( fun (m, n) – >     Some([m * m - n * n; 2 * m * n; m * m + n * n],         if n + 1 < m then m, n + 1 else m + 1, 1)) |> Seq...
  • Code Monkey Have Fun

    Functional I/O (including “I” this time)

    • 0 Comments
    [Part 13 of the FScheme series ] Now to add input to our Functional I/O system; following up on the previous post . We already had bouncing balls so how ‘bout we add a mouse-controlled paddle and make a primitive “Pong”? Mouse...
  • Code Monkey Have Fun

    Playing Dice with the Universe

    • 0 Comments
    [Part 11 of the FScheme series ] We’re now taking the first small step into the world of nondeterministic logic programming (chapter 16 of Bill Hails’ book ). Hopefully you enjoyed the last post about continuation passing and found the...
  • Code Monkey Have Fun

    TinyRPN Calculator

    • 1 Comments
    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...
Page 2 of 4 (77 items) 1234