Showing posts from February, 2012

Knowledge Tree Update 1

Knowledge Tree is growing.. Update...

I am updating the structure of . ..Knowlegebase..

Every node in the tree will now have a page for itself. Appending "i" to the Node URL will take you to the "itself" page. The main url will be showing the branches(1 level) and also the graphical representation of the branches( arbitrary level).

Just added the UML branch to the Knowledge Tree.

Earlier this week I added an itself page to the foreach node of Java tree.
Leaf node urls are themselves Itself

copyright ©Rajesh Patkar, All rights reserved.

DataStructures in Scala

I have started populating the DataStructure Space in the Scala section.
The first entrant is a simple Stack class implemented using some interesting features of Scala Language.

Java , C++ and C# programmers can analyze the following Scala code, written for implementing a simple bounded stack. Try to figure out interesting Scala language properties. 

Simple Stack

package datastructuresinscalastack
object Main {   def main(args: Array[String]): Unit = {     println("Welcome to Simple Stack");     var s1 = new Stack(10)     val v = (1::2::3::s1).!.pop     println("Popped Value is "+ v)     s1 !   } } class Stack(v:Int){   var stk = new Array[Int](v)   var sp = v   def ::(v:Int) = { if(sp!=0){sp-=1;stk(sp)= v} else println("Overflow") ; this}   def pop = if(sp!=v) {sp = sp + 1; stk(sp-1)} else {println("underflow"); -1}          def ! = { println("Printing Stack"); for( i <- sp to stk.length-1) println(stk(i)) ; this } }


Welcome to Simple Stack P…