Posts
  • Code Monkey Have Fun

    Project Euler Problem #5

    • 0 Comments
    Smallest number divisible by each of 1 to 20 : First cut (takes almost an hour to execute!): let isFactor n d = n % d = 0 {1..Int32.MaxValue} |> Seq.find ( fun n -> [1..20] |> List.forall (isFactor n)) Second cut (takes a...
  • Code Monkey Have Fun

    Project Euler Problem #6

    • 0 Comments
    Difference between sum of the squares and the square of the sum of 1 - 100 : ( fun ns -> let sqr x = x * x (sqr (List.sum ns)) - (List.map sqr ns |> List.sum) ) [1..100]
  • Code Monkey Have Fun

    Babbage’s Difference Engine

    • 0 Comments
    ";" galleryimg="no"> Babbage's Difference Engine is pretty fascinating. I had wanted to go see the one on display at the Computer History Museum in Mountain View, but now Nathan Myhrvold has the thing back in his living room! Maybe I’ll build...
  • Code Monkey Have Fun

    Sweeping Mines... Functionally

    • 0 Comments
    Mr. GeekRaver and I were walking between buildings and, for some reason, talking about how silly it is that good ol’ Minesweeper was “glossed up” for Vista. He said he had written it for DOS in some tiny amount of C code ( http://www.bradygirl.com/Work...
  • Code Monkey Have Fun

    Project Euler Problem #1

    • 0 Comments
    Project Euler is pretty darn cool. It’s a bunch of mathematical problems that require programming to solve. I’m having fun doing them in F#. They start very simple but quickly become more difficult. Problem 1 is to find the sum of all the multiples...
  • Code Monkey Have Fun

    Project Euler Problem #2

    • 0 Comments
    Sum of even terms in Fibonacci sequence which are < four-million : (1, 1) |> Seq.unfold ( fun (a, b) -> Some(a, (b, a + b))) // fibs |> Seq.takeWhile ( fun x -> x <= 4000000) |> Seq.filter ( fun x -> x % 2 = 0) ...
  • Code Monkey Have Fun

    Project Euler Problem #3

    • 0 Comments
    Largest prime factor of 600851475143 : let primeFactors n = let isFactor n d = n % d = 0L let nextFactor n d = seq {d..n} |> Seq.find (isFactor n) (n, 2L, []) |> Seq.unfold ( fun (n, d, a) -> if isFactor n d then Some(d, ((n...
  • Code Monkey Have Fun

    XSLT: A Pure Functional Language

    • 0 Comments
    Some years ago now, I had the pleasure of working with a great team building a very elegant publishing and rendering system for MSN. This was one the best times I’ve had at Microsoft. It was a revolutionary system for the time [1] based on transformation...
  • Code Monkey Have Fun

    Hey, Hey We’re the Monkeys

    • 0 Comments
    My current team is awesome! We’re a tight little team with an interesting history and have done some great work together. It’s a sad day though. Today was John’s last day. He’s going over to work on Seadragon -ish stuff – really, really cool project!...
  • Code Monkey Have Fun

    Streams

    • 0 Comments
    These SICP lectures are great I tell ya! The two lectures on Streams (6a/6b) talk about implementing things with lazy lists. His examples are in Scheme but here’s my translation to C# using some of the new features in 3.0. For example, here is a lazy...
  • 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

    Oh, The Humanity!

    • 0 Comments
    [Part 8 of the FScheme series ] 'set', 'begin', 'define' Here we implement chapters 10 and 11 of Bill Hails’ book . We’re about to do something hideous and horrible to the language (and to our interpreter). We’re about to add assignment...
  • Code Monkey Have Fun

    Language vs. Library

    • 0 Comments
    [Part 9 of the FScheme series ] Primitives Perhaps this post should have gone along with the one about macros and how Lisp is a “programmable programming language.” The common tension in any language or runtime design is how much to...
  • Code Monkey Have Fun

    Turtle Soup

    • 0 Comments
    I've been reading Seymour Papert 's Mindstorms book about Logo ; very interesting! I'm just dying to add Turtle Graphics to my little toy language from last post (BTW, a friend suggested I call it "Ape" and I think I will!). Logo with a twist What...
  • 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

    MS Space Mobile

    • 0 Comments
    Back in late 2005 there was an internal contest sponsored by MED to get people using Compact Framework. I spent a long weekend building a little app to browse Microsoft building floor plans and find offices and conference rooms. I ended up winning some...
  • 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

    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

    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

    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

    Introducing the Cult of the Bound Variable to the Cult of Forth

    • 0 Comments
    [The twelfth in a series of posts on the evolution of TransForth ]   It’s been quite fun playing with this Universal Machine from the Cult of the Bound Variable . In this post we’re going to continue the journey toward building a full Forth for this...
  • Code Monkey Have Fun

    Meta-Circular Chicken and Egg

    • 0 Comments
    [The tenth in a series of posts on the evolution of TransForth ] This post may not quite be deserving of a wizard’s cape and 2001 Space Odyssey background music as when Sussman writes out Lisp in Lisp (at 34:34 - my absolute favorite SICP lecture...
  • Code Monkey Have Fun

    Programming a 2000 Year Old Sandstone Computer

    • 0 Comments
    [The eleventh in a series of posts on the evolution of TransForth ] If you think coding with punch cards is old school, you should try using sandstone tablets! Legend has it that members of the Cult of the Bound Variable designed and may have even...
  • Code Monkey Have Fun

    Heart Transplant

    • 0 Comments
    [The eighth in a series of posts on the evolution of TransForth ] They say that the inner interpreter is the heart of Forth and outer interpreter is the soul. It’s time to give TransForth a heart transplant! To really understand what we’re...
Page 3 of 4 (79 items) 1234