Skip to content

Instantly share code, notes, and snippets.

View alcidesfp's full-sized avatar

Alcides Flores Pineda alcidesfp

View GitHub Profile
@alcidesfp
alcidesfp / nomedad.scm
Created September 25, 2012 17:02
Programa mascota simple en Scheme Chicken
#!/usr/local/bin/csi -s
;; -*- coding:utf-8; mode:Scheme -*-
(use extras)
(define (pide-nombre)
(display "Hola, ¿Cuál es tu nombre?: ")
(read-line))
(define (pide-ann)
(display "¿En qué año naciste?: ")
@alcidesfp
alcidesfp / arbolito-nav.scm
Created December 27, 2012 06:12
Arbolito de Navidad
(cond-expand (chicken (use srfi-1 srfi-13))
(kawa (require 'srfi-1 'srfi-13)))
(let* ((numeros (filter odd? (iota 20 1)))
(maxnum (apply max numeros)))
(newline)
(for-each (lambda (n)
(format #t "~a~a~%" (make-string (/ (- maxnum n) 2) #\space)
(make-string n #\*)))
numeros)
@alcidesfp
alcidesfp / string_calc.scm
Last active November 14, 2016 16:22
String Calculator en Kawa
; -*- coding: utf-8; mode: Scheme -*- Kawa
;; Coding Kata String Calculator (http://osherove.com/tdd-kata-1/)
(require 'srfi-1 ) ;; List Library
(require 'srfi-13) ;; String Library
(require 'srfi-14) ;; Character-set Library
(define-alias String java.lang.String)
(define-alias RuntimeException java.lang.RuntimeException)
main = do
putStrLn "¡Hola!, ¿Cuál es tu nombre?"
nombre <- getLine
putStrLn "¿En qué año naciste?"
ann_nac <- getLine
let edad = 2014 - (read ann_nac)::Integer
putStrLn ("Hola " ++ nombre)
#!/usr/bin/perl -w
print "Hola ¿Cual es tu nombre?: ";
chomp(my $nombre = readline);
print "¿En que año naciste?: ";
chomp(my $ann = readline);
print "Hola $nombre.\n";
print "En el año 2014 tendrás ", (2014-$ann), " años.\n";
@alcidesfp
alcidesfp / nomedad.java
Created December 20, 2013 19:41
Programa mascota en Java
import java.io.*;
class nomedad {
public static void main (String[] args) throws IOException {
Integer edad;
String strnombre;
BufferedReader brin;
int n;
/* Inicialización */
brin = new BufferedReader(new
InputStreamReader(System.in));
//-*- coding:utf-8; -*-
def edad
def nombre
def brin = new BufferedReader(new InputStreamReader(System.in))
def num
print("Hola, ¿Cuál es tu nombre? ")
nombre = new String(brin.readLine())
print("¿En qué año naciste? ")
@alcidesfp
alcidesfp / gist:8100459
Created December 23, 2013 16:51
Snippet de código en Kawa con Swing
;; -*- coding: utf-8; mode: Scheme -*-
;; Snippet de código utilizando Swing en Kawa
(define-alias JFrame javax.swing.JFrame)
(define-alias JLabel javax.swing.JLabel)
(let ((frame1 (JFrame "Ventana Hola")))
(*:add frame1 (JLabel "Hola a todos desde Kawa"))
(*:pack frame1)
(*:setDefaultCloseOperation frame1 JFrame:EXIT_ON_CLOSE)
(*:setVisible frame1 #t))
@alcidesfp
alcidesfp / gist:95f32461b78bbf109fe2
Last active August 29, 2015 14:04
Respalda carpeta actual en Kawa
":"; exec kawa -f $0 "$@" # -*- coding:utf-8; mode:Scheme -*-
(define-alias File java.io.File)
(define-alias Date java.util.Date)
(define-alias DateFormat java.text.SimpleDateFormat)
(let* ((this-dir (path-last (*:getCanonicalPath (File "."))))
(backup-date (*:format (DateFormat "yyyyMMdd-HHmm") (Date)))
(nom-tar (format #f "~A_~A.tar" this-dir backup-date)))
(format #t "Generando respaldo ~A ...~%" nom-tar)
@alcidesfp
alcidesfp / read-properties.scm
Last active August 29, 2015 14:04
Kawa: Load a properties file
":"; exec kawa -f $0 "$@" #-*- coding:utf-8 -*-
(define-alias Properties java.util.Properties)
(define-alias FileInputStream java.io.FileInputStream)
(let ((props (Properties)))
(props:load (FileInputStream "application.properties"))
(format #t "Nombre: ~A~%" (props:getProperty "app.name"))
(format #t "Version: ~A~%" (props:getProperty "app.version")))