This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cgon { | |
import com.greensock.easing.Expo; | |
import com.greensock.TweenLite; | |
import flash.display.Sprite; | |
import flash.events.MouseEvent; | |
import flash.geom.Point; | |
import flash.utils.Dictionary; | |
public class FluctGrid extends Sprite { | |
public var _tweenTime:Number = 0.5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cgon { | |
import flash.display.MovieClip; | |
import flash.display.Sprite; | |
public class FluctGridItem extends Sprite { | |
public var row:int; | |
public var col:int; | |
public var itemonme:MovieClip; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function arrangeItems():void { | |
var itemSelected:FluctGridItem = _dictionary[_currentItem]; | |
var cellToBeDraggedOn:Point = getCellCoord(_currentItem.x, _currentItem.y); | |
var intialCol:int = itemSelected.col; | |
var intialRow:int = itemSelected.row; | |
var colToBeDraggedOn:int = cellToBeDraggedOn.x; | |
var rowToBeDraggedOn:int = cellToBeDraggedOn.y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapReducev1(f: Int => Int, combine: (Int, Int) => Int, zero: Int)(a: Int, b: Int): Int = { | |
if (a > b) zero | |
else (a to b).map(f).reduce(combine) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapReduce(f:Int=>Int,combine: (Int,Int)=>Int, zero:Int)(a:Int,b:Int):Int ={ | |
if(a>b) zero | |
else combine(f(a),mapReduce(f, combine, zero)(a+1, b)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapReduce(f:Int=>Int,combine: (Int,Int)=>Int, zero:Int)(a:Int,b:Int):Int ={ | |
if(a>b) zero | |
else ??? | |
} | |
def sumGN(f:Int=>Int)(a:Int,b:Int) = mapReduce(f, (x,y)=>(x+y), 0)(a, b) | |
def productGN(f:Int=>Int)(a:Int,b:Int) = mapReduce(f, (x,y)=>(x*y), 1)(a, b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def product(f:Int=>Int)(a:Int,b:Int):Int={ | |
if(a>b)1 | |
else f(a)*product(f)(a+1,b) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(f:Int=>Int)(a:Int,b:Int):Int ={ | |
if(a>b) 0 | |
else f(a) + sum(f)(a+1,b) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cgon.BinaryTree; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class JUnitTest { | |
BinaryTree node1 = new BinaryTree(2,null,null); | |
BinaryTree node2 = new BinaryTree(3,null,null); | |
BinaryTree node3 = new BinaryTree(4, node1, node2); | |
BinaryTree node4 = new BinaryTree(5, null, null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BinaryTree { | |
int i; | |
BinaryTree right; | |
BinaryTree left; | |
public BinaryTree(int _i, BinaryTree _right, BinaryTree _left) { | |
i =_i; | |
right = _right; | |
left = _left; | |
} |