<commit_before>//Implements http://rosettacode.org/wiki/9_billion_names_of_God_the_integer

extern crate num;

use num::bigint::BigUint;
use std::from_str::FromStr;
use std::string::String;
use std::cmp::min;



 fn cumu<'a>(num: uint, cache: &'a mut Vec<Vec<BigUint>>) -> &'a Vec<BigUint> {
	
    let len = cache.len();


    for l in range(len, num+1)
    {
	    let initial_value:BigUint = FromStr::from_str("0").unwrap();
	    let mut r: Vec<BigUint> = vec!(initial_value);
		
	    for x in range(1, l+1)
	    {
		 let y = r.get(x -1).clone();
		 let z = cache.get(l-x).get(min(x, l-x)).clone();
		 let w = y+z;
		
		 r.push(w)
                
	    }

	    cache.push(r);

    }

    cache.get(num)
}

// Returns a line

fn row(num: uint,  cache: &mut Vec<Vec<BigUint>>) -> String {
	 
	let r = cumu(num,cache);
	let mut returned_string = String::new();
	for i in range(0,num)
	{
		let i = *r.get(i+1) - *r.get (i);
		let z = i.to_str();
		let y = z.as_slice();
		returned_string.push_str(y);
		returned_string.push_str(", ");
	}
	returned_string
	
	 


}

#[cfg(not(test))]
fn main()
{

	    let mut cache: Vec<Vec<BigUint>> = Vec::new();

	    let initial_value:BigUint = FromStr::from_str("1").unwrap();

	    let initial_vector : Vec<BigUint> = vec!(initial_value);
	    cache.push(initial_vector);
	   


	    println!("rows");
	    for n in range(1, 11)
	    {	
			let x = n as uint;
			println!("{}: {}", n, row(x,&mut cache));
	    }

	    println!("sums");

	    let x: Vec<uint> = vec!(23, 123, 1234, 12345);
	    for y in x.iter()
	    {
			let z = cumu(*y,&mut cache);
			let w = z.last();
			println!("{}: {}", y, w.unwrap());
			

	   }
		

	    
           

}


#[test]
fn test_cumu()
{

	    let mut cache: Vec<Vec<BigUint>> = Vec::new();

	    let initial_value:BigUint = FromStr::from_str("1").unwrap();

	    let initial_vector : Vec<BigUint> = vec!(initial_value);
	    cache.push(initial_vector);


	    let a: Vec<uint> = vec!(23, 123, 1234);
	    let b: Vec<BigUint> = vec!(FromStr::from_str("1255").unwrap(), FromStr::from_str("2552338241").unwrap(), FromStr::from_str("156978797223733228787865722354959930").unwrap());
	    let mut n=0;
	    for y in a.iter()
	    {
			let z = cumu(*y,&mut cache);
			let w = z.last().unwrap();
			assert!(w == b.get(n));
			n= n+1;
			

	   }
}


#[test]
fn test_row()
{

	    let mut cache: Vec<Vec<BigUint>> = Vec::new();

	    let initial_value:BigUint = FromStr::from_str("1").unwrap();

	    let initial_vector : Vec<BigUint> = vec!(initial_value);
	    cache.push(initial_vector);
	   
	    let a: String = FromStr::from_str("1, 2, 1, 1, ").unwrap();

		let x = 4;
			assert!(a == row(x,&mut cache));


}



<commit_msg>fix formatting and spacing<commit_after>//Implements http://rosettacode.org/wiki/9_billion_names_of_God_the_integer

extern crate num;

use num::bigint::BigUint;
use std::from_str::FromStr;
use std::string::String;
use std::cmp::min;

fn cumu<'a>(num: uint, cache: &'a mut Vec<Vec<BigUint>>) -> &'a Vec<BigUint> {
    let len = cache.len();
    for l in range(len, num+1) {
	let initial_value:BigUint = FromStr::from_str("0").unwrap();
	let mut r: Vec<BigUint> = vec!(initial_value);

	for x in range(1, l+1) {
	    let y = r.get(x -1).clone();
	    let z = cache.get(l-x).get(min(x, l-x)).clone();
	    let w = y+z;

	    r.push(w)
	}
	cache.push(r);
    }
    cache.get(num)
}

// Returns a line
fn row(num: uint,  cache: &mut Vec<Vec<BigUint>>) -> String {
    let r = cumu(num,cache);
    let mut returned_string = String::new();
    for i in range(0,num) {
	let i = *r.get(i+1) - *r.get (i);
	let z = i.to_str();
	let y = z.as_slice();
	returned_string.push_str(y);
	returned_string.push_str(", ");
    }
    returned_string
}

#[cfg(not(test))]
fn main() {
    let mut cache: Vec<Vec<BigUint>> = Vec::new();
    let initial_value:BigUint = FromStr::from_str("1").unwrap();
    let initial_vector : Vec<BigUint> = vec!(initial_value);
    cache.push(initial_vector);

    println!("rows");
    for n in range(1, 11) {
	let x = n as uint;
	println!("{}: {}", n, row(x,&mut cache));
    }

    println!("sums");

    let x: Vec<uint> = vec!(23, 123, 1234, 12345);
    for y in x.iter() {
	let z = cumu(*y,&mut cache);
	let w = z.last();
	println!("{}: {}", y, w.unwrap());
    }
}

#[test]
fn test_cumu() {
    let mut cache: Vec<Vec<BigUint>> = Vec::new();

    let initial_value:BigUint = FromStr::from_str("1").unwrap();

    let initial_vector : Vec<BigUint> = vec!(initial_value);
    cache.push(initial_vector);


    let a: Vec<uint> = vec!(23, 123, 1234);
    let b: Vec<BigUint> = vec!(
        FromStr::from_str("1255").unwrap(),
        FromStr::from_str("2552338241").unwrap(),
        FromStr::from_str("156978797223733228787865722354959930").unwrap());

    let mut n=0;
    for y in a.iter() {
	let z = cumu(*y,&mut cache);
	let w = z.last().unwrap();
	assert!(w == b.get(n));
	n= n+1;
    }
}


#[test]
fn test_row() {

    let mut cache: Vec<Vec<BigUint>> = Vec::new();

    let initial_value:BigUint = FromStr::from_str("1").unwrap();

    let initial_vector : Vec<BigUint> = vec!(initial_value);
    cache.push(initial_vector);

    let a: String = FromStr::from_str("1, 2, 1, 1, ").unwrap();

    let x = 4;
    assert!(a == row(x,&mut cache));


}
{'fraction_non_alphanumeric': 0.19494584837545126, 'fraction_numerical': 0.035721071632148965, 'mean_word_length': 3.1448818897637794, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546000', 'n_tokens_mistral': 2279, 'n_tokens_neox': 2058, 'n_words': 446}