Hogget: Comparison to JavaScript
Comments
; explanatory comment
// explanatory comment
Variables
(let val 42)
const val = 42
Function call
(log 'value is: ' val)
console.log('value is: ', val)
Conditional: if
(if (> val 100) (log 'value is bigger than 100'))
if (val > 100) { console.log('value is bigger than 100') }
Array access
(let list ['foo' 'bar']) (let first (head list)) (let second (nth 1 list)) (log first second)
const list = ['foo', 'bar'] const first = list[0] const second = list[1] console.log(first, second)
Functional Programming: point-free style
(let formatEuro (map (concat '€ '))) (let takeSignificant (filter (<= 100))) (let app (pipe takeSignificant formatEuro)) (app [42 1337 9000])
import * as R from 'ramda' const formatEuro = R.map(R.add('€ ')) const takeSignificant = R.filter(R.lte(100)) const app = R.pipe(takeSignificant, formatEuro) app([42, 1337, 9000])