Skip to content

Instantly share code, notes, and snippets.

View fbanados's full-sized avatar

Felipe Bañados fbanados

View GitHub Profile
@fbanados
fbanados / gist:2171447
Created March 23, 2012 14:56
Auxiliar 2 CC4101 - Lenguaje AE
#lang plai
(print-only-errors #t)
(define-type AE
[num (n number?)]
[bool (n boolean?)]
[bool-and (lhs AE?) (rhs AE?)]
[bool-or (lhs AE?) (rhs AE?)]
[bool-not (s AE?)]
[add (lhs AE?)
@fbanados
fbanados / gist:2171473
Created March 23, 2012 15:00
Auxiliar 2 CC4101 - Ejercicios 1, 2, 3, 4, 5a
#lang plai
(print-only-errors #t)
;fibs : int -> int
;Retorna el n-esimo numero de fibonacci
(define (fibs n)
(cond
((equal? n 1) 0)
((equal? n 2) 1)
(else (+ (fibs (- n 1)) (fibs (- n 2)))))
@fbanados
fbanados / gist:2205744
Created March 26, 2012 15:09
Clase Substitución CC4101
#lang plai
#|
<WAE> ::= <num>
| {+ <WAE> <WAE>}
| {- <WAE> <WAE>}
| {with {<id> <WAE>} <WAE>}
| <id>
|#
(define-type WAE
@fbanados
fbanados / gist:2429272
Created April 20, 2012 14:53
Laziness en #lang racket
#lang racket
(define (my-if pred true false)
(if
(pred)
(true)
(false)))
;(define (infiniteloop x)
; (infiniteloop x))
@fbanados
fbanados / gist:2429315
Created April 20, 2012 14:58
Laziness en #lang plazy
#lang plazy
(define (my-if p t f)
(if p t f))
(define (infiniteloop x)
(infiniteloop x))
;al contrario de #lang racket, aquí esta función sí funciona correctamente.
(my-if #f (infiniteloop 0) 123)
@fbanados
fbanados / gist:2657106
Created May 11, 2012 02:24
Auxiliar 7
#lang racket
;P1 No. Al evaluar, el nombre 'fibs en la llamada recursiva no se encontrará en el ambiente.
;P3:
;pow no es recursiva por la cola
(define (pow base exp)
(if (= exp 0)
1
@fbanados
fbanados / gist:9921888
Created April 1, 2014 20:00
Installing ncurses on mac os x
brew install ncurses
gem install ncursesw -- --with-opt-dir=/usr/local/opt/ncurses
@fbanados
fbanados / gist:d6e0134ff226abe71984a2221bbc7234
Created May 23, 2017 01:18
F#'s pipe operator for racket.
(define pipe
; Inspired on F#'s Forward pipe operator (|>)
(lambda args
(let ((v (car args))
(functions (cdr args)))
(foldl (λ (f v) (f v)) v functions))))
(test (pipe 1
add1
#lang slideshow
(require slideshow/play)
(provide timer-slide)
(module stopwatch racket
(provide (all-defined-out))
(define time? number?)
(define (seconds n) n)
@fbanados
fbanados / AOC_Squeak.md
Last active December 4, 2020 23:50
Advent Of Code 2020

The --- separator is not squeak syntax, but is presented to distinguish IDE("Browser") code from REPL content ("Workspace").