Category: Programming
-
Understanding Read-Only Properties with Object (Refererence Types)
using System; using System.Text; namespace TestReadOnly { class Program { static void Main(string[] args) { MyClass1 myObject1 = new MyClass1(); // myObject1.MyObject2 = new MyClass2(); // clearly illegal // legal, reference is read-only, not object myObject1.MyObject2.x = 1; Console.WriteLine(“myObject1.MyObject2.x: {0}”, myObject1.MyObject2.x); // also legal, similar to above, anotherObject2 is just a reference to the same […]
-
Understanding Lisp Better
This is the result of a light-bulb going on when reading an info file that introduces emacs lisp. I’m not sure this is legal in other lisps, and it goes against el camino of lisp. But it demonstrates what became clear to me… (defun inc (x) (set x (+ 1 (eval x)))) ;note the intentional […]
-
Benchmarking Recursion Using Factorial Function
def fact(n) (1..n).to_a.inject(1){|f,n| f*n} end def recursive_fact(n) return n==1 ? n : n * recursive_fact(n-1) end require ‘benchmark’ Benchmark.bm do |b| b.report(“inject”){1000.times{fact(100)}} b.report(“recursive”){1000.times{recursive_fact(100)}} end
-
Debug NUnit Tests With Visual Studio
1. Set a break point in a unit test 2. Open NUnit 3. In Visual Studio, go the tools Menu and choose Attach to Process (or Ctrl-Alt-P) 4. Choose nunit out of the list 5. Run tests. Make sure you run the test where your breakpoint is if you don’t run all tests.
-
Parenthesis Syntax
I’m going to a talk on F# tonight in the Cleveland area. It’s not something I’ll likely get to use in my job, but it’s interesting, and I like to check out different languages. I’ve played around with the language and it seems to have some promise. I like some of the newer functional languages […]