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
const dagPB = require('@ipld/dag-pb'); | |
const UnixFS = require('ipfs-unixfs'); | |
const multiformats = require('multiformats/cid'); | |
const data = // file's byte data | |
// console.log(data) | |
const bytes = dagPB.encode({Data: new UnixFS.UnixFS({type:'file',data: data.pop()}).marshal(),Links:[]}); | |
console.log(bytes); |
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
class main { | |
def maim = print(FizzBuzzWhizz(3,5,7)) | |
def FizzBuzzWhizz(a :Int,b :Int,c :Int) ={ | |
for(i <- 1 to 100) | |
i match { | |
case (i + i % a) => println("Fizz") | |
case (i + i % b) => println("Buzz") | |
case (i + i % c) => println("Whizz") | |
} |
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 scala.collection.mutable.ArrayBuffer | |
import scala.io._ | |
import scala.util.Random | |
// A low efficient implement of Karger's algorithm (Randomized Contraction Algorithm) in Scala | |
// https://en.wikipedia.org/wiki/Karger%27s_algorithm | |
object RandomizedContractionAlgorithm { |
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 scala.collection.mutable.ArrayBuffer | |
import scala.io._ | |
import scala.math._ | |
object QuickSort{ | |
var count = 0 | |
def median_of_three(array: ArrayBuffer[Int]): ArrayBuffer[Int] = { | |
if(array.length <= 1 )return array | |
val median:Int =(array.length-1)/2 |
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
Future{ | |
//......code something | |
//I don't know how to make a scala Future in java~~ | |
}.map(new Function1<Object, Object>(){ | |
@Override | |
public Object apply(Object v1) { | |
//do something....... | |
return 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
class Collatz_conjecture { | |
var max: Set[Int] =Set() | |
val len=10 | |
var number=2 | |
def launch()={ | |
while(true){ | |
if(!max.apply(number)){ | |
var number_2=number | |
max += number_2 | |
print(number_2) |
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
/*-------------Memory-Manager------------------------*/ | |
typedef struct { | |
void * pointer; | |
void * protect_level; | |
}mem_table; | |
void *mem_apply(size_t); | |
void *mem_apply_important(size_t); | |
void mem_free(void *); | |
#define malloc(_Size) mem_apply(_Size) | |
#define malloc_important(_Size) mem_apply_important(_Size) |