Skip to content

Instantly share code, notes, and snippets.

View ppsdatta's full-sized avatar

Sourav Datta ppsdatta

View GitHub Profile
@ppsdatta
ppsdatta / codes.scala
Last active October 6, 2022 08:52
Some scala functions
def permutations(nums: Seq[Int]): Seq[Seq[Int]] = {
if (nums.isEmpty)
Array(Seq())
else {
for (
n <- nums;
perms <- permutations(nums.filter(_ != n))
) yield n +: perms
}
}
@ppsdatta
ppsdatta / INSTALL.md
Last active September 30, 2022 10:58 — forked from thomasheller/INSTALL.md
Install Arch Linux in VirtualBox VM
@ppsdatta
ppsdatta / pok.sc
Created September 29, 2022 13:47
Pok - A toy language in Scala worksheet
trait Pok {
def rank: Int
def isScalar: Boolean
def isVector: Boolean
def isFn: Boolean
def typeString: String
@ppsdatta
ppsdatta / codes.apl
Last active September 27, 2022 14:38
Some APL codes
LinSearch ← { ⍸⍺=⍵ }
a ← 23 46 ¯9 5 67 0 10
¯9 LinSearch a ⍝ 3
b ← 4 5 ¯3 23 ¯3 45 0 1
¯3 LinSearch b ⍝ 3 5
@ppsdatta
ppsdatta / GUESS.BAS
Last active September 16, 2022 10:44
GUESS game in Applesoft BASIC
10 HOME
12 PRINT "Guess a number from 1 to 100"
14 PRINT "I WILL TRY TO GUESS NOW..."
16 L=0:H=101
18 M=INT((L+H)/2)
20 PRINT "IS IT ";M;"?"
22 PRINT "IF YES, ENTER 0."
24 PRINT "IF IT IS MORE THAN GUESS, ENTER 1"
26 PRINT "IF IT IS LESS THAN GUESS, ENTER 2"
28 INPUT C
@ppsdatta
ppsdatta / misc.txt
Last active April 21, 2022 06:06
Various Algorithms
;;; Lisp - top 2 in a list
(defun top-2 (a)
(let ((ls (reduce
#'(lambda (vs n)
(if (null (third vs))
(list
n
(second vs)
n)
@ppsdatta
ppsdatta / program.bqn
Created April 19, 2022 06:26
BQN Expressions
SortByParity ← (((¬2⊸|)/⊢)∾(2⊸|/⊢))
SortByParity 1‿2‿3‿4
@ppsdatta
ppsdatta / b1_c1.js
Created October 25, 2021 06:41
b1_c1
const B = (x, y) => z => x(y(z))
// Combinators
const I = x => x
const K = (x, y) => x
const S = (b, u) => x => b(u(x), x)
const Sp = (b, u, v) => x => b(u(x), v(x))
const B = (u, v) => (x) => u(v(x))
const C = (b, u, v) => (x, y) => b(u(x, y), v(y))
// Helpers
const eq = (x, y) => x === y
@ppsdatta
ppsdatta / cat.pas
Created July 7, 2021 14:53
A simple program to display files in paginated manner in Turbo Pascal 3 on CP/M 2
program cat(input, output);
var
fname: string[60];
f: text;
ln: string[100];
rw: integer;
i: integer;
begin
write('FILE? ');
readln(fname);