⇐ What's Jekyll? Blogtest: Divers ⇒

Blogtest: Programmacode

Code

Inline code is available with the <code> element. Snippets of multiple lines of code are supported through Pygments. Longer lines will automatically scroll horizontally when needed.

// Example can be run directly in your JavaScript console


// Create a function that takes two arguments and returns the sum of those arguments

var adder = new Function("a", "b", "return a + b");

// Call the function

adder(2, 6);
// > 8

You may also optionally show code snippets with line numbers. Add linenos to the Pygments tags.

1
2
3
4
5
6
7
8
// Example can be run directly in your JavaScript console


// Create a function that takes two arguments and returns the sum of those arguments

var adder = new Function("a", "b", "return a + b");

// Call the function

adder(2, 6);
// > 8

Toegevoegd door Hans

Dit is Ruby:

1
2
3
4
5
def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.

Dit is Scala:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//Voor de syntaxhighlighting, Scala

    def primeFactorMultiplicity: Map[Int,Int] = {
      def factorCount(n: Int, p: Int): (Int,Int) = 
        if (n % p != 0) (0, n)
        else factorCount(n / p, p) match { case (c, d) => (c + 1, d) }
      def factorsR(n: Int, ps: Stream[Int]): Map[Int, Int] = 
        if (n == 1) Map()
        else if (n.isPrime) Map(n -> 1)
        else {
          val nps = ps.dropWhile(n % _ != 0)
          val (count, dividend) = factorCount(n, nps.head)
          Map(nps.head -> count) ++ factorsR(dividend, nps.tail)
        }
      //Iets te printen

      println("Iets te printen")
      factorsR(start, primes)

En dit is Java:

1
2
3
4
5
6
7
	public static void main( String[] args){
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUIApplication();
            }
        });
	}

Kortom: het doet het, maar misschien kunnen dekleurtjes wat helderder.

⇐ What's Jekyll? Blogtest: Divers ⇒