Месяц: Апрель 2013

C#: Проверить на null в монаде

pub­lic sta­t­ic TRe­sult With<tinput tre­sult=””> (this TIn­put o, Func<tinput tre­sult=””> eval­u­a­tor) where TRe­sult : class where TIn­put : class { return (o == null) ? return null : evaluator(o); } Использовать так: string post­Code = this.With(x => per­son) .With(x => x.Address) .With(x => x.PostCode);

Python: размер по числу байт

def get_bytes_size_units(num): “”” Get file size with prop­er units of mea­sure­ment. “”” range_titles = [“b”, “kB”, “Mb”, “Gb”, “Tb”, “PB”, “EB”, “ZP”, “YB”] range_titles_len = len(range_titles) i = 1 prev_value = 0 new_value = num is_iteration = True while is_iteration: prev_value = new_value new_value = num » ((i « 1) * 5) i += 1…

Прочитать статью целиком