Skip to content

Instantly share code, notes, and snippets.

View albertzak's full-sized avatar

Albert Zak albertzak

View GitHub Profile
@cgrand
cgrand / asym.clj
Created November 18, 2024 16:56
->> and -> asymmetries
;; cond-> inside -> is fine
(-> input
(dothis ...)
(cond-> test (maybe do this also ...))
(dothat ...))
;; cond->> inside ->> isn't fine
(->> input
(dothis ...)
(cond->> test (maybe do this also ...)) ; the input seq comes last because of ->> but cond->> expects it first.

Thinking about "syntax families", and how to ~categorize them.

My broad thinking is that all syntax can be usefully flattened into "atoms" and "collections" (delimited & separated sequences of atoms and collectiosn), and then a language's syntax can be characterized by "what kinds of atoms are there" and "what kinds of collections are there". The structured editor that I'm building then works at the level of those atoms and collections (the 'reader' phase, in lisp), providing in my opinion a sweet spot of "just enough structure to be powerful & useful with out being overly restrictive & annoying".

Here's how I would describe various syntaxes:

Programming languages

Forth:

@ssrihari
ssrihari / clojure-learning-list.md
Last active April 17, 2025 15:56
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
@jackrusher
jackrusher / trinity.js
Created March 29, 2021 09:23
A fast, minimal JS triple store implementation in ~70 lines of code
// three indices to efficiently support all lookups
function createDB() {
return {eav: new Map(),
ave: new Map(),
vea: new Map()};
}
function addToIndex(xs, x, y, z, triple) {
let ys = xs.get(x);
if(ys == undefined) {
; John McCarthy. Puzzle Solving Program in LISP. Memo 20, Artificial Intelligence Project
; http://www.bitsavers.org/pdf/mit/ai/aim/AIM-020.pdf
; 1960
; Common Lisp translation: Rainer Joswig, 2016, [email protected]
; basically the code is unchanged, but using s-expression syntax in Common Lisp
(defparameter pzl
'((a1 (a2 a5) 7.5)
(a2 (a1 a5 a9 a3) 3.5)
@mfikes
mfikes / README.md
Last active April 23, 2025 20:32
eval in ClojureScript

ClojureScript master now has cljs.core/eval. This delegates to cljs.core/*eval* which, by default throws, but you can bind it to any implementation that can compile and evaluate ClojureScript forms.

If you require the cljs.js namespace (which is the main support namespace for self-hosted ClojureScript), then cljs.core/*eval* is set to an implementation that uses self-hosted ClojureScript for this capability. This means that all self-hosted ClojureScript environments will now have a first-class eval implementation that just works. For example, Planck master:

$ planck -q
cljs.user=> (eval '(+ 2 3))
5
@jackrusher
jackrusher / triples.clj
Last active February 18, 2025 16:40
A super simple example of inference from a set of triples.
;; knowledge representation, syllogism via knowledge base
(defrecord Triple [subject predicate object])
(def knowledge-base
[(Triple. :Socrates :is-a :Greek)
(Triple. :Greek :is-a :human-being)
(Triple. :human-being :has-property :mortal)])
(defn collect-predicate-along-axis [kb subject predicate axis]
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 9, 2025 18:09
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@mattetti
mattetti / bs_header_doc_parser.rb
Created November 8, 2011 20:19
A dumb parser to parse a header file generated via sdef/sdp. The parsed info is saved to a local json file.
#!/usr/bin/env ruby
require 'json'
file = ARGV.first
raise "Can't find #{file.inspect}" unless File.exist?(file)
header = File.open(file)
doc = {}
properties = {}