- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
function* foo() {
let i = 1;
while (i < 10)
yield ++i;
}
function main() {
for (const o of foo()) {
print(o);
}
print("done.");
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
function* foo() {
let i = 1;
while (i < 10)
yield ++i;
}
function main() {
for (const o of foo()) {
print(o);
}
print("done.");
}
возрадуйтесь браться и сестры .. я вам благую весть принес... наконец-то я доделал это ..говно.. и "елдаки" теперь работают нормально.
0
let glb1 = 0;
function doubleIt(f: (x: number) => number) {
return f(1) - f(2);
}
function testLambdas() {
let x = doubleIt(k => k * 108);
assert(x == -108, "l0");
}
function main() {
testLambdas();
print("done.");
}
я вам еще принес новых фич.
0
А куда пропал инканус?
0
void main()
{
unsigned char c=0;
for (int c = 0;c < 256; c++) {
cout << "the value of '" << c << "' is: " << int(c) << '\n';
}
}
Ой, а чойта оно повесилося и пикает?
0
// These are equivalent:
fn`some string here`;
fn(['some string here']);
Джаваскриптеры переизобрели руби (ладно-ладно, скрестили с FormattableString из шарпа)
https://styled-components.com/docs/advanced#tagged-template-literals
0
// https://github.com/google/ruy/blob/2887692065c38ef6617f423feafc6b69dd0a0681/ruy/pack_avx2_fma.cc#L66
inline void Pack8bitColMajorForAvx2Packer(
const std::int8_t* src_ptr, std::int8_t input_xor,
const std::int8_t* zerobuf, int src_stride, int remaining_src_cols,
int src_rows, std::int8_t* packed_ptr, std::int32_t* sums_ptr,
std::int8_t* trailing_buf) {
using Layout = PackImpl8bitAvx2::Layout;
RUY_DCHECK_EQ(Layout::kCols, 8);
RUY_DCHECK_EQ(Layout::kRows, 4);
// Each Layout::Rows is 4 contiguous input, contiguous packed elements.
// We process 8 of these chunks at a time, padding short input chunks.
constexpr int kNumRowChunks = 8;
constexpr int kNumChunkedSrcRows = kNumRowChunks * Layout::kRows;
const std::int8_t* src_ptr0 = src_ptr;
const std::int8_t* src_ptr1 = src_ptr0 + src_stride;
const std::int8_t* src_ptr2 = src_ptr1 + src_stride;
const std::int8_t* src_ptr3 = src_ptr2 + src_stride;
const std::int8_t* src_ptr4 = src_ptr3 + src_stride;
const std::int8_t* src_ptr5 = src_ptr4 + src_stride;
const std::int8_t* src_ptr6 = src_ptr5 + src_stride;
const std::int8_t* src_ptr7 = src_ptr6 + src_stride;
std::int64_t src_inc0 = kNumChunkedSrcRows;
std::int64_t src_inc1 = kNumChunkedSrcRows;
std::int64_t src_inc2 = kNumChunkedSrcRows;
std::int64_t src_inc3 = kNumChunkedSrcRows;
std::int64_t src_inc4 = kNumChunkedSrcRows;
std::int64_t src_inc5 = kNumChunkedSrcRows;
std::int64_t src_inc6 = kNumChunkedSrcRows;
std::int64_t src_inc7 = kNumChunkedSrcRows;
// Handle cases where source does not have Layout::kCols (8) columns.
if (remaining_src_cols < 8) {
if (remaining_src_cols <= 0) {
src_ptr0 = zerobuf;
src_inc0 = 0;
}
if (remaining_src_cols <= 1) {
src_ptr1 = zerobuf;
src_inc1 = 0;
}
if (remaining_src_cols <= 2) {
src_ptr2 = zerobuf;
src_inc2 = 0;
}
if (remaining_src_cols <= 3) {
src_ptr3 = zerobuf;
src_inc3 = 0;
}
if (remaining_src_cols <= 4) {
src_ptr4 = zerobuf;
src_inc4 = 0;
}
if (remaining_src_cols <= 5) {
src_ptr5 = zerobuf;
src_inc5 = 0;
}
if (remaining_src_cols <= 6) {
src_ptr6 = zerobuf;
src_inc6 = 0;
}
src_ptr7 = zerobuf;
src_inc7 = 0;
}
const std::int8_t zero_point = zerobuf[0];
if (sums_ptr) {
// i: Layout::kCols.
for (int i = 0; i < 8; ++i) {
sums_ptr[i] = 0;
}
}
std::int32_t sums_adjustment = 0;
const __m256i ones_16bit = _mm256_set1_epi16(1);
__m256i sums_4x2_32bit_lo = _mm256_set1_epi32(0);
__m256i sums_4x2_32bit_hi = _mm256_set1_epi32(0);
// The overall packing effectively pads the source rows to
// (src_rows + 63) & ~63. The iteration over k may skip when m=1, and then we
// only pack for (src_rows + 31) & ~31. When there is an incomplete
// destination block, this is stored into trailing_buf instead of packed_ptr.
for (int k = 0; k < src_rows; k += kNumChunkedSrcRows) {
// Available source rows.
// If this is less than 0 (for m=1), we skip, having filled trailing
// buffer for m=0. Also, if source rows is zero on m=1, then we filled
// exactly to the end of the column in the packed buffer.
const int available_src_rows = src_rows - k;
// Effectively,
// available rows = std::max(0, std::min(8, src_rows - k));
// treat each case separately.
if (available_src_rows >= kNumChunkedSrcRows) {
if (sums_ptr) {
__m256i t0, t1, t2, t3, t4, t5, t6, t7;
__m256i r0, r1, r2, r3, r4, r5, r6, r7;
const __m256i input_xor_v = _mm256_set1_epi8(input_xor);
t0 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr0));
t4 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr4));
t1 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr1));
Интересно, они это вручную всё писали, или какой-то хуйней генерировали?
+1
Я вот смотрю на Ричарда Столлмана... Вижу, как он всю жизнь рвёт на себе жопчик за халявное ПО...
И думаю: а что сделал ОН? Он написал "Photoshop"? Создал "Windows"? Разработал хоть что-то?
Знает ли он, что такое многочасовой, многодневный, многомесячный, а иногда и многолетний труд разработки?
Всё его достижение - это ТЕКСТ лицензии "GNU". Всё.
В чём смысл Ричарда Столлмана?
И, кстати, нахуй вообще нужны лицензии на халявное ПО?
+2
/* https://habr.com/ru/company/piter/blog/491996/
Пусть в Python такая штука и называется генератором, в языке C++ она
называлась бы корутиной. Пример взят с этого сайта: https://masnun.com/2015/11/13/python-generators-coroutines-native-coroutines-and-async-await.html
def generate_nums():
num = 0
while True:
yield num
num = num + 1
nums = generate_nums()
for x in nums:
print(x)
if x > 9:
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#define START 0
#define YIELD 1
typedef struct
{
uint8_t jmpto;
int num;
} coroutine_state;
int generate_nums(coroutine_state *state)
{
switch(state->jmpto)
{
case START: break;
case YIELD: goto yield;
}
while (true)
{
state->jmpto = YIELD; return state->num; yield: // какая питушня
state->num = state->num + 1;
}
}
int main(void)
{
int x;
coroutine_state st = {START, 0};
while(true)
{
x = generate_nums(&st);
printf("%d\n", x);
if (x > 9)
{
break;
}
}
return EXIT_SUCCESS;
}
Попробовал переписать эту ко-ко-корутину c питуха на Си - получилась какая-то херня нечитаемая. что еще раз доказывает, что корутины нахуй не нужны
К тому же в крестопарашном говне они требуют хип, а это нахуй не нужно на самом-то деле.
0
#include <stdlib.h>
void main()
{
a: ; malloc(1); goto a;
}
0
>>> def f(positional_only, /, regular, *varargs, kw_only, **kw_varargs):
print(positional_only, regular, varargs, kw_only, kw_varargs)
f(1, 2, 3, 4, 5, kw_only='kw_only', kw_var1='var1', kw_var2='var2')
# 1 2 (3, 4, 5) kw_only {'kw_var1': 'var1', 'kw_var2': 'var2'}
Блядь, как всё сложно…
https://www.python.org/dev/peps/pep-0570/