Skip to content

Instantly share code, notes, and snippets.

View scvalencia's full-sized avatar

scvalencia scvalencia

  • Universidad de los Andes
  • Bogotá, Colombia
View GitHub Profile
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10.0-RC1:
brew install https://raw.github.com/gist/3939012/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0-RC1
import rbm
import scipy
import cpickle
import numpy as np
'''
This implementation is based on the MovieLens 100k dataset,
available at http://grouplens.org/datasets/movielens/
'''

Setup Mac OS X

I'm in a hospital in Spain and my MacBook was stolen.

Hospital Commit

Now I bought a new one and need to configure it. I have an external hard drive that backup everything using Time Machine, but I don't want all the crap I had in the old one.

1. Run Software Update

(ns my-transducers.core
(:require [clojure.core.async :as async]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Understanding Transducers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This is the source code for the blog post Understanding Transducers, found
;; here: http://elbenshira.com/blog/understanding-transducers
;;
def nQueens(n: Int) = (0 until n).permutations filter {p => // p[i] is the column of the queen on ith row (must be a permutation of 0 until n)
val i = p.zipWithIndex.toSet
i.map{case (c, d) => c + d}.size == n && i.map{case (c, d) => c - d}.size == n // No 2 queens can have same col + diag or col - diag
}
for {
(solution, num) <- nQueens(8).zipWithIndex
_ = println(s"Solution #${num + 1}:")
col <- solution
row = solution.indices.map(i => if (i == col) 'Q' else '-')
;; primitive-procedures con los nuevos bindings
;; AQUÍ PUEDEN INTRODUCIR LAS FUNCIONES QUE SU LENGUJE VA A CONOCER!
(define primitive-procedures (list
(list 'car car)
(list 'second cdr)
(list 'cons cons)
(list 'null? null?)
(list '+ +)
(list '* *)
(list '= =)
data Expr = Const Int
| Var String
| Plus Expr Expr
| Minus Expr Expr
| Mul Expr Expr
type EnvType = [(String, Int)]
fetch_error :: String -> String
fetch_error str = "No variable of name " ++ str ++ " found!"
;; =====================================================
;; es necesario para que los siguientes philos sirvan,
;; cambiar la definciión original de primitive-procedures
;; por la siguiente:
;; =====================================================
(define primitive-procedures
(list
(list 'car car)
(list 'second cdr)
(list 'cons cons)