apt install curl
apt install vim
apt install git
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 fib_cps = (n, k) => { | |
console.log(n); | |
if (n < 2) { | |
return k(1); | |
} | |
else { | |
return fib_cps(n - 1, c1 => { | |
return fib_cps(n - 2, c2 => { | |
return k(c1 + c2); | |
}) |
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
// basic idea | |
(f => f(f)(5))(f => n => n == 0 ? 1 : (n * f(f)(n-1))); | |
// This version doesn't work, because js is not lazy. | |
// const Y = f => (x => f(x(x)))(x => f(x(x))); | |
// const Y = f => (x => x(x))(x => f(a => x(x)(a))); | |
const Y = f => (x => f(y => x(x)(y)))(x => f(y => x(x)(y))); |
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
// We learn lots of functional "concept" when we coding, such as point-free, high order function, avoiding side effect | |
// function composition. | |
// We are told they are good and we should code like that way. | |
// We feel strugging when learn the advanced conecpt like monads, and have difficulty to apply them to our coding. | |
// Sometime I feel using "functional programming" create more problems or not realistic. | |
// Like Using Rambda |
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
// Stream | |
const stream = f => (x => x(x))(y => init => [init, m => y(y)(f(m))]); | |
const add3Stream = stream(n => n + 3); | |
const mult2Stream = stream(n => n * 2); | |
const inspect = stream(n => { | |
console.log('inspect:' + n); | |
return 0; | |
}); | |
const pipe = s1 => s2 => 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
const COLORS = { | |
blue: ['#1E88E5', '#90CAF9'], | |
brown: ['#6D4C41', '#D7CCC8'], | |
gray: ['#212121', '#BDBDBD'], | |
green: ['#388E3C', '#A5D6A7'], | |
red: ['#E53935', '#EF9A9A'], | |
orange: ['#F4511E', '#FFAB91'], | |
purple: ['#8E24AA', '#E1BEE7'], | |
yellow: ['#FFD600', '#FFF59D'], | |
} |
A Vue file is a file with .vue
extension.
It is composed by three parts, template
, script
, and style
. We ignore style
now for simplicity.
The template portion of a Vue file is almost like HTML, except it includes the ability to add embedded JavaScript and directives, among other things. The script portion describes the functionality of the application. It specifically does so with an object called data
, which provides values that are directly accessible in the template. Updates to values in data
will be automatically propagated on the user interface.
<template>
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
;; Let say we want to build a text adventure game like following. | |
;; You’re standing in a meadow. | |
;; There is a house to the north. | |
;; > north | |
;; You are standing in front of a house. | |
;; There is a door here. | |
;; > open door |
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
SELECT B1.BookNo | |
FROM Book B1 | |
WHERE B1.Price NOT IN (Select B2.Price FROM Book B2 ORDER BY B2.Price DESC LIMIT 1) ORDER BY B1.Price DESC LIMIT 1; | |
SELECT p.Sid, p.BookNo | |
FROM (SELECT Buys.Sid, Buys.BookNo, Book.Price FROM Buys, Book WHERE Buy.BookNo = Book.BookNo) AS p | |
WHERE p.Price NOT IN | |
(SELECT p1.Price | |
FROM (SELECT Book.Price FROM Buys, Book WHERE Buys.Sid = p.Sid AND Book.BookNo = Buys.BookNo) AS p1, | |
(SELECT Book.Price FROM Buys, Book WHERE Buys.Sid = p.Sid AND Book.BookNo = Buys.BookNo) AS p2 |
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
(require (for-syntax syntax/parse)) | |
(define-syntax (struct/con stx) | |
(syntax-parse stx | |
[(_ id ((pa colon checkers) ... )) | |
#:when (and (map (lambda (x) (eqv? (syntax-e #'x) ':)) (syntax->datum #'(colon ...)))) | |
(begin | |
(define make-id (string->symbol (string-append "make-" (symbol->string (syntax->datum #'id))))) | |
#`(begin |