Skip to content

Instantly share code, notes, and snippets.

(import srfi-18)
(import (chicken format))
(import (chicken random))
;; Compute fib(n)
(define (fib n)
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
;; Compute and print all fib until n, yield after each fib computation
(define (fib-seq n)
@ryloric
ryloric / queens.fnl
Created September 30, 2020 15:01
N-Queens in Lua and Fennel
(global N 12)
(fn place-ok? [a n c]
(var ok? true)
(var i 1)
(while (and ok? (< i n))
(set ok? (not (or (= (. a i) c)
(= (- (. a i) i) (- c n))
(= (+ (. a i) i) (+ c n)))))
(set i (+ 1 i)))
;; Spoj code : COINS
(defun memoize (fn)
(let ((cache (make-hash-table :test #'equal)))
#'(lambda (&rest args)
(multiple-value-bind
(result exists)
(gethash args cache)
(if exists
result
@ryloric
ryloric / main.dart
Created July 12, 2020 11:49
ChangeNotifier
import 'package:flutter/material.dart';
void main() {
print("Hello World!");
var notifier = TestNotifier();
var listener1 = () {
print("Inside listener 1");
};
@ryloric
ryloric / utils.ts
Last active June 29, 2020 15:51
Deno test
export type Person = {
firstName: string,
lastName: string,
age: number
}