juan_gandhi: (Default)
Принцип дизайна: non sunt entia multiplicanda sine necessitatem.

Короче, CPS рулит; сейчас вмажу моноид, https://docs.rs/functional/0.0.5/functional/trait.Monoid.html, чтобы вообще не дублировать ничего и не писать циклы, где не надо (а просто fold). 

Подробности:

1. Не нужно дублировать данные. Если у тебя есть данные, присобачь к ним какой-нибудь метод, чтобы применять твою функцию и устраивать какой-нибудь fold, возможно, с мапингом и фильтрацией.

2. Поэтому, вместо того, чтобы передавать коллекцию в функцию, передавай функцию в коллекцию.

3. Для фолда моноид самое то (а иначе откуда фолд?) В моноиде есть "начальное значение" и ассоциативная бинарная операция. Чтобы проехаться по коллекции, это все что надо - начали с "начального значения", и все данные переварили, получив одно значение. Левый фолд или правый - для моноида роли не играет, можно и распараллелить.

rust cache

Dec. 24th, 2019 08:20 am
juan_gandhi: (Default)
Понадобился мне кеш в задаче. Ну конечно я и сам этого кеша понаписал дохрена, но что б не погуглить. Нагуглил. Это макро! Код ты вообще не меняешь, только заворачиваешь в вызов макро, с указанием, где у тебя кеш хранится. И все. Лайк!

#[macro_use] extern crate cached;

/// Defines a function named `fib` that uses a cache named `FIB`
cached!{
    FIB;
    fn fib(n: u64) -> u64 = {
        if n == 0 || n == 1 { return n }
        fib(n-1) + fib(n-2)
    }
}
juan_gandhi: (Default)
Its performance is amazing. The sum of the first 2m primes (have to calculate the primes first): 32 seconds (optimized compilation).

Why does performance even bother me? I don't know, just as a surprise.

Shit, found a bug. In short, 160ms in Rust (the naive algorithm), 700ms in Scala (same algorithm).
juan_gandhi: (Default)
the dark arts of Rust 

How to fuck (up) Rust and shoot in your leg professionally, as if it were C++.
juan_gandhi: (Default)
It turns out, if you build rust code with full optimization, it will be e.g. 12 times faster (my example, with Mandelbrot set, 10" vs 2'). 
juan_gandhi: (Default)


src: https://github.com/vpatryshev/rustex/tree/master/mandelbrot

Will have to sanitize and civilize the code, of course.

It was the first time I generated Mandelbrot, which is weird, eh.
juan_gandhi: (Default)
enum Option {
    Some(T),
    None,
}
juan_gandhi: (Default)
Rust allows this, but Scala does not

fn main() {
let c = 'z';
let z = 'ℤ';
let heart_eyed_cat = '😻';
}


juan_gandhi: (Default)
> rustc -version
error: Unrecognized option: 'e' 
juan_gandhi: (Default)
http://dawn.cs.stanford.edu/ 

"DAWN is a five-year research project to democratize AI by making it dramatically easier to build AI-powered applications.

Our past research–from Spark to MesosDeepDive, and HogWild!–already powers major functionality all over Silicon Valley–and the world. Between fighting against human traffickingassisting in cancer diagnosis and performing high-throughput genome sequencing, we’ve invested heavily in tools for AI and data product development.

The next step is to make these tools more efficient and more accessible, from training set creation and model design to monitoring, efficient execution, and hardware-efficient implementation. This technology holds the power to change science and society—and we’re creating this change with partners throughout campus and beyond."

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
222324252627 28
29 30     

Syndicate

RSS Atom

Most Popular Tags

Active Entries

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 10th, 2025 07:44 pm
Powered by Dreamwidth Studios
OSZAR »