This file contains 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 fibonacci(num: Int): BigInt = | |
@scala.annotation.tailrec | |
def fibFcn(n: Int, acc1: BigInt, acc2: BigInt): BigInt = n match | |
case 0 => acc1 | |
case 1 => acc2 | |
case _ => fibFcn(n - 1, acc2, acc1 + acc2) | |
fibFcn(num, 0, 1) | |
fibonacci(90) |
This file contains 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
/** | |
* D Holbrook | |
* | |
* Code Club: PO1 | |
* | |
* (*) Define a binary tree data structure and related fundamental operations. | |
* | |
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported: | |
* | |
* Constructors |
This file contains 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
'use strict'; | |
angular.module('app').config(['$routeProvider', function ($routeProvider) { | |
var routes =[{ | |
url: '/dashboard', | |
config: { | |
template: '<dashboard></dashboard>' | |
} | |
}, |
This file contains 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 util; | |
import java.io.*; | |
import java.net.InetAddress; | |
import java.net.Socket; | |
import java.net.URL; | |
import java.net.UnknownHostException; | |
import java.util.Map; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; |
This file contains 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
val jsonString = """{"count":100205,"_shards":{"total":5,"successful":5,"failed":0}}""" | |
val tweets = scala.util.parsing.json.JSON.parseFull(jsonString) | |
def getValue(parsedJson: Option[Any], key: String): Double = { | |
parsedJson match { | |
case Some(m: Map[String, Any]) => m(key) match { | |
case d: Double => d | |
} | |
} |
This file contains 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
BEGIN | |
FOR Rec IN (SELECT object_name, object_type FROM all_objects WHERE owner='SOURCEUSER' AND object_type IN ('TABLE','VIEW','PROCEDURE','FUNCTION','PACKAGE')) LOOP | |
IF Rec.object_type IN ('TABLE','VIEW') THEN | |
EXECUTE IMMEDIATE 'GRANT SELECT, UPDATE, INSERT, DELETE ON SOURCEUSER.'||Rec.object_name||' TO TARGETUSER'; | |
ELSIF Rec.object_type IN ('PROCEDURE','FUNCTION','PACKAGE') THEN | |
EXECUTE IMMEDIATE 'GRANT EXECUTE ON SOURCEUSER.'||Rec.object_name||' TO TARGETUSER'; | |
END IF; | |
END LOOP; | |
END; |
This file contains 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
//val lines = scala.io.Source.fromFile("test.txt", "utf-8").getLines.toList | |
val lines = List("HEAD 000001","HEAD 000002","HEAD 000002","HEAD 000002","HEAD 000003","HEAD 000003") | |
val keywords = lines.map(x => x.substring(9, 15)).distinct | |
def groupByKeyword(lines: List[String], keywords: List[String]): List[List[String]] = keywords match { | |
case keyword :: Nil => lines.groupBy(x => x.substring(9, 15).contains(keyword)).get(true).toList | |
case keyword :: _keywords => { | |
val mapped = lines.groupBy(x => x.contains(keyword)) | |
mapped.get(true).toList.head :: groupByKeyword(mapped.get(false).toList.head, _keywords) |