[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 454 KB, 1046x1500, x14.jpg [View same] [iqdb] [saucenao] [google] [report]
67828122 No.67828122 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous thread: >>67820193

>> No.67828145
File: 715 KB, 640x640, LIGHT_WEIGHT.webm [View same] [iqdb] [saucenao] [google] [report]

I have placed a curse on this thread

>> No.67828146
File: 44 KB, 636x616, 1474325315193.jpg [View same] [iqdb] [saucenao] [google] [report]

Employed Haskell programmer reporting in

>> No.67828163

What do you do? Why Haskell?

>> No.67828186

Daily reminder that wireless devices cause brain damage, endocrine dysfunction, DNA damage, and irreversible infertility.

>> No.67828208
File: 33 KB, 696x943, quak.png [View same] [iqdb] [saucenao] [google] [report]

Light themes are the best, but not too light!

>> No.67828251

First for vim is shit

>> No.67828375

Daily reminder /dpt/ causes irreversible death

>> No.67828422

Let us honor the memory of all fallen /dpt/-comrades we've lost along the way.

>> No.67828465

This github repo did 10 implementations of recursive fibonacci and has 150+ stars now.
How many stars has your most ambitious project gotten?

>> No.67828481

>github upvotes
who cares

>> No.67828742

Patrician taste

>> No.67828751
File: 127 KB, 700x2528, tu2.png [View same] [iqdb] [saucenao] [google] [report]

reminds me this. (pic)

>> No.67828790

Shamelessly bumping my question in the previous thread:

>> No.67828812

Any implementation other than the hackathon (jump table) is unacceptable.

Large company makes me shudder and feel all twisted up inside.

>> No.67828907

Last time I posted, I was studying for a Google phone interview.

Now, I'm getting flown out to a Google onsite interview. Studying for that rn

>> No.67829026

>current year
>still not learning how to solve fibonacci using a fibonacci matrix

>> No.67829110

Rate my C program, /g/.

%:include <stdio.h>
int main(argc,argv)
int argc;char*argv[];<%
int array[012:>;
for (int i=0;i<sizeof(array)/sizeof(array<:0]);++i){
i[array] = i;
printf("%s: %d\n", 0[argv], i[array]);
return 0;

>> No.67829167

not valid

>> No.67829180

What isn't valid?

>> No.67829192

I'm working at a startup and I've noticed my code slowly transition from startup to large company mode. The math PhD one makes no sense, why would they prefer function notation to binary? t. Not quite math PhD yet.

>> No.67829223


>> No.67829235

None of these scale very well for large n.

>> No.67829251

It's absolutely valid. i[a] and a both work in C.

>> No.67829254

That's valid C, n00b.

i[array] translates to *(i + array)
array translates to *(array + i)

As addition is commutative, those two are equivalent.

>> No.67829259

desu it is wrong to write things to be scalable and generic when they only have one limited use; look at the comment of the hackathon code

>> No.67829292

>gcc doesn't support destructors for classes that are thread_local in c++11

>> No.67829293

It can be written scalable and generic with less code than any of those examples.

public int getFibonacciNumber(int n) {
int[] fib = {1, 1, 2};
for (int i = 3; i < n; ++i) {
fib[i % 3] = fib[(i - 1) % 3] + fib[(i - 2) % 3];
return fib[n % 3];

>> No.67829306

It needed neither of those qualities, and now the
code looks worse.

>> No.67829323

>the code looks worse.
If you think any of those except the very first one looks "good", then I hope I'll never encounter your code in my life.

>> No.67829335

Also, where the fuck is it stated that none of those are needed?

>> No.67829385

I never claimed that. Don't make such baseless assumptions. Also the code you wrote is a totally niggerlicious way of doing fibonacci.

Look at the comment in the hackathon piece, it implies it doesn't need them given the context it is used it.

>> No.67829398

i have 3-4 ok projects of medium size i can upload on github but i'm afraid they might get stolen

>> No.67829413

>Also the code you wrote is a totally niggerlicious way of doing fibonacci.
Enjoy your stack overflow

>Look at the comment in the hackathon piece,
What kind of retard answer is that? Look at the comment in the enterprise edition.

You're just insanely butthurt you couldn't come up with a non-recursive method of calculating Fibonacci numbers, lol.

>> No.67829439

Just use the math one without the retarded redefining of basic operations, it's F(n) = round(phi^n / sqrt(5)), that's it.

>> No.67829456

what's the reason given?

>> No.67829459

All right. I have gotten tired of all the ridiculously complicated build systems.

A program should be able to build as gcc main.c deps/*.c -Ideps/.
To this end:
Projects which only produce one binary should name the .c source file containing the main() function either main.c or {name of binary}.c
Projects which produce multiple binaries should have one .c source file named after each binary in the root folder, which in turn include the needed headers.
Libraries must work both by #include and linking, unless they are header-only libraries, in which case the latter is optional.
This means that libraries must avoid defining the same identifier across multiple source files. Such identifiers should instead be put in a common header with an include guard. If this is not possible, the identifiers should be made locally scoped by a prelude which redefines them.
#define id1 file_id2
#define id2 file_id2
#define id3 file_id3
#undef id1
#undef id2
#undef if3

All source code and header files must have include guards, with the exception of files that define a main() function, or which are intended to be included multiple times.
If the project contains a makefile, it should not require GNU make, nor should it be required to compile the project without taking more than a cursory look at the structure.

Did I miss anything?

>> No.67829461

math phd would be using matrices not the one with the golden ratio, because that one is actually slow

>> No.67829487 [DELETED] 

The funny thing is that it's not even correct (which I guess is part of the joke?)

It should be: F(n) = (phi - (-phi) * n) / sqrt(5)

>> No.67829488

>Enjoy your stack overflow
>You're just insanely butthurt you couldn't come up with a non-recursive method of calculating Fibonacci numbers, lol.

lmao, No I am not. This proves you wrong:
int fibonacci(int n)
int foo = 0;
int bar = 1;
int tmp;

while (n--) {
foo += bar;
tmp = foo;
foo = bar;
bar = tmp;
return foo;

It is a shitton better than your nigger solution½

>> No.67829498

#pragma once or good old header guard?

>> No.67829500

Your implementation of fibonacci(n) will return 0 for n=0, which is wrong retard.

>> No.67829515

By definition, the first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s. For n = 0 it is clearly 0: F(0) = (1 - 1) / sqrt(5) = 0.Sep 20, 2009
In the Fibonacci sequence, is fib(0) 0 or 1 ? - Stack Overflow

>> No.67829521

#pragma once for your own stuff, old header guard if you're writing a library.

>> No.67829525

>no one here
Employed computational scientist, AMA.

>> No.67829539

>while (n--)
Pass in -1 to your function, and it now iterates until it wraps (undefined behaviour for signed ints).

Good job at making a "generic" solution....

>> No.67829540

No, both are correct.
(pow(phi, n)-pow((1-sqrt(5))/2, n))/sqrt(5) is equivalent to floor(pow(phi, n)/sqrt(5)+0.5f).

>> No.67829552

Yeah, I realized that after posting. Thanks for correcting me anon.

>> No.67829553

hi have you considered quitting rather than continuing to endanger the human race

>> No.67829564

Not really. The only other field that may interest me at this point would be HFT.

>> No.67829575

Simula faggot detected.

>> No.67829602

You should ensure valid arguments before calling the function.
>Good job at making a "generic" solution....
Never claimed to have done that. For that you would also need something like the java BigInteger

>> No.67829607

Pragma once can be trivially converted to header guard with a two line shell script.

>> No.67829618

A negative integer is a valid argument to something that expects a signed integer.

>> No.67829636

I've been found

>> No.67829643

I meant in the same sense that it is your job to ensure that you are not dividing by zero when dividing.

>> No.67829644

Yes, you have. It's stupid to post RL projects online, especially when you're boasting about your e-peen.

>> No.67829652

What about using binomial expansion and (1/2 + sqrt(5)/2)^n?

>> No.67829697

Next you're going to say you were merely pretending

>> No.67829734

Why would I say I'm merely pretending? I'm not the one boasting about working on FEniCS (which is a pretty done project by now tbqh).

>> No.67829754

#include <cstdio>

template <typename T>
class sample {


T member;

static thread_local class sample<int> mysample;

int main()
mysample.member = 10;
return 0;

/usr/bin/ld: /tmp/cctQLO7o.o: in function `__tls_init':
sample.cpp:(.text+0x5b): undefined reference to `sample<int>::~sample()'
collect2: error: ld returned 1 exit status

clang++ just werx

>> No.67829778

Oh, it (gcc) needs -pthread to even use tls
That's why

>> No.67829817

>I'm not the one boasting about working on FEniCS
Where did I do that you mongoloid? Please spend more time focusing on your mouth-breathing and less on making retarded comments on 4chan.

>> No.67829833


The fact that you're getting mad and upset about this proves to me that I found you out.

>> No.67829857

You are retarded, a negative number is a valid argument since the general sequence is ...,-8,5,-3,2,-1,1,0,1,1,2,3,5,8,...

>> No.67829957

So in that case it should actually be:
int fibonacci(int n)
int foo = 0;
int bar = 1;
int tmp;

if (n < 0) {
int tmp = fibonacci(-n);
return (-n & 1) ? tmp : -tmp;

while (n--) {
foo += bar;
tmp = foo;
foo = bar;
bar = tmp;
return foo;

>> No.67829982

>(-n & 1)
Implementation specific behaviour. Into the trash it goes.

>> No.67830003

Where am I fucking up?
def MArray( i, j ):
#Produce an Array of size i, and dimensions j
#>>>[ ['1','2','3'], ['4','5','6'] ]
arr = [None] * j
arr2 = [None] * i

for c in range(len(arr2)):
for k in range(len(arr)):
arr[k] = input('enter your data')

arr2[c] = arr

return arr2

>> No.67830012 [DELETED] 

#include <stdio.h>

int main()
double a,b,c,a_2,b_2,ac_4,b2_ac4;
printf("Quadratic equation calc\n"
"Enter values for a b c\n");
scanf("%lf %lf %lf",&a,&b,&c);
printf("Displaying your values a=%lf b=%lf c=%lf\n",a,b,c);
printf("x1= -b+sqrt((b^2)-4ac)\n"
" ----------------\n"
" 2a");
printf("x2= -b-sqrt((b^2)-4ac)\n"
" ----------------\n"
" 2a");
printf("x1= -(%lf)+sqrt((%lf^2)-4*%lf*%lf)\n"
" -------------------------------------------------\n"
" 2*%lf",b,b,a,c,a);
printf("x2= -(%lf)-sqrt((%lf^2)-4*%lf*%lf)\n"
" -------------------------------------------------\n"
" 2*%lf",b,b,a,c,a);
printf("x1= -(%lf)+sqrt(%lf-(%lf))\n"
" --------------------------------------\n"
" %lf",b,b_2,ac_4,a_2);
printf("x2= -(%lf)-sqrt(%lf-(%lf))\n"
" --------------------------------------\n"
" %lf",b,b_2,ac_4,a_2);
b2_ac4=b_2 - ac_4;
printf("x1= -(%lf)+sqrt(%lf)\n"
" --------------------------\n"
" %lf",b,b2_ac4,a_2);
printf("x2= -(%lf)-sqrt(%lf)\n"
" --------------------------\n"
" %lf",b,b2_ac4,a_2);

return 0;

>> No.67830017

On which platforms does it not work?

>> No.67830020


>> No.67830027

Platforms that uses one's complement.

>> No.67830086

yeah well you just keep using your imaginary system, while I program for real hardware.

>> No.67830088

Any good resources for learning machine learning and deep learning in depth? I mean the actual math and algorithm creation.

The results I keep coming across keep saying just use these AI libraries, rather than actually learning the underlying technology.

>> No.67830101

it's a meme technology, if you have a brain get into something useful that isnt a fad

>> No.67830105

Or, you could just write % 2 like a sane person, and let the compiler handle your silly microoptimisation.

>> No.67830110


>> No.67830118

Was meant for >>67830086

>> No.67830127

of what?

>> No.67830140

I looked a bit at it again and I think you're wrong.
-n comes before the bitmask.

>> No.67830152

Theme you dum dum

>> No.67830157

You're probably right, but still you should do >>67830105 imo

>> No.67830163

>trusting the (((compiler)))

>> No.67830177

what are they about

>> No.67830179

Premature (micro)optimisations are the root of all evil.
- The D.

>> No.67830184

It doesn't have a name.

background: #CFCFCF
text: #000000
comments: #9E0C0C
strings: #009456

>> No.67830187

please help I have no idea why it's only indexing the last element of my outer array.

>> No.67830195

you just making your js apps with electron

>> No.67830211

Because [None] * j doesn't do what you think it does.

Do this instead:
arr = []
arr2 = []

for c in range(i):
for k in range(j):
arr.append(input('enter your data'))


Lists are not arrays.

>> No.67830225

I'm serious though, if you ever examined the assembly from your compiler, you'd realise that it does this """optimisation""" for you.

There is no excuse for writing non-portable code unless you're dealing directly with hardware (which you're not in this case).

>> No.67830226

>not trusting the compiler
Until you tell me how ROB, load/store buffers, instruction retirement and cache synchronization work you really don't know more than a good optimizing compiler does. Don't forget about register renaming and data hazards.

>> No.67830240

>programming without trusting the compiler
Let me guess, you're one of those people who write your own string functions too, because the standard library can't be "trusted", am I right?

>> No.67830255

i've been out of the loop for a while
can you give me an update on rust

is it more popular now
is it still fast

>> No.67830268

Get a loads this (((compiler dev)))

>> No.67830273

It's a step up, but not quite what I want to do since it copies my inner array to each element in the outer array.

>> No.67830278

How do I use SDL2 to stream to an indexed texture with a custom palette?

Here's the problem. There doesn't seem to be any way to access the palette of an indexed texture. You can create one, by passing an indexed pixel mode to SDL_CreateTexture, but since you can only pass the flag for the pixel mode, not the entire pixel mode data structure, you can't specify a palette.

You can create a texture with an arbitrary palette by first creating a surface with that palette (since there are functions available to freely manipulate the palette of a surface) and then using SDL_CreateTextureFromSurface. However, SDL_CreateTextureFromSurface is documented as always allocating and returning a static texture. I need a streaming texture. There also do not seem to be any functions for creating a texture from an existing texture, except SDL_RenderCopy[Ex] with a texture as the render target -- which would defeat the purpose, as neither pixel mode nor streaming mode would not be preserved, so in order to create an indexed streaming texture to copy to, I'd be faced with the same problem as before.

Pls. All I want is to directly manipulate the pixels on my 8-bit emulator.

Current workaround is to store the texture as RGBA8888, have a separate 8-bit indexed pixel array in static memory as well as a palette for it, and manually convert every pixel from indexed 8-bit to RGBA8888 every frame. This works but it would be more efficient to just have the texture itself be indexed 8-bit with the palette I want.

>> No.67830280

Still ugly, compiler still exceeds the 32-bit address space when being linked, still pushed by loud, insufferable people who ride on Haskell's coattails.

>> No.67830281

You are right about light themes being patrician, bul low contrast increases eyestrain

>> No.67830282

This but unironically

>> No.67830299

That's still good contrast.

>> No.67830315

How do I get good haskell integration with emacs?
I'm trying to setup haskell-ide-engine but it's not working. I'm on archlinux btw

>> No.67830329

Just get hlint and ghcid, you don't really need anything else

>> No.67830351

>black on grey

>> No.67830360
File: 227 KB, 1582x2111, Screenshot_2018-09-29 regexp Go's regex is even slower than Python · Issue #26623 · golang go.png [View same] [iqdb] [saucenao] [google] [report]

Remember all the time I have been constantly bitching about Go - C FFI cost and no one gave a shit?

>> No.67830415

Yet still noone gives a shit

>> No.67830425

LOL I like how C# manages to come out as the bottom of the barrel Java's bitch every damn time

>> No.67830435

I'd have to know which of those are unicode aware before I give a shit.

>> No.67830436

You ain't seen nothing.

>> No.67830442
File: 143 KB, 500x855, 5C0348A0-6687-48E9-B3D0-214FEFC5F4DB.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67830460
File: 610 KB, 1291x3600, 1534935983694.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.67830474

>I don't understand why Go has to use cgo to call C code
Is he fucking stupid or something?

Anyway, Go's regexp package was designed to deal with common-ish pathological cases where PCRE would start blowing up and taking years to complete, but it hasn't been optimized.

>> No.67830475

> counting other people’s money
good going sanjeev

>> No.67830479
File: 510 KB, 782x1238, bakabaka.png [View same] [iqdb] [saucenao] [google] [report]

Isn't that just a shittier copy of this meme? I mean C# is literally Microsoft Java, so the meme doesn't even make sense. Pot calling the kettle black.

>> No.67830481
File: 58 KB, 1000x1000, 1535935817856.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67830500


>> No.67830509

Dumb question but this has always confused me.

What do double pointers mean in C++?

If I do
int **A= 103

For instance.
Wouldn't that indicate the address for *A?

I mean whatever content is fit in **A would be the address for *A right?

>> No.67830525

>startup can't even write Fibonacci right in the end
>math phd doesn't do exponentiation by squaring

You forgot to attach a frog picture, dumb frogposter.
Both use exponentiation so both can run in O(log(n)). The foremost reason it's stupid is because it uses doubles so it'll probably break down past F(70), while an int64 matrix holds up to F(92) and is guaranteed to give you the right answer for any value that doesn't overflow.

>> No.67830530

> tfw maining both C# and JS
I’ll be alright

>> No.67830531

real programmers use only three stars like int ***x;

>> No.67830538

>The foremost reason it's stupid is because it uses doubles so it'll probably break down past F(70)
yea it was something with the limitations of the hardware
it;s slower because you'd have to implement unlimited precision

been a while since i read algorithms, maybe i should brush up

>> No.67830539

pointer to pointer to something

address of address of value

int n = 123;
int *np = &n;
int **npp = &np;

printf("fuck my %d anuses\n", **npp);

basically the more indirection the more powerful your code is. there's no limit, you can only level up.

>> No.67830545

A pointer is a variable, and the value of that variable is a memory address. A pointer to an integer is therefore a variable that contains the address of an integer in memory.
int i = 3; // this statement reserves//allocates memory, and stores the value 3 in that memory
int* p = &i; // the value of p is the address of the memory location reserved/allocated by i.

A pointer-pointer to an integer would therefore be a variable that holds the address of a pointer to an integer.

int i = 3;
int* p = &i;
int** pp = &p;

>> No.67830549

It's a pointer to a pointer, just like it says on the tin.
>int **A= 103
is basically saying that the number at memory address 103 is a pointer to another address that actually has the int you want. This will of course segfault your app if you dereference it.

>> No.67830558

>This will of course segfault your app if you dereference it.
Depends on what's stored in address 103 and the permission of that memory segment.

>> No.67830559

you keep working on a single arr that you then save to arr2 at every index.
make a new arr=[None]*j in every iteration of your "c" loop

>> No.67830562

yep. its a pointer to a pointer.

int a = 5;
int *ap = &a;
int **app = &ap;
int p = *app; //val = &a
int val = **app; //val = 5

>> No.67830570
File: 33 KB, 600x569, Programming-Languages.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.67830573
File: 21 KB, 601x2411, 1537531127481.png [View same] [iqdb] [saucenao] [google] [report]

&1 feels far more natural to me anyway. But you shouldn't trust the compiler.

>> No.67830574

brb taking a poop

>> No.67830579

I’m employed lol.

>> No.67830580
File: 25 KB, 480x394, brainlet-autism.jpg [View same] [iqdb] [saucenao] [google] [report]

>But you shouldn't trust the compiler.

>> No.67830587

Compilers are pretty clever, but not too clever. They will not replace a bubble sort with quicksort for example.

>> No.67830614

Obviously, but that's why we're talking about microoptimisations (such as bitfiddling), and not macrooptimisations (such as algorithms and data structures).

>> No.67830644

>&1 feels far more natural to me
Not an argument.

>But you shouldn't trust the compiler.
Portability > premature microoptimisations.

>> No.67830657

where's haskell? shouldn't it be on top?

>> No.67830661

use isodd(x)
I don't care if you #define isodd(x) ((x)&1) or make an inline function or a fucking template factory builder concept, just make that code easily readable.

>> No.67830662

Haskell is so popular, it's literally off the charts.

>> No.67830673

>cleanly designed

>> No.67830682

>implying the average poo or joe can grasp haskell
if haskell were on top it'd be a shit language

>> No.67830688


>> No.67830695
File: 8 KB, 442x500, 1538068292820.jpg [View same] [iqdb] [saucenao] [google] [report]

>beautiful and cleanly designed language
>Microsoft Java 2.0

>> No.67830703

Based Rust though

>> No.67830735

That’s C++++ though, aka C#

>> No.67830751

Why do compilers often xor a register before storing a value into it? Is it not pointless?

>> No.67830781

why would i ver choose ugly ass haskell over lisp

>> No.67830787
File: 71 KB, 645x729, brainlet3.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67830791

to clean up before using it

>> No.67830810

Haskell is cleaner and terser than lisp

>> No.67830819

Look at this:
xorl %eax, %eax
popcntl %edi, %eax

The popcntl replaces the value in eax, so zeroing it out is totally pointless
Just like the assignment to zero is pointless in this code:

int a = 0;
a = 10;

>> No.67830834

I don't know x86 but is it possible that the register width is different in these cases

>> No.67830836

If the operand size it's moving into the register doesn't trigger the upper bits to be zeroed automatically. XOR'ing a register on itself is zeroing itself.

>> No.67830847

that particular example looks pointless, yes. report it to the devs?

>> No.67830850

can anyone help a brainlet out? how the fuck does hash table work? how do you pass "john doe" to a function and get the guy's position on the index in return?

>> No.67830876

Using a hash function. A hash chews up some data - a string or whatever you like - and spits out an index. There's no guarantee that the index is unique to your particular string but you can start searching from a match at that index if there are multiple strings with the same hash.

>> No.67830885

The idea is to group the input by the bytes it uses.
A hash function generates a single number from the input bytes that you can then do modulus on and use as an index to a group, where you can check each "collision".

>> No.67830886

It fixed everything that was wrong with java

>> No.67830897

The only thing it fixed was Generics, then it bolted on a bunch of badly designed badly implemented afterthoughts

>> No.67830900

It didn't

>> No.67830923

Before I try to possibly reinvent the wheel is there a way in python to get a list of all substrings from a list in a string? Like this:

If I have this string: 123abaaaabqwertyqwerty
And this list of strings: ['123', 'ab', 'a', 'qwerty']

I want to split the string into this list: ['123', 'ab', 'a', 'a', 'a', 'ab', 'qwerty', 'qwerty']

>> No.67830927

Is it nearly as portable as Java? No?
Into the bin.

>> No.67830942

Don't know about any such feature already existing but when you implement that, you'll have to watch out for "ab" and 'a' colliding with eachother.
If you can think of any efficient algorithm for it then let me know cuz I can't think of any.

>> No.67831000

&1 is portable.
>inb4 one's complement

>> No.67831004

is the order in the list the precedence at which they're extracted? sounds like a fun problem!

>> No.67831014

You're not inb4, you're in-after.

There is no reason not to use % 2. No reason.

>> No.67831017

That sounds like a NP-hard problem.
Maybe you could build a tree, but you still might have to backtrack.

>> No.67831031

>No reason.
My % key is broken.

>> No.67831032

It looks ugly. %2 is nonstandard, it's like using output instead of rc. Am I supposed to write %65535 instead of &0xFFFF too?

>> No.67831047

>get into something useful that isnt a fad

>> No.67831049

Yes, goy. The CIA doesn't wa- err.. you don't want to use bitmasks!

>> No.67831067

Doesn't get much more inane than this

>> No.67831139

see for example https://reviews.llvm.org/D17289
tldr: Sandy/Ivy Bridge and Haswell are too retarded to see that eax is a destination register, not a source register, so to pipeline the instructions better an xor is inserted

>> No.67831161
File: 20 KB, 412x351, 1531827399967.jpg [View same] [iqdb] [saucenao] [google] [report]

>company was going to give me $5k for relocation
>slipped my tongue and said i would be okay with taking the hit myself
i fucking hate being autistic. there's no way i can renege this, is there?

>> No.67831175

It seems pretty easy:
>let S = the string, L = the search list, M = the result list (empty), i = index into S (0)
>sort L in place from longest to shortest
>loop while i < |S|:
>>let Y be nothing
>>for each string X in L:
>>>if X is at position i in S:
>>>>add X to M
>>>>Y is now X
>>if Y is nothing:
>>>increment i
>>>increment i by |Y|
>return M

>> No.67831189

dumb frogposter

>> No.67831191
File: 9 KB, 390x454, 2018-09-25-004245_390x454_scrot.png [View same] [iqdb] [saucenao] [google] [report]

I made a 4chan file grabber in BBC BASIC.

>> No.67831194

>%2 is nonstandard
What the fuck are you talking about? It's the modulus operation.

>Am I supposed to write %65535 instead of &0xFFFF too?
Is it a bit mask? Use AND and 0xF's
Is it a check for divisibility? Use modulus.
>>No reason.
Because it's portable.

>> No.67831212

indeed, don't reinvent the wheel:
re.findall(r'123|ab|a|qwerty', '123abaaaabqwertyqwerty')

>> No.67831233

It is.

>> No.67831239

>on second thought I need the cash
no harm in trying, no shame in needing cash

>> No.67831254

The number of jobs available for a language is not a good measure of how good the language is. It's a better measure of how many shills the language has in high places. Which, frankly, is practically the opposite: a measure of how BAD the language is.
Which is why I'm proud to be a Ruby dev.

>> No.67831277

>no shame in needing cash
Not him but there is absolutely shame in needing cash. There's nothing wrong with it, but unfortunately, we live in a fucked up world where plenty of things have been made shameful despite not being wrong, or even necessarily within someone's personal control.

>> No.67831278

>How good the language is
There are hundreds upon hundreds of better languages than Microsoft's java ripoff.

>> No.67831291

So I guess you're agreeing with me then?

>> No.67831343

The reason is that they wanna clean up, but you could just do mov eax, 0x00. However, historically xor eax, eax was much faster than an actual mov and its instruction encoding is also much smaller. See:

bits 32
section .text
global _start
mov eax, 0x00
xor eax, eax
mov eax, 0x01
mov ebx, 0x00
int 0x80


$ nasm -f elf32 asm.s
$ ld -m elf_i386 asm.o
$ objdump -d a.out

a.out: file format elf32-i386

Disassembly of section .text:

08049000 <_start>:
8049000: b8 00 00 00 00 mov $0x0,%eax
8049005: 31 c0 xor %eax,%eax
8049007: b8 01 00 00 00 mov $0x1,%eax
804900c: bb 00 00 00 00 mov $0x0,%ebx
8049011: cd 80 int $0x80

You can see that xor eax, eax gets encoded as 0x31 0xc0, which is absolutely tiny. What's more, xor eax, eax works on the entire register 100% of the time, while the mov instruction in this takes 32-bit immediate data, but on some processors might take 16-bit immediate data depending on what the "default" size is defined as for that particular processor.

Furthermore, the 0x66 prefix can be used to modify it to take immediate 16-bit data instead, but this is ignored on Intel processor and it treats it as a 32-bit instruction, while on AMD it's treated as a 16-bit instruction with the 0x66 prefix.

x86 is a complete and utter clusterfuck.

>> No.67831351

or if you really need to grab your needles from a random string list
needles = ['123','a','ab','qwerty','.']
haystack = "123abaaaabqwertyqwerty."
matches = re.findall("|".join(map(re.escape, sorted(needles,reverse=True))), haystack)

>> No.67831364
File: 286 KB, 960x722, 1535972932461.jpg [View same] [iqdb] [saucenao] [google] [report]

I made a spongebob mock meme generator. Comes in handy sometimes.
void main(string[] args) {
import std.uni : toUpper, toLower;
import std.stdio : writeln;
import std.encoding : codePoints;

string toPrint;
bool mkLower = true;
foreach (word; args[1 .. $]) {
foreach (c; word.codePoints) {
toPrint ~= mkLower ? c.toLower : c.toUpper;
mkLower = !mkLower;
toPrint ~= " ";

$ ./mock Sîne klâwen durh die wolken sint geslagen
sÎnE kLâWeN dUrH dIe WoLkEn SiNt GeSlAgEn

>> No.67831365
File: 56 KB, 924x976, pure.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.67831385

Who was in the wrong here

>> No.67831386

because if you use a 64 bit register and move a 32 bit value into it the top bits are still set
as rax and eax are the same register only eax is the lower 32 bits

>> No.67831398


>> No.67831399

Mostly because of right shifts you dont want to get nigger dicked because there is still a set bit when right shifting

>> No.67831401

who saw this coming woah

>> No.67831429

It is wrong to make changes for the sake of optimization without perf measurements to back it up

>> No.67831437

>It is wrong to make changes for the sake of optimization without perf measurements to back it up

>> No.67831451


Or at least the assembly output.

>> No.67831452

this reminds me
is there a good guide to writing 64 bit assembly, preferably gas
i had a compiler to 32 bit gas (didn't have arrays)

i want to make one to 64 bit and i dont want to use llvm cuz that's like cheating right

>> No.67831468
File: 825 KB, 700x700, 43DE75E21A954ABA8991FD29F6A09FD2.png [View same] [iqdb] [saucenao] [google] [report]

> tfw Junior sysadmin containerizing products and transitioning to devops
It's grunt work, but whenever i test a build and a billion lines scroll down the screen...
>pic related

>> No.67831485

I feel like just knowing how to code without any knowledge about algorithm is a bit like knowing how to draw while being color blind. What's some good books to help me learn algorithms?

>> No.67831488

you for shitposting

>> No.67831493

Oh and yes, I forgot to address this:
>but on some processors might take 16-bit immediate data depending on what the "default" size is defined as for that particular processor.
What I mean by this is that if one uses mov eax, 0x00 and it is encoded as 0x8B 0x00 0x00 0x00 0x00, then it will in fact end up with undesired behavior if it is then executed on a processor with a 16-bit instruction size as default. On a processor defaulting to 32-bit instructions, the processor it will execute as "mov eax, 0", but on a processor with 16-bit default instruction size will execute it as:

mov eax, 0
add eax, [garbage data] ; [garbage data] should be next opcode, but it's treated as data

And from that point on EVERY single instruction in the program will be malformed and your program will break.

You can't use 0x66 prefix either and compilers NEVER EVER DO because it's massively problematic, because then:

- Processors with 16-bit instruction default will treat it as 32-bit instruction and the program breaks
- Intel i386 and x86_64 processors will ignore it (not spec compliant) and continue to treat it as 32-bit instruction (which is their default)
- AMD processors will not ignore it and will treat the instruction as a 16-bit one and now your program breaks again

This is stuff that compiler devs are forced to think about because they need to compile code that works on every x86 processor imaginable, even an only hypothetical processor that defaults to 16-bit instructions in 32-bit protected mode.

So this is why registers are zero'd out with xor.

>> No.67831503

Introduction to Algorithms aka CLRS

>> No.67831518


Meant to say "it is encoded as 0xB8 0x00 0x00 0x00 0x00"

0x8B does not deal with immediate data (but it is a mov instruction).

>> No.67831552


>> No.67831553

Absolute madness

>> No.67831557

What should I program now? I want something simple but challenging

>> No.67831563

An x86 emulator

>> No.67831573

If you want more, try
The Art of Computer Programming aka TAOCP

>> No.67831622

i'm currently writing a torrent CLI downloader/uploader. don't copy me silly boys

>> No.67831631

what's a brainlet friendly introduction on scheme macros?

does define-syntax just work like define except it doesn't eval its arguments?

>> No.67831663

This. But it doesn't carry a backup solution and doesn't miscompile when used outside the jump table range.
Ideally the backup solution shouldn't compile for any input within the jump table range either but that's kinda hard to deal with. And in a good language (not C++) we'd have the introspective abilities to choose which values we store in the jump table automatically.

>> No.67831667
File: 29 KB, 515x613, 1522344200660.png [View same] [iqdb] [saucenao] [google] [report]

Still playing with Julia, loving it so far.

Heres newtons method
using Flux.Tracker
using Flux.Tracker: Params, gradient, update!

∇(f,x) = gradient(() -> f(x),Params(x))[x]

function Newtons(f, x0, ε=1e-3, maxiter=1e3)
x = param(x0)
for i in 1:maxiter
x = x - f(x)/∇(f,x)
@show(f(x)) > ε || break
@show x

pic in case something fucks up again, and for output. Its great that you can write algorithms so close to how the math is.

>> No.67831690

If you know (or are learning in) C or Java, you might find Sedgewick's books more approachable. They're nowhere near as encyclopedic as CLRS, but they cover all the basic algorithms, and having actual code examples rather than pseudocode can be helpful when you're starting out.

>> No.67831710

On x86 all 32 bit operations implicitly zero extends to 64 bits.
So you should always prefer the lower 8 registers and 32 bit encodings unless you have to (i.e dealing with pointers or 64 bit numbers) since they are smaller.

>> No.67831723

Julia is a trick by the subversive Leninist society of anti-intellectuals who are part of an ancient and powerful conspiracy designed to overthrow and enslave the neanderthal race

>> No.67831732

GB emulator

>> No.67831769

>1. Download this paper: https://www.microsoft.com/en-us/research/publication/the-bw-tree-a-b-tree-for-new-hardware/
>2. Implement it in your language of choice
>3. Launch NoSQL Database Startup

>> No.67831771

I subverted your mom last night

>> No.67831772


>> No.67831786

>3. Launch NoSQL Database Startup
>4. Get patent trolled and sued into the oblivion by Microsoft.

>> No.67831789

xmm register dont do this so it is probably compiler standard to do so

>> No.67831796


>> No.67831797

They didn't even look to past experience here. Awful.

>> No.67831814
File: 7 KB, 329x190, 1511081262450.png [View same] [iqdb] [saucenao] [google] [report]

oh shit I just realized you can use /in for in, updated to be even better.

>> No.67831817
File: 1.09 MB, 3000x1994, gettyimages-8501546581.jpg [View same] [iqdb] [saucenao] [google] [report]

And I would have gotten away with it if too, if it weren't for you meddling kids.

>> No.67831842

I fucking hate him.
I hate patent trolls.

>> No.67831857

Red-black pill me on BW-Trees

>> No.67831910


>> No.67831925


>> No.67831948

I looked at https://en.wikipedia.org/wiki/List_of_data_structures and there are really many different data structures than you normally think about.
Is there any kind of diagram/flowchart that explains when to use which one?

>> No.67831971


What purpose do pointers to pointers serve?
It's already complicated enough to work with pointers, why would I need to point to pointers or even point to a pointer that points to pointers?

>> No.67831973

No, you go by instinct
Picking data structures is just an innate talent you need to have as a programmer
If you don't already know when you would use a linked list, you'll never learn

>> No.67832013

that would be a good idea desu

>> No.67832020


I'll just leave this here.
It has nice bot programming contests and other cool stuff, in case anyone is interested.

>> No.67832034

Found something annoying in Julia, shits still incomplete. even though types in some libraries have both == and < defined for them <= doesn't work and I had to create a function ≤(x::T1,y::T2) = x < y || x == y for those cases.

>> No.67832039

pointers to pointers can be useful with some complex data structure operations. Last time I used them was implementing a pairing heap with back pointers

>> No.67832088

I have a bunch of microservices. I want one schema/db per microservice to achieve total and complete isolation.

So I need/want a database/database provider. PostgreSQL preferably. I can set one up myself. Sure. I have a home server. But I don't trust myself. My house will probably burn down or something.

What paid service for a VPN/DB provider is the best? I want backups and data security.

>> No.67832109


>> No.67832124

julia confirmed shit
of course it already was because it has as many abstractions as java, which is fuck all

>> No.67832165

> it has as many abstractions as java, which is fuck all
wats missing that you need?

>> No.67832169
File: 112 KB, 675x949, 1510400538702.jpg [View same] [iqdb] [saucenao] [google] [report]

Rust doesn't have this problem

>> No.67832182

internship or full time? I'm patiently awaiting my phone interview for an internship but they haven't even confirmed a date yet

>> No.67832199

baka akari

>> No.67832211

Thats the library that's shit/incomplete, not the language. you need to define >, == and >= for custom types.

>> No.67832215

>I want backups and data security

>> No.67832219

an array of strings is a char**, just look at argv.
any array of dynamically allocated objects is an obj** for that matter.
if you want to pass an address via a pointer rather than as a reference, you easily get double or triple pointers.

>> No.67832228
File: 353 KB, 648x626, 1392011828134.png [View same] [iqdb] [saucenao] [google] [report]

and akari go hand-in-hand

>> No.67832266

why'd you post an image of a wall? Nice curtain btw

>> No.67832275


>> No.67832540

That manga is awful

>> No.67832620

where's muh default implementation?
defaults Ordered t
a < b = (b > a)
a > b = not (a <= b)
a <= b = (b >= a)
a >= b = not (a < b)
defaults Equal t
a == b = (a <= b) and (b <= a)
a <> b = (a < b) or (b < a)
compare a b
| a > b = 1
| a == b = 0
| a < b = -1

higher-kinded types of course
how else are you getting your burritos?

>> No.67832640

wtf am i doing wrong?

num = int(input("Enter number: "))
x = range(1, num)
divisorList = []

for num in x:
if x % num == 0:

>> No.67832686

>wtf am i doing wrong?
you forgot to use code tags

>> No.67832691

It's not that simple. Datastructures inform algorithms and algorithms inform datastructure choice. So it's something you need to judge in a complex manner.

But if there was a flow chart describing the intersection of access patterns for common data structures and algorithms that'd be quite helpful for some cases. Especially for making a good first guess.

Most describe their choice as intuitive. It's probably more accurately described as arbitrary with a slight common sense applied. Measuring is the only way to really know. But sadly that implies you implement a realistic test case. And maybe once you've informed yourself on the tradeoffs you may choose to reevaluate your requirements.

It's not easy.

>> No.67832702

use proper names for the 4 different things you have and you'll see
and next time use code tags

>> No.67832737

I thought I used to proper names.

>> No.67832769

you thought wrong.

>> No.67832774
File: 77 KB, 680x535, maki.jpg [View same] [iqdb] [saucenao] [google] [report]

How do you get good at interview problems?

>> No.67832777

overly descriptive names like allNumbersFrom1ToInput

>> No.67832783

you git gud. Then you ace interviews with your left hand YOU FOOL.

>> No.67832787

x % num == 0
x is a list so that doesn't make any sense

>> No.67832788

fuck I meant listOfNumbersFrom1ToInput

wasted triplets

>> No.67832789

High school students know enough maths to do it in O(log(n)) with a few variables.

>> No.67832797

go through CLRS

>> No.67832827

That's not the real math one.
Arbitrary length arithmetic is O(n) and phi^n will very quickly overflow on fixed length representation.

>> No.67832876

>High school students
Only those who search on the web for optimal fibonacci algorithms and then copypaste the thing.
You won't come up with an iterative squaring solution by yourself.

>Arbitrary length arithmetic is O(n)
based and redpilled

>> No.67832881

When would you ever want the Nth Fibonacci number without first wanting all the Fibonacci numbers before it?

>> No.67832896

When would you ever want a Fibonacci number?

>> No.67832906

Good question.

>> No.67832939

tryin to make a js for scraping url;

var data = [];

data.push(1, 23); (does this even work?)

How to get 23 value only back? data[0] should probably print out (1,23) but I just want the second value.

How do?

>> No.67832943

>ever wanting fibonacci numbers
leave those thots behind

>> No.67832956

JS doesn't use tuples so it'd be [1,23]

accessing 23 would be data[0][1]

>> No.67832969

math phds are not computer scientists; they only see the expressions, not the underlying computation. this is why most of them wrote their programs in python or R then ask a real programmer to rewrite it in c++ to run it on HPC.

>> No.67832979

why can't math people program?

>> No.67832992

Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.

>> No.67833023

>some guy walks up to you
>says "I would like F(1) mcnuggets and F(3) fries please"
>fetch laptop
>stack build /g/ certified© fibonacci program
>stare blankly at the other person for 3 minutes
>run /g/ certified© fibonacci program
>enter 1 mcnuggets and 2 fries into register
a day in the life of a haskell professor

>> No.67833035

Math students in my experience usually have an easier time with algorithms and a harder time with large-scale program structure.
My guess is that the structure of a proof is really different from the structure of a program, but I only took undergraduate courses that dealt with proofs, so I'm not sure.

>> No.67833053

Full time. Just graduated.

>> No.67833112

How is string interpolation usually implemented?
I mean something like this:
foo = 'fgt'
urafgt = `ura_{foo}` \\'ura_fgt'

It's just syntactic sugar for a string format function, right?

>> No.67833153

Some sort of substitution regexp or the compiler might split it up into several string append operations. Depends which idiot wrote your language.

>> No.67833207

Large-scale program structure isn't difficult.
Just break down your problem into something sensible that other people can understand, and then make it concrete.
That's step 1 and all most people need to be able to do.

Senior fags need to be able to design systems to be able to logically interconnect with other, already and usually larger existing systems, and also be able to navigate company politics since it can sometimes affect the scope of the project and the communication between projects

>> No.67833245
File: 148 KB, 222x293, 1536362535565.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67833283

what programming language?

>> No.67833293

>Depends which idiot wrote your language
that's gonna be me in a second

this is for a .yaml file, where {foo} expands to a serialized object {'like': 'this'}

It makes little sense to me and I'm honestly not sure where they're going with this. Maybe the string gets absorbed into the object or something.

>> No.67833307

>tfw overthinking everything
>tfw worrying about performance even though a phone can run thousands upon thousands of the same function every single fucking second, and I'm worrying about it

>> No.67833312

inspired by this:

wrote a version that uses in-place new to avoid heap allocations for a nice fsm
#include <memory>

struct FSM;
struct StateBase;
struct StateDeleter;

using sptr_t = std::unique_ptr<StateBase, StateDeleter>;

struct StateBase {
virtual ~StateBase() {}
virtual sptr_t update(FSM &) = 0;

struct StateDeleter {
void operator()(StateBase *s) {

struct S1 : StateBase {
sptr_t update(FSM &fsm) override;

struct S2 : StateBase {
sptr_t update(FSM &fsm) override;

struct S3 : StateBase {
sptr_t update(FSM &fsm) override;

struct FSM {
void update() {
state = state->update(*this);

union SUnion {
S1 s1;
S2 s2;
S3 s3;

template<class T, class ...Args>
// TODO: add check that T is S1..Sn
sptr_t in_place(Args... args) {
return sptr_t {
new (&s[index++ & 1]) T{std::forward<Args>(args)...}

// double buffer for the intermediate
// state of in place creation
uint8_t s[2][sizeof(SUnion)] {};
size_t index {};
sptr_t state { in_place<S1>() };

sptr_t S1::update(FSM &fsm) {
return fsm.in_place<S2>();

sptr_t S2::update(FSM &fsm) {
return fsm.in_place<S3>();

sptr_t S3::update(FSM &fsm) {
return fsm.in_place<S1>();

int main(int argc, char* argv[])
FSM fsm;
for (auto e : {1,2,3,4,5,6,7,8})

although I don't know if I'm invoking undefined behavior due to alignment.

>> No.67833321

That makes sense, I wasn't thinking about it properly. Ultimately, I decided to keep using the single data array and access it via data[0] and data[1] since I was only using it to store one set.

>> No.67833322

Worrying about performance is a valid concern. Do you want to be a shitty engineer or a good engineer?

>> No.67833323

Performance on phones is often about energy efficiency, not run time. Being able to do twice the work in the same amount of time is equivalent to being able to do the same amount of work with half the battery consumption.

>> No.67833336

Just use C++1z resumable functions (stackless coroutines).

>> No.67833374
File: 407 KB, 1120x840, 1509333007981.jpg [View same] [iqdb] [saucenao] [google] [report]

>wtf am i doing wrong?
You're not using Haskell
divisors num = [x | x <- [1..num]
, num `mod` x == 0]

main = print . divisors =<< (putStr "Enter number: " >> readLn)

>> No.67833382

Is that already available on gcc ? This is the latest compiler I can use:

>> No.67833452

>Large-scale program structure isn't difficult.
its the only difficult thing about programming, and what senior programmers get paid the most amoutn of money to do

>> No.67833466

Apparently no compiler has implemented it. Fucking lmao, nice language.

>> No.67833501

Just look at Snapchat and Tinder. They're by no means slow or unresponsive, but they're beasts when it comes to battery consumption. Which is pretty unreasonable.

>> No.67833571

In Swift, the compiler generates an array of strings from the literal string segments and interpolated references and then calls an initializer that concatenates them together to make the final string. So "The temp is \(currentTemp(n)) degrees" gets translated into something like String(segments:["The temp is ", currentTemp(n).description, " degrees"]) behind the scenes.

>> No.67833583

I dunno about others but on my Galaxy S7 Snapchat is extremely slow

>> No.67833585

no, clang actually has, but you need to enable it as an experimental feature

>> No.67833608

Why don't people that write in C++ write readable code?

>> No.67833632

for the alignment issue this might be an option:
using union_t = std::aligned_union_t<sizeof(SUnion), S1, S2, S3>;
std::array<union_t, 2> s {};

>> No.67833641

wah wah poo poo pee pee
someone call teh wahmbulance wah wah
ur mom

>> No.67833649

>C++ beyond toy examples

>> No.67833655

nvm, I found that this is also an option, removing the need for SUnion
using union_t = std::aligned_union_t<0, S1, S2, S3>;

>> No.67833673

Because they've been given too many tools to do so

At least with C, an emulator still looks pretty damn simple

>> No.67833764

And you're not using the fact that any divisor gives a complementary divisor:
divisors n = divisor 1
divisor a
| a*a > n = []
| a*a == n = [a]
| a*b == n = [a] ++ divisor (a+1) ++ [b]
| otherwise = divisor (a+1)
where b = n `div` a

(Appending to the list only to get the divisors from small to large)

>> No.67833810

you calculate a*a twice unless it's > n

>> No.67833852

Actually stackless coroutines could easily be done with the gnu++11 standard:

#include <cstdio>

#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))

int main() {
int co_state = 0;
int a = 10;

auto my_coroutine = [&]() -> bool {
static void *state[] = {&&first, &&second, &&third};
if (co_state != ARRAY_LEN(state))
goto *state[co_state++];
return false;
a = 20;
return true;
a = 30;
return true;
a = 40;
return true;

printf("a is %d\n", a);
while (my_coroutine())
printf("now a %d\n", a);

return 0;

>> No.67833868
File: 25 KB, 655x509, 7ppiugrc47d11[1].png [View same] [iqdb] [saucenao] [google] [report]

>ask for relocation assistance like another guy from the last thread told me to
>they end up dropping the offer's salary by 10k, but offer me 5k in relocation fees

>> No.67833873

dumb frogposter

>> No.67833883
File: 120 KB, 500x408, 798fc127521.png [View same] [iqdb] [saucenao] [google] [report]

I have problem with my C exercise, mostly loops not terminating properly, my comments go on more detail.

>> No.67833933

does using '\0' not work?

>> No.67833964

>if (First = 'E')
on second thought...

>> No.67834028

Well at least they could recognize it.
I don't think either of the people I quoted would recognize a O(log(n)) if it hit them in their face.

>> No.67834038

What does it feel like to be hit in the face by an O(log(n))?

>> No.67834042

New thread!!!

>> No.67834052

shit you're right

>> No.67834283

>wtf am i doing wrong?
using Python

>> No.67834701

thanks for the suggestion.

>> No.67835078

senior programmers get forced into management because they cost too much to keep around

>> No.67835781

Just finished up a Python script to turn all of my ZIP and RAR files into CBZs and CBRs, so that MComix previews them better.

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.