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
// a function that take one argument x and returns itself | |
function(x) { return x;} | |
// a function that take nothing; but this will not be used | |
// naming a function is do as | |
var functionName = function (x) { // do something with x | |
return x; | |
}; | |
// also | |
function functionName(x) { //... | |
return x; |
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
module Main where | |
-- recursive square root function | |
rsqrt x n = if n == 1 then sqrt x else sqrt (x + rsqrt x (n-1)) | |
-- product expansion of pi upto n terms | |
productPi n = 2 * product [ 2 / (rsqrt 2 i) | i <-[1..n]] | |
main = do | |
putStr "Actual value of pi: " |
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
Actual value of pi: 3.141592653589793 | |
Product expansion upto n terms: | |
1 --> 2.82842712474619 | |
2 --> 3.0614674589207183 | |
3 --> 3.1214451522580524 | |
4 --> 3.1365484905459393 | |
5 --> 3.140331156954753 | |
10 --> 3.1415914215112 | |
100 --> 3.141592653589797 |
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
PFont font; | |
void setup(){ | |
background(0); | |
size(500,500); | |
noLoop(); | |
// you can find this file in my LangtonAnt project | |
// at https://github.com/Mizzlr/LangtonAnt | |
// place FreeMonoBold.ttf in a directory named data | |
// under the Parent directory recursivePi |
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
Block of size=15 is | |
CACCACCTTGTGGAG | |
ATree as dict: | |
╒═════════╤═════════╕ | |
│ chunk │ count │ | |
╞═════════╪═════════╡ | |
│ │ 15 │ | |
├─────────┼─────────┤ | |
│ A │ 3 │ | |
├─────────┼─────────┤ |
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
CTGCCGCAAGCCGATCGGAGATCGCAGGTGAGAACCGCAG | |
TAATTGGTCTAGGTGGGAGCGACGCCATACCTCTACGGCA | |
CACACACACTCGTTTGATATTCCTAGGTGCGCGTTCTTCC | |
TACAGACATCGTGTGAGATATGTACCCACATTCAAAGAAA | |
ACTAGATCAAGTTGCTTGACCCGCTGGAGACGGGCCTGGT |
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
module Main where | |
-- x -> number whose sqrt has to be found | |
-- y -> approximate guessed sqrt of x | |
mysqrt x y = let z = x + y ^ 2 | |
in z / (4 * y) + x * y / z | |
main = do | |
-- lets compute sqrt(10) with guess=3 | |
putStr "Actual Value: " |
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 ATree: | |
"Aggregator Tree Data Structure" | |
def __init__(self): | |
self.count = 0 | |
self.children = {} | |
def __repr__(self): | |
return "<ATree: %d\n\t%s>" \ | |
% ((self.count, self.children)) \ | |
if self.children else "<ATree: %d>" \ |
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
#! /usr/bin/octave -qf | |
pkg load signal | |
% read the file name | |
fprintf('\n\nInitializing equalizer ...\n'); | |
% setting default values for Equalizer | |
Equalizer.type = 'Custom'; | |
Equalizer.amps = [7 7 2 0.25 0]; | |
Equalizer.freqs = [100 500 1000 5000 10000]; |
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
// Create a 2D array for the grid | |
int[][] grid; | |
// each cell is 4x4 pixel | |
int cellSize = 4; | |
// the whole grid is 125x125 cells | |
int gridSize = 125; | |
int cellStartX = 0; | |
int cellStartY = 0; | |
// enumerate directions |