- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
function main() {
let user = {
firstName: "John",
sayHi() {
print(`Hello, ${this.firstName}!`);
},
};
user.sayHi();
print("done.");
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
function main() {
let user = {
firstName: "John",
sayHi() {
print(`Hello, ${this.firstName}!`);
},
};
user.sayHi();
print("done.");
}
как тебе такое Илон Маск?
+4
#!/bin/sh
count_roosters(){
echo $1: `grep -c -P $1 gk_users.csv`
}
for rooster_name in nemyx_HoMep g0_14 Antibagor _daSome spooler ebebebeb assosin pdro alisher 14sun bot.number ,rss
do
count_roosters $rooster_name
done
Выхлоп:
nemyx_HoMep: 40817
g0_14: 1434
Antibagor: 1404
_daSome: 1001
spooler: 1000
ebebebeb: 678
assosin: 490
pdro: 300
alisher: 281
14sun: 250
bot.number: 131
,rss: 127
−1
val cityEq: (City) -> (Customer) -> Boolean = { city -> { it.city == city } }
Какой Kotlin ^_^^_^^_^
+1
Ltac destruct_mint_ H :=
match type of H with
(MInt_ _ ?z ?t) =>
lazymatch goal with
|- ?GOAL =>
refine (match H in (MInt_ _ z0 t0) return (z = z0 -> t = t0 -> GOAL) with
| mint_nil _ =>
fun Heq_z Heq_tt_ =>
ltac:(destruct_mint_common Heq_tt_ Heq_z H)
| mint_cons _ te rest l r t H =>
fun Heq_z Heq_tt_ =>
ltac:(destruct_mint_common Heq_tt_ Heq_z H)
| mint_cons_l _ te rest l r z t Hz H =>
fun Heq_z Heq_tt_ =>
ltac:(destruct_mint_common Heq_tt_ Heq_z H)
| mint_cons_r _ te te' rest l r z t Hz Hcomm H =>
fun Heq_z Heq_tt_ =>
ltac:(destruct_mint_common Heq_tt_ Heq_z H)
end (eq_refl z) (eq_refl t))
end
end.
Наебавшись с inversion в механизированным доказательстве, закрыл я очи.
+1
function main() {
let { aa, bb } = { aa: 10, bb: 20 };
print(aa + bb);
let {
aa,
bb: { q, r },
} = { aa: 10, bb: { q: 1, r: 2 } };
assert(aa == 10, "{}");
assert(q == 1, "{}");
assert(r == 2, "{}");
let { x, y } = new ObjF(1, "foo");
assert(x == 1, "{}");
assert(y == "foo", "{}");
print("done.");
}
Добрый вечер дорогие неопределившиеся... или заблудшие... вот я тут вам новую фичу притарабанил .. называет деконстракт :)
0
Пиздец-оффтоп #26
#1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
#2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
#3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
#4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
#5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
#5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
#6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
#7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
#8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
#9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
#10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
#11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
#12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
#13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
#14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
#15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
#16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
#22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
#23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
#24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
#25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
0
IT Оффтоп #105
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
#81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
#82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
#83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
#97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
#98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
#99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
#100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
#101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
#102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
#103: https://govnokod.ru/27526 https://govnokod.xyz/_27526
#104: https://govnokod.ru/27534 https://govnokod.xyz/_27534
0
namespace Ifaces {
interface IFoo {
foo(): number;
bar(x: number): string;
twoArg(x: number, y: number): number;
baz: string;
}
class A implements IFoo {
constructor() {
this.baz = "Q" + "A";
}
foo(): number {
return 12;
}
bar(v: number) {
return v.toString();
}
twoArg(x: number, y: number) {
return x;
}
baz: string;
}
class B extends A {
foo(): number {
return 13;
}
}
function foo(f: IFoo) {
return "" + f.foo() + f.baz + f.bar(42);
}
export function run() {
print("Ifaces.run");
let a = new A();
assert("" + foo(a) + "X" == "12.QA42.X");
assert((a as IFoo).twoArg(1, 2) == 1, "t");
a = new B();
assert("" + foo(a) + "X" == "13.QA42.X", "b");
let q = a as IFoo;
q.baz = "Z";
assert("" + foo(q) + "X" == "13.Z42.X", "x");
print("Ifaces.runDONE");
}
}
function main() {
Ifaces.run();
print("done.");
}
хотел оставить вас в покое. но не смог. Ловите - fields в интерфейсах
0
class Bagor:
r = []
def __init__(self, val):
self.r.append(val)
def get(self):
return self.r[0]
kakoi = Bagor(1)
bagor = Bagor(2)
print([kakoi.get(), bagor.get()])
https://ideone.com/K7tADi
0
/* https://fstarlang.github.io/lowstar/html/Introduction.html#the-essence-of-low
Consider the following very simple program:
module Intro
module P = LowStar.Printf
module C = LowStar.Comment
module B = LowStar.Buffer
open FStar.HyperStack.ST
open LowStar.BufferOps
let main (): St Int32.t =
push_frame ();
let b: B.buffer UInt32.t = B.alloca 0ul 8ul in
b.(0ul) <- 255ul;
C.comment "Calls to printf are desugared via meta-programming";
let s = "from Low*!" in
P.(printf "Hello from %s\nbuffer contents: %xul\n"
s 8ul b done);
pop_frame ();
0l
....
Once compiled by the KreMLin compiler, we obtain the following C code:
*/
int32_t main()
{
uint32_t b[8U] = { 0U };
b[0U] = (uint32_t)255U;
/* Calls to printf are desugared via meta-programming */
Prims_string s = "from Low*!";
LowStar_Printf_print_string("Hello from ");
LowStar_Printf_print_string(s);
LowStar_Printf_print_string("\nbuffer contents: ");
LowStar_Printf_print_lmbuffer_u32((uint32_t)8U, (uint32_t *)b);
LowStar_Printf_print_string("\n");
return (int32_t)0;
}
Какая-то компилируемая в сишку хренотень с завтипами, разрабатываемая в Microsoft Research