Skip to content

Instantly share code, notes, and snippets.

View lidangzzz's full-sized avatar
😅

立党 Lidang lidangzzz

😅
View GitHub Profile
function fibonacci(x){
if (x<0) return 0;
if (x==1 || x==0) return 1;
//elst x>=2
let dp = [1,1]
for (let i=2;i<=x;i++){ let val = dp[dp.length-1] + dp[dp.length-2]; dp.push(val)}
return dp[x];
}
/*
Function fibonacci
Author: lidangzzz
Input: x: number
Output: fibonacci of x
*/
function fibonacci(x){
if (x<0) return 0;
@lidangzzz
lidangzzz / tvm.js
Last active November 20, 2020 23:44
function EmccWASI() {
var Module=typeof Module!=="undefined"?Module:{};var __wasmLib={};function __wasmLibInstantiateWasm(imports,successCallback){__wasmLib.imports=imports;__wasmLib.successCallback=successCallback}function __wasmLibStart(wasmInstance){__wasmLib.successCallback(wasmInstance)}__wasmLib.start=__wasmLibStart;var Module={"instantiateWasm":__wasmLibInstantiateWasm,"wasmLibraryProvider":__wasmLib};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRON
@lidangzzz
lidangzzz / demo_2.hhs
Last active December 14, 2020 00:22
demo_2.hhs
// generate 2D points as vectors of x and y
let x = range(-10,10,0.1);
let y = sin(x) + random(1,x.cols);
// plot x and y as scatter
plot2D(x,y);
// ploy x and y as line
plot2DLine(x,y);
@lidangzzz
lidangzzz / matrix_add.py
Created March 23, 2021 18:42
matrix_add
def matrix_add(matrixA, matrixB):
return matrixA + matrixB
@lidangzzz
lidangzzz / my_demo.hhs
Last active April 4, 2021 18:56
my_demo.hhs
// generate 2D points as vectors of x and y
x = range(-10,10,0.1);
y = sin(x) + random(1,x.cols);
// plot x and y as scatter
plot2D(x,y);
// ploy x and y as line
plot2DLine(x,y);
print("hello world 1")
print`hello world 2`
print("Hello! This is a script saved at Github Gist and loaded to Hedgehog Lab automatically from URL!")
x = random(1000,1000)
tic()
y = x*x
toc()
x.mode = "gpu"
tic()
y = x*x
@lidangzzz
lidangzzz / my_demo_function.hhs
Created April 29, 2022 04:10
my_demo_function
function my_demo_function(matrixA, matrixB){
return 4* matrixA + 3 * matrixB.T();
}