Skip to content

Instantly share code, notes, and snippets.

View jagbolanos's full-sized avatar

Jorge Garcia jagbolanos

View GitHub Profile
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;
}
#!/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)
#!/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|
//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)
#include <iostream>
class A {
private:
int a;
public:
static double sa;
A(int _a) {
/**
* 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);
//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)
}
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)
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)
- (void) postToTwitterPhotoAtIndexPath: (NSIndexPath*) indexPath {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
PFObject *photo = [self.myPhotos objectAtIndex:indexPath.row];
// Create an account store object.
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
// Create an account type that ensures Twitter accounts are retrieved.
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to use their Twitter accounts.