- 1
- 2
- 3
[]() { std::function<int(int)> foo =
[&foo](int k) { return k == 1 ? 1 : k + foo(k-1); };
return foo; }()(3)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+50
[]() { std::function<int(int)> foo =
[&foo](int k) { return k == 1 ? 1 : k + foo(k-1); };
return foo; }()(3)
Как написать рекурсивную лямбдру на крестах?
+132
rc = system
(
"test "
"`ls -1 $WORKDIR/somedir/ | wc -l` = 1"
" -a "
"`ls -1 $WORKDIR/somedir/*/somefiles.* | wc -l` = 1"
);
ASSERTM( rc != -1, "check for number of <dirs>" );
ASSERTM( rc == 0, "number of <some> files is greater than 1" );
по мотивам http://govnokod.ru/14374
из теста. да, можно было на С написать. да, мне было просто лень.
−95
[dic setObject:[NSNumber numberWithInt:TWITTER] forKey:@"source"];
Как можно простые вещи сделать сложными.
Эквивалентно: dict[@"source"] = @(TWITTER);
+132
procedure tmythread.execute;
var i:integer;
begin
bot.postnumber:=topicno; bot.proxy:='220.181.89.72:8000'; bot.login:=copy(vote,1,pos(':',vote)-1); bot.password:=copy(vote,pos(':',vote)+1,length(vote));
case actiontype of
ac_dec:
begin
bot.comment:=false;
try
bot.connect;
except
terminate;
end;
bot.VoteAgainst;
end;
ac_inc:
begin
bot.comment:=false;
try
bot.connect;
except
terminate;
end;
bot.VoteOn;
end;
ac_deccurrent:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
bot.VoteAgainst;
end;
ac_inccurrent:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
bot.VoteOn;
end;
ac_decall:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
for i:=0 to clist.Count-1 do
begin
bot.postnumber:=clist[i];
bot.VoteAgainst;
end;
end;
ac_incall:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
for i:=0 to clist.Count-1 do
begin
bot.postnumber:=clist[i];
bot.VoteOn;
end;
end;
ac_decallc:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
for i:=0 to clist.Count-1 do
begin
bot.postnumber:=clist[i];
bot.VoteAgainst;
end;
end;
ac_incallc:
begin
bot.comment:=true;
try
bot.connect;
except
terminate;
end;
for i:=0 to clist.Count-1 do
begin
bot.postnumber:=clist[i];
bot.VoteOn;
end; end; end; end;
Код Того-На-Кого-Не-Будем-Показывать-Пальцем
ВНИМАНИЕ! Некоторые строки были объединены дабы вместиться в пост
+20
Matrix matrix ( h, w );
delete &h, &w;
for ( int i = 0; i < h; i++ )
{
for ( int j = 0; j < w; j++ )
{
cout << "Введите элемент [" << i << ", " << j << "]: ";
cin >> matrix[i][j];
}
}
Найди ошибку...
−88
while ii<kol:
a = random.random()
z = str(a)
L = len(z)
i = 0
while i <L:
if z[i]=="0":
s0 +=1
elif z[i]=="1":
s1 +=1
elif z[i]=="2":
s2 +=1
elif z[i]=="3":
s3 +=1
elif z[i]=="4":
s4 +=1
elif z[i]=="5":
s5 +=1
elif z[i]=="6":
s6 +=1
elif z[i]=="7":
s7 +=1
elif z[i]=="8":
s8 +=1
elif z[i]=="9":
s9 +=1
i+=1
ii +=1
массивы для питухов
http://habrahabr.ru/post/183022/
+157
#include <iostream>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/key_type.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/string.hpp>
#include <boost/mpl/for_each.hpp>
using namespace boost;
typedef mpl::map<
mpl::pair<mpl::string<'H','e','l','l','o'>, mpl::int_<0>>,
mpl::pair<mpl::string<',',' '>, mpl::int_<1>>,
mpl::pair<mpl::string<'W','o','r','l','d','!'>, mpl::int_<2>>
> map;
struct do_some {
template<typename T>
void operator()(T) const {
std::cout << mpl::c_str<T>::value;
}
};
int main() {
mpl::for_each<
map,
typename mpl::lambda<
mpl::key_type<map, mpl::_1>
>
>(do_some());
}
еще один хеловорд.
+152
class ListEl{
public:
int val;
ListEl *head;
ListEl *tail;
}
class MyList{
public:
ListEl *head, *tail;
0
#include <stdio.h>
struct{int a; float b;} test()
{
return (typeof(test())){1337, 666.666};
}
int main()
{
auto a = test();
printf("%d %f\n", a.a, a.b);
return 0;
}
В стандарт C23 добавили auto и теперь можно писать такую хуйню. В "Clang" работает: https://godbolt.org/z/GG3addqPb
0
Объясните, зачем нужен docker-compose
Есть же Dockerfile, туда можно поставить всё, что нужно сразу, а не плодить кучу контейнеров, которые нужно связать