Skip to content

Instantly share code, notes, and snippets.

View cebolan's full-sized avatar

cebolan

  • brazil
View GitHub Profile
@swannodette
swannodette / gist:1119534
Created August 2, 2011 03:17
latest.clj
(let [x [1 2 4]]
(match [x]
[[1 2 3]] :a0
[[1 2 4]] :a1))
;; =>
(cond
(vector? x) (let [x0 (first x) x (next x)]
(cond
@alandipert
alandipert / maptemplate.md
Created January 30, 2013 00:28
ClojureScript macros: kinda, sorta, not really.

ClojureScript macros: kinda, sorta, not really.

ClojureScript does not have a standalone macro system. To write ClojureScript macros, one must write them in Clojure and then refer to them in ClojureScript code. This situation is workable, but at a minimum it forces one to keep ClojureScript code and the macros it invokes in separate files. I miss the locality of regular Clojure macros, so I wrote something called maptemplate that gives me back some of what I miss. The technique may be useful in other scenarios.

Problem

Suppose you're wrapping functionality in another namespace or package so that you can have your own namespace of identically named but otherwise decorated functions:

ClojureScript:

@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active May 19, 2024 19:25
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@johnmastro
johnmastro / slime-ac-example.el
Created February 24, 2016 21:50
Example of setup with SLIME and auto-complete
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(defvar my-packages '(slime auto-complete ac-slime)
"List of packages to install automatically.")
(let ((need (delq nil (mapcar (lambda (pkg)
@joelouismarino
joelouismarino / googlenet.py
Last active October 9, 2023 07:09
GoogLeNet in Keras
from __future__ import print_function
import imageio
from PIL import Image
import numpy as np
import keras
from keras.layers import Input, Dense, Conv2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D, Dropout, Flatten, Concatenate, Reshape, Activation
from keras.models import Model
from keras.regularizers import l2
from keras.optimizers import SGD
; A MICRO-MANUAL FOR LISP - NOT THE WHOLE TRUTH, 1978
; John McCarthy, Artificial Intelligence Laboratory, Stanford University
; https://www.ee.ryerson.ca/~elf/pub/misc/micromanualLISP.pdf
; https://github.com/jaseemabid/micromanual
; for CL : Rainer Joswig, joswig@lisp.de
; this version runs in a Common Lisp
;; (defvar *unquote** (make-symbol "UNQUOTE*"))
(defvar *unquote** :unquote*)
(defvar *unquote-splicing** :unquote-splicing*)
(defvar *qq-quote* (make-symbol "QUOTE"))
(defvar *qq-list* (make-symbol "LIST"))
(defvar *qq-append* (make-symbol "APPEND"))
(defvar *quasiquote** 'quasiquote*)
;; Taken from On Lisp