View horner.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float horner(float A[], float x, int n) { | |
float resultado = A[n]; | |
for (int i=n-1; i>=0 ; i--) { | |
resultado = resultado * x + A[i]; | |
} | |
return resultado; | |
} |
View downloadactassv.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "net/http" | |
require 'open-uri' | |
def download(url, acta) | |
File.open("presidente/#{acta}", "wb") do |saved_file| | |
# the following "open" is provided by open-uri | |
open(url, 'rb') do |read_file| | |
saved_file.write(read_file.read) |
View generadordedepartamentosymunicipios.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'csv' | |
# 3 dept, 4 mun, 1 mesa | |
departamento = nil | |
municipio = nil | |
primero = nil | |
ultimo = nil | |
departamentos = Hash.new | |
CSV.foreach("departamentos.csv") do |row| |
View ExamenFinal20130921.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Recuerden que no pueden usar ciclos ya que | |
//es parte de los objetivos de la clase manejar la recursividad de los lenguajes funcionales | |
//6 Oro Eliminar los ultimos n elementos de la lista | |
//ultimosn(List(1,3,5,0,7,4,2,6), 3) => List(1,3,5,0,7) | |
def ultimosn(l:List[Int], n:Int) : List[Int] | |
//6 Oro Devolver una lista con los elementos que estén en una posición impar | |
//posicionimpar(List(1,3,5,0,7,4,2,6)) => List(1,5,7,2) |
View examenII42.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class A { | |
private: | |
int a; | |
public: | |
static double sa; | |
A(int _a) { |
View guid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a GUID string, according to RFC4122 standards. | |
* @returns {String} The generated GUID. | |
* @example af8a8416-6e18-a307-bd9c-f2c947bbb3aa | |
* @author Slavik Meltser (slavik@meltser.info). | |
* @link http://slavik.meltser.info/?p=142 | |
*/ | |
function guid() { | |
function _p8(s) { | |
var p = (Math.random().toString(16)+"000000000").substr(2,8); |
View solucionesexamenfinal.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Examen Final | |
//6 Oro Devuelve el elemento maximo de una lista | |
//e.g. maximo (List(3,4,1,2,9,11,7,5,0)) => 11 | |
def maximoHelper(l:List[Int], max:Int) : Int = l match { | |
case Nil => max | |
case x :: xs => if (x > max) maximoHelper(xs, x) else maximoHelper(xs, max) | |
} |
View ejemplos4.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class NB(e:Int, izq:NB, der:NB) | |
def busquedaBinaria(v:Int, a:NB) : NB = { | |
if (a == null) | |
a | |
else { | |
if (v == a.e) | |
NB(v,null,null) | |
else { | |
if (v < a.e) |
View ejemplos3.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumarListas(l:List[Int], m:List[Int]) : List[Int] = (l, m) match { | |
case (Nil, Nil) => Nil | |
case (Nil, y :: ys) => y :: sumarListas(Nil, ys) | |
case (y :: ys, Nil) => y :: sumarListas(ys, Nil) | |
case (x :: xs, y :: ys) => (x+y) :: sumarListas(xs, ys) | |
} | |
def extraerImpares(l:List[Int]) : List[Int] = l match { | |
case Nil => Nil | |
case x :: xs => if ( x % 2 != 0) x :: extraerImpares(xs) else extraerImpares(xs) |
NewerOlder