[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 314
Thread images: 29

File: K&R himegoto waifux2.png (1MB, 1000x1400px) Image search: [Google]
K&R himegoto waifux2.png
1MB, 1000x1400px
old thread: >>60990139

What are you working on, /g/?
>>
what happened to the programming general?

who are you people?
>>
>>60999178
several intelligent girlmales who bicker about "moan ads" and "lamb duhs" all day
>>
File: 1496174654982.png (393KB, 582x533px) Image search: [Google]
1496174654982.png
393KB, 582x533px
>>60999166
C influenced languages get an automatic F in my book.
>>
>>60999194
Compare the two code snippets I am about to send your way
>>
>>60999192
There are no male programmers.
>>
>>60999194
>>>/lgbt/
>>>/lgbt/
>>
>>60999194
>>60999219

#lang racket
(require 2htdp/image)
(define TILE_SIZE 32)
(define WIDTH_IN_TILES 20)
(define HEIGHT_IN_TILES 15)
(define GRID_SCENE
(empty-scene (* TILE_SIZE WIDTH_IN_TILES)
(* TILE_SIZE HEIGHT_IN_TILES)))
(define (draw-grid-starting-from x y x-offset y-offset grid color scene)
(cond
[(empty? grid) scene]
[(empty? (first grid))
(draw-grid-starting-from
0 (add1 y) x-offset y-offset
(rest grid) color scene)]
[(first (first grid))
(place-image/align
(square 32 (quote solid) color)
(* (+ x-offset x) TILE_SIZE)
(* (+ y-offset y) TILE_SIZE)
"left" "top"
(draw-grid-starting-from
(add1 x) y x-offset y-offset
(cons (rest (first grid)) (rest grid))
color scene))]
[else
(draw-grid-starting-from
(add1 x) y x-offset y-offset
(cons (rest (first grid)) (rest grid))
color scene)]))
(define (draw-grid grid color (x-offset 0) (y-offset 0) (scene GRID_SCENE))
(draw-grid-starting-from 0 0 x-offset y-offset grid color scene))
(define (listof-string->grid los)
(map
(compose (curry map (compose not (curry eq? #\space)))
string->list) los))
(define (draw-grid-from-strings los color
(x-offset 0)
(y-offset 0)
(scene GRID_SCENE))
(draw-grid (listof-string->grid los) color x-offset y-offset scene))
(draw-grid-from-strings
(list "N N OOOOO"
"NN N O O"
"N N N O O"
"N N N O O"
"N N N O O"
"N NN O O"
"N N OOOOO") (quote red) 2 4)
>>
>>60999194
>>60999219
>>60999239
Against:
#include <SDL2/SDL.h>
#include <stdio.h>
static int const PIXW = 32;
static int const PSW = 20;
static int const PSH = 15;
static void sdl_try(int l, int s) {
if (!s) {
fprintf(stderr, "SDL error at line %d: %s\n", l, SDL_GetError());
exit(1);
}
}
int main(int argc, char const** argv) {
SDL_Window* window;
SDL_Renderer* rend;
sdl_try(__LINE__, SDL_Init(SDL_INIT_VIDEO) >= 0);
sdl_try(__LINE__, !!(window = SDL_CreateWindow("",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
PIXW*PSW, PIXW*PSH, SDL_WINDOW_SHOWN
)));
sdl_try(__LINE__, !!(rend = SDL_CreateRenderer(
window, -1, SDL_RENDERER_ACCELERATED
)));
SDL_Event e;
SDL_Rect pos;
pos.x = 0;
pos.y = 0;
pos.w = PIXW;
pos.h = PIXW;
int quit = 0;
int x, y;
SDL_SetRenderDrawColor(rend, 0xff, 0xff, 0xff, 0xff);
SDL_RenderClear(rend);
char const* NO =
"N N OOOOO "
"NN N O O"
"N N N O O"
"N N N O O"
"N N N O O"
"N NN O O"
"N N OOOOO ";
int no_w = 16;
int no_h = 7;
int no_x = 2;
int no_y = 4;
SDL_SetRenderDrawColor(rend, 0xff, 0, 0, 0xff);
for (x = no_x; x < no_x + no_w; x++)
for (y = no_y; y < no_y + no_h; y++)
if (NO[(y - no_y)*no_w + x - no_x] != ' ') {
pos.x = x*PIXW;
pos.y = y*PIXW;
SDL_RenderFillRect(rend, &pos);
}
SDL_RenderPresent(rend);
while (!quit) while (SDL_PollEvent(&e) != 0)
quit = (e.type == SDL_QUIT);
SDL_DestroyRenderer(rend);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}

C is the clear winner.
>>
File: comfy.png (167KB, 376x328px) Image search: [Google]
comfy.png
167KB, 376x328px
Daily Programming Challenge:

Describe how you would gracefully recover from malloc returning a NULL pointer during program execution.
Assume that you're in a multi-threaded application and the problem is recoverable.
>>
>>60999239
>>60999250
They're the same thing. I'm not able to distinguish between shitlangs.
>>
>>60999226
There are girlmale programmers and only girlmale programmers. No male-identifying biological males and no biological females
>>
>>
>>60999255
>Describe how you would gracefully recover from malloc returning a NULL pointer during program execution.
I wouldn't use a shit language.
>>
>>60999239
>>60999250
You are not using the same library
Why defining functions in racket and not in c (eg: draw-grid-starting-from)
That racket code is badly written (C code too)
>>
>>60999262
Incorrect, C is better and it is also better than equivalent code in any language.
>>
>>60999279
>at random
That is known to be impossible. People aren't capable of this.
>>
>>60999255
>out of memory
>try to call a function to close all file descriptors and abort everything
>STACK OUT OF MEMORY
>>
>>60999255
Wrong time of day anon. Only Americans and east Asians are up now.
You won't get a good answer.
>>
>>60999304
>If
>>
>>60999298
>C is better
C is equal to Racket. How can it be better than itself?
>>
OOP was a mistake
>>
>>60999312
>calling a function
But why? Just inline it.
>>60999319
>C==Racket
This doesn't fly in C.
>>
>>60999318
From contradiction, anything follows.
>>
>big get coming up
Are you ready to snipe it?
>>60000000
>>
>>60999336
C can be shown to be the same thing as Racket. C not being able to internally recognize it doesn't really change anything.
>>
>>60999339
We aren't talking implication
>>
>>60999255
>Describe how you would gracefully recover from malloc returning a NULL pointer during program execution.
Large alloc or small alloc?
>>
File: pass by reference.png (21KB, 818x182px) Image search: [Google]
pass by reference.png
21KB, 818x182px
>using textbooks when you can use youtube
>>
threadly reminder that faggots will go to hell
>>
>>60999194
What's a non-C influenced language that does not in any way depend on a C-influenced language? (protip: x86 assembly is influenced by C).

>>60999255
>Assume that you're in a multi-threaded application and the problem is recoverable.
Why would I assume that?
>>
>>60999255
Solution 1: If I'm dynamically allocating objects, that should mean the number of objects there are is unknowable at compile time. Which, in turn, should mean they're being stored in a data structure, and how many should come into being depends on some information that's collected during runtime. If we don't even know how many we need until runtime, we can pretty much assume they're all quite nonvital to execution. So, what I'd do is I'd call a function that doesn't heap-allocate anything, and in that function, I'd display a message that the heap is full, and provide an interface for the user to manually walk the data structure(s) where our heap objects are being stored, inspect the objects, and manually choose which ones to clean up and free. Since in all probability the objects originally came from their input somehow, they should be able to tell which ones they want to get rid of.

Solution 2: Wipe the data structure(s), serializing the objects to disk in the process. Warn the user that you had to do that, and their work has been saved, but will be inaccessible for the remainder of the session.

Can't think of anything else.
>>
>>60999396
Not programming related.
>>>/b/
>>
>>60999289
>That racket code is badly written (C code too)
how so tho
>>
>>60999413
Cobol, Fortran, Haskell
>>
>>60999396
Hell doesn't exist, ANSI C36 has proved this.
... Wait, shit, I'm in 2017 aren't I.
Everyone run as fast as you can, I think I just ripped time open.
>>
>>60999413
>that does not in any way depend on a C-influenced language?
In what way is this relevant? Depending on shit doesn't make something shit.
>>
>>60999289
>Why defining functions in racket and not in c (eg: draw-grid-starting-from)
Because Racket is a functional language and C is an imperative language
>>
>>60999472
>Racket is a functional language
no. and it's not even about that; being imperative is not exclusive to structured programming.
>>
>>60999472
>Because Racket is a functional language and C is an imperative language
"well you see, trees are cyan, whereas water is yellow"
>>
>>60999472
>functional language
What is an ``functional language"?
>>
>>60999495
>implying C isn't imperative
>>
>>60999548
>implying C is advanced enough to even paradigm at all
>>
>>60999590
Even assembly is imperative. C is furthermore structured, due to the presence of named functions and variable scope.
>>
>>60999590
>paradigm
man have one dime
other man have:
pair o' dime
oh hoh hoh
>>
>>60999618
>Even assembly is imperative
[flotation needed]
>>
>>60999514
A language that allows users to do functional programming. Fix your quotation marks.
>>
>>60999628
you ok big guy
i think maybe you've spent too much time here
please shower and get some exercise friend :(
>>
>>60999649
he just wants to let us know he wrote his comment with latex
>>
>>60999739
Is that a form of attention whoring?
>>
>>60999649
>functional programming
What is ``functional programming" though?
>Fix your quotation marks.
What's wrong with my quotation marks?
>>
>>60999618
>due to the presence of named functions
Which makes it instant trash.
>>
>>60999166
Has anyone here written themselves a small script or tool they use every day? If so, please share
>>
>>60999812
Functional programming is a set of practices that involve programming with pure functions and avoiding if/else/for/foreach/while statements
>What's wrong with my quotation marks?
Your opening and closing quotation marks are not the same. Quotation marks are implied by ASCII code 34 (The " character). `` and " are not the same.
>>
>>60999645
>>60999922
0/10
>>
>>60999922
>Functional programming is a set of practices that involve programming with pure functions
So any language is an ``functional language"?
>if/else/for/foreach/while statements
Neither of those is a ``statement" in any non-shit language.
>Your opening and closing quotation marks are not the same.
You can still tell that they are quotation marks. As long as that's true it doesn't really matter.
>>
>>60999645
It literally consists of steps telling the computer what to do.

>>60999846
So you prefer BASIC then?
>>
File: spelling-sampel.png (15KB, 275x233px) Image search: [Google]
spelling-sampel.png
15KB, 275x233px
>>61000026
>So any language is an ``functional language"?
No. You could argue that no language is a purely functional language because nothing in any language is pure.
>Neither of those is a ``statement" in any non-shit language.
I didn't mention two statements. Your usage of "Neither" is wrong. I suggest that you learn English first.
>You can still tell that they are quotation marks.
That's because people can infer silly mistakes. See the attached file.
However intentionally making repeated mistakes (both spelling and grammar) suggest that you are an uneducated mongrel.
>>
File: 1470306362011.png (15KB, 300x300px) Image search: [Google]
1470306362011.png
15KB, 300x300px
>>61000122
>No
Why not?
>You could argue that no language is a purely functional language
And your argument would be invalid.
>I suggest that you learn English first.
I think I know English pretty well. I'm just having a hard time hiding my mental deformity.

>See the attached file.
False analogy. `` and "" aren't letters in a word.
>However intentionally making repeated mistakes
It should be pretty obvious that I don't consider it to be a ``mistake".
>you are an uneducated mongrel
I'm about as educated as anyone else when it comes to English. And I'm certainly not a ``mongrel" by any stretch of the imagination.
>>
>>61000249
>Why not?
Because if there is no side effect, it's not a programming language. English is not a programming language.
>I think I know English pretty well
You are daydreaming
>False analogy
No it isn't. It confirms may claim " people can infer silly mistakes"
>It should be pretty obvious that I don't consider it to be a ``mistake"
No other people consider it not to be a mistake. You can consider 5 to be a quotation mark and you will still be just as wrong.
>I'm about as educated as anyone else when it comes to English.
If you don't know what a quotation mark is, it's safe to claim that you are not educated.
You are an uneducated autistic mongrel.
>>
>>60999166
Lisp is the most powerful programming language.
>>
File: 1447058908157.jpg (47KB, 1024x576px) Image search: [Google]
1447058908157.jpg
47KB, 1024x576px
How bad of an idea is it to co-opt a 64-bit pointer by storing 4 flag bits in the highest significant bits to save space and avoid memory waste from the compiler "aligning" my structs for maximum waste?
>>
I'm building a python web scraper, but am running into a small problem:
In the website's text, there is a bit of JS that I can extract information out of. My question is, how can I convert the structure in pic related to a dictionary in python?

I've been searching around, but it appears I need JSON.stringify, which I don't have, and
json.loads(...)
doesn't seem to work.
>>
>>61000378
show us the "JS"
>>
>>61000378
Why doesn't json.loads work
>>
>>61000321
>Because if there is no side effect, it's not a programming language.
Wrong. And even if this was somehow correct, ``functionality" isn't about ``side effects". It's about respecting equality of arguments. You can still have ``side effects" while doing that.
>You are daydreaming
But only in your head.
>No it isn't.
It is, assuming `` and " aren't letters.
>It confirms may claim " people can infer silly mistakes"
That's irrelevant to our discussion.
>No other people consider it not to be a mistake.
So? Why does it matter if I can still get my point across? Other people don't seem to care about it.
>If you don't know what a quotation mark is
As far as I'm concerned a quotation mark is anything which resembles ".
>it's safe to claim that you are not educated
Educated in what? Perhaps you know more about English, but that's not really important to me.
>You are an uneducated autistic mongrel.
Please never say that again.
>>
>>61000403
because he's trying to load an invalid json, obviously
if his "json" contains that ellipsis or that variable declaration, it's not a valid
>>
>>61000378
The text above was under a
<script type="text/javascript">

so I'm assuming it's javascript (or is it actually JSON?)

>>61000403
I get the following message:
ValueError: No JSON object could be decoded
>>
>>60999279
funny but just in case anyone was unable to solve
if you say 0% you really have 25%
if 25%, you have 50%
if 50%, you have 25%
so no solution
>>
>>61000416
>>61000403
>>61000401

Here's the entirety of the JSON (I placed ellipses to have it be more readable)
>>
>>61000000
ooo big get wonder where it is
>>
>>61000428
drop everything before the first "=" is found then try again
also, seems malformed, there's no matching closing "}" (you stated it was in its entirety)
>>
>>61000414
u got tricked
>>
>>61000454
>there's no matching closing "}"
Oh my bad. There is one in the actual text I parse. Should I include the closing brace and a semicolon, or is a closing brace enough?

Update: Getting closer!
Now, the json.loads method is running, and the error is:
ValueError: Expecting property name enclosed in double quotes: line 2 column 5 (char 7)
>>
>>60999166
Can someone help me understand why this code fails automated tests? It's meant to return the index of an array which the sum of all numbers to the left and all numbers to the right of is equal. It returns -1 if there is no index that satisfies the conditions. It works on every test i've tried, but the automated test it fails every time, I can't figure out why, though.

public static int test(int arr[]){
boolean flag = false;
if(indexCheck(arr)==0) //if sum of numbers to the right of index 0 is 0, return index 0
return 0;
for(int i = 0;i<arr.length;i++){
int leftHalf = 0;
int rightHalf = 0;

for(int j = 0; j<arr.length;j++){ //for every index i, add left and right Half
if(j<i){ //and check for equality
leftHalf+=arr[j];
flag = true;
}
if(j>i)
rightHalf+=arr[j];
if(leftHalf==rightHalf && flag) //flag to avoid returning true while both halfs = 0
return i;
}
}
return -1;
}
>>
>>60999255
loop until malloc doesn't return NULL
>>
>>61000612
this
>>
>pointers
>garbage collection
Why even learn about this autistic stuff? What kind of a nerd even cares? If I want to drive I don't learn about how car is made or how it works, I just learn how to use the peripherals, the steering wheel and the pedals. Why waste your time when Python already works without knowing about that useless stuff?
>>
>>61000564
Do you know the exact test you're failing?

If not, I wrote a function that does your thing (in C++)
Two things:
1) Not really sure what 'flag' is for... Maybe add a comment describing its use
2) I don't think you need two/three if statements... Having two for-loops inside the 'separating index' for loop makes checking unnecessary.

//Works with a trivially easy vector, {1, 2, 3, 4, 3, 2, 1} (returns index 3, the midpoint of the array)
int test(std::vector<int> arr)
{
int size = arr.size();
for(int separator = 0; separator < size; separator++)
{
int leftSum = 0, rightSum = 0;
for(int left = 0; left < separator; left++) //Go to just before the separating index
leftSum += arr[left];
for(int right = separator+1; right < size; right++) //Start after the separating index
rightSum += arr[right];
if(leftSum == rightSum) return separator;
}
return -1;
}
>>
>>61000730
Then don't learn it if you're mainly interested in the high-level applications stuff. It's useful though if you ever get into writing operating systems, game engines, or reverse-engineering, or if you want to have some idea what causes programs to crash.
>>
Why are there so many jobs using braindead languages like Python?
>>
>>61000770
>returning a serious reply to my obvious bait
You're one of the good ones, anon. Now I feel bad for shitposting.
>>61000761
Hmm, no it's this website called codewars, it doesn't actually show you the test you failed, it just tells you that it failed. The flag is just so it doesn't immediately terminate on the first loop. The leftHalf and rightHalf variables both start initialized to 0, and the stopping condition is (leftHalf==rightHalf). I added the flag to prevent that, although I guess it would still mess up if Index1 is 0.
>>
>>61000511
>Should I include the closing brace and a semicolon,
No, you should read what a JSON is.
>ValueError: Expecting property name enclosed in double quotes: line 2 column 5 (char 7)
yep, that is a non conformant JSON.

YAML parser will parse that just fine.
https://stackoverflow.com/a/1931531

or maybe try another parser
>>
>>61000564
I don't fully understand the problem
mind pasting a pic to the codewars description?
>>
>>61000378
Real answer: You can't, because it's JS, not JSON. You have to evaluate it, which basically means solving this task "perfectly" is impossible the same way solving the halting problem is.

More practical answer: If this is a really specific thing you're doing once, probably match it with a regex or something. If you're trying to solve this generally, one solution is to parse the script with Esprima http://esprima.org/demo/parse.html and look for ObjectExpressions. From there you can traverse the object to find what you're looking for. There's multiple Python bindings for Esprima but it still might be easiest to write that kind of thing in JS.

>>61000730
If you're writing a project of sufficient complexity the implementation of the abstractions starts to matter even if you never touch them. Sometimes for performance reasons, sometimes for cross platform reasons, and so on. Another reason is, especially in the case of something simple like pointers, other programmers won't be able to explain algorithms to you since you don't know what they're talking about.

>>61000840
>Now I feel bad for shitposting.
Well damn, I guess I wasted my time.
>>
lads what terminal do you use?
/fglt/ is too slow.
>>
>>61000903
rxvt
>>
>>61000903
xfce4-terminal now
used urxvt for a long time
>>
>>61000903
iterm2
>>
>>61000873
"You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1."
>>
>>61001008
this is 6 lines at most
stop being an idiot
>>
>>61001037
Please post your solution, I could learn a lot from seeing how better programmers solve the same problem.
>>61000761
this for example
>>
Holly shit please kill me, this is what kind of stuff I write:
https://a.uguu.se/moqWPoJJxXlJ.py
>>
>>61001097
Nice virus
>>
>>61001104
you're welcome
>>
>>61001064
sure thing bby

int fuck(int *arr, unsigned sz)
{
unsigned i, j;
for (i = 0; i < sz; i++)
{
int sum[2] = { 0 };
for (j = 0; j < sz; j++)
sum[!(j < i)] += arr[j];
if sum[0] == sum[1]
return i;
}
return 0;
}
>>
>>61000880
I seemed to solve it through kind of a hack-ey method (using knowledge of the layout of the structure to isolate the part I need), but I'm kind of interested in learning more about what "evaluating" it would entail and why it's "impossible"

>>61001064
Something I've noticed in the couple of years I've lurked here is that some people will shit on your code (and justifiably so, we're all shitty programers at one point), but won't really offer much of a solution. Don't mind them and just focus on solving the problem at hand

>>61001097
>one comment
>one comment in python
Oh god...

I'm guessing this is a web scraper of some sort (requests and lxml), but I have no fucking clue what this does
>>
>>61001140
Yeah, it is supposed to scrape every page from ED and output the html to a text file.
>>
>>61001159
So... like an archive?
If you don't mind me asking, why?
Are you doing some sort of analysis with it?
>>
>>61001127
Very nice.
sum[!(j<i] += arr[j] 
What about for when j == i?
>>
>>61001169
for (j = 0; j < sz; j++)
if (j != i)
sum[!(j < i)] += arr[j];
>>
give me an algorithm problem. i already implemented a self balancing bst
>>
File: mfw.jpg (27KB, 533x388px) Image search: [Google]
mfw.jpg
27KB, 533x388px
>>61001167
If I wanted to archive it I would just use httrack or something.
>Are you doing some sort of analysis with it?
I was thinking about putting it though a neural network and having it match pages similar to ED..
I'll probably parse out all the html so only words are left later. (should have done that before saving them desu)
Also word frequency would be interesting.
>>
>>61001064
https://repl.it/IukP
see if this does the trick
it's C-ish Python
>>
>>61001234
Huh... Good luck, then!
>>
>>61001234
Oh. And no particular reason.
>>
>>61001227
Write an algorithm which given another algorithm and an input determines if that algorithm loops on that input.
>>
>>61001241
>C-ish python
No its not. It's just not pythonic python.
>>
>>61001274
bool ChecksIfLoopsOnInput(object algorithm) {
return algorithm is IEnumerator;
}
>>
>>61001288
It's my code and I call it whatever I want!
>>
>>61001127
This is a quadratic solution - it can be solved in linear time.

>>61001140
Think of it this way - that bandcamp page could in theory have some demanding script that serves you a different music file if and only if the Riemann hypothesis is true (a famous unsolved problem in mathematics). The script could be as simple as something which loops through every possible math proof for millions of ears checking if it happens to be a valid answer. This doesn't make the file an invalid script, it just makes it impossible to analyze.

The fact that programs have essentially unrestricted behavior like this means that most questions we ask about them we have to answer "I don't know" until the moment the actual code runs and we find out what it does. That's the essence of the halting problem. In a loose sense, the reason a programmer can still program despite this is a human thing - because with years of training, we can isolate what weak things we can prove or at least "know to be pretty much always true" about code and use them together to make larger programs.

And while I'm at it, the tools we use to restrict programs' behavior (again, this is so that we know more about what the program does BEFORE it runs) are things like type checking. (This is part of the field of static analysis.) This is also why people use statically typed languages for large projects.
>>
>>61001299
what's recursion?
>>
What's a good programming jobs website?

Sick of finding sites filled with bullshit, like when I search for something in my state and I get a bunch of jobs wanting me to relocate to the other side of the country, or soulless bodyshop shit.
>>
>>61001328
You don't speak C#, do you?
>>
>>61001328
>recursion
So what is the verdict on this? The guy who taught me programming told me to always seek recursion
>>
>>61001064
I dont think I'm a better programmer but I enjoyed solving it!
solve :: [Int] -> Int
solve as =
let posibs = map (\i -> (take i as, drop (i + 1) as)) [0..(length as)]
solns = filter (\(a,b) -> sum a == sum b) posibs
result = case solns of
[] -> -1
_ -> length (fst (head solns))
in result
>>
>>61001320
>it can be solved in linear time

Could you explain how?
>>
File: 2017-06-20-221619_673x295_scrot.png (24KB, 673x295px) Image search: [Google]
2017-06-20-221619_673x295_scrot.png
24KB, 673x295px
>>61001396
>https://repl.it/IukP
2*n
>>
>>61001388
You shouldn't always seek recursion. It depends on how much function calls will be made. It can eat up a lot of memory fast.
>>
>>61001351
Why not trust Googleâ„¢ for your job-hunting needs?

https://www.google.com/search?q=software+engineer+jobs&ibp=htl;jobs

>>61001388
In most programming languages weighted by usage, you'll make your coworkers mad and not pass code review

There are some problems where the recursive structure is evident, and that's when you use recursion

>>61001411
>>61001396
Yeah, this or some variant.
>>
>>61001411
I don't understand your code, where are your loops?
>>
>>61001419
>what's tail call optimization
>>
>>61001388
Tail recursion:
Fine if you're not using a meme-language.

Normal recursion:
If it scales linearly or worse, you're doing it wrong.
If it scales logarithmically or better, it's fine (e.g. walking trees).
>>
>>61001431
>Why not trust Googleâ„¢ for your job-hunting needs?
There are so many reasons.
>>
I'm working Binary Space Partioning program, but I've run into a snag. How do I determine what side of plane a polygon lies on?
>>
>>61001493
http://realtimecollisiondetection.net
Get this book.
>>
File: 2017-06-20-222904_632x223_scrot.png (21KB, 632x223px) Image search: [Google]
2017-06-20-222904_632x223_scrot.png
21KB, 632x223px
>>61001288
Somewhat more Pythonic.
Although this is the extent of my python-fu.
https://repl.it/IukP/1
>>
>>61001441
>meme
>>>/v/
>>
>>61001633
>The ">meme >>>/v/" meme
>>>/v/
>>
>>61001541
I'm not saying it's good to be pythonic. I'm just saying that it's not 'like C'. You can write whatever. Imo your other version was clearer.
>>
If you want to pass arguments, verify a pathname, perform tilde expansion, and perform wildcard expansion in Python, you have to import:
>os.path
>sys
>glob
And have conditionals such as:
if os.path.exists(glob.glob(os.path.expanduser('~/python/*/trash'))) and os.path.exists(
glob.glob(os.path.expanduser('~/python/*/moretrash'))):
do something

Wheres in bash it's simply:
if [[ -d ~/python/*/trash && -d ~/python/*/moretrash ]]
then
do something
fi

At this point why not just use bash? What is the purpose of Python?
>>
>>61001642
>>The ">meme >>>/v/" meme
>>>/v/
>>
>>61001703
>purpose of python
It's module system and libraries.
That's it.
>>
File: Wireworld_XOR-gate.gif (41KB, 313x170px) Image search: [Google]
Wireworld_XOR-gate.gif
41KB, 313x170px
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>

int
main (void)
{
int w = 1280, h = 800, z = 4, fs = w * h * z;
int s = 512;

unsigned char *fb = malloc (fs);
int f = open ("/dev/fb0", O_WRONLY);

char a[s][s];
char b[s][s];

srand (time (NULL));

for (int i = 0; i < s; i++)
for (int j = 0; j < s; j++)
a[i][j] = rand () % (3 + 1);

memset (a, 0, sizeof a);

while (1)
{
memset (b, 0, sizeof b);
memset (fb, 0, fs);

for (int i = 0; i < s; i++)
for (int j = 0; j < s; j++)
if (a[i][j] != 0)
memset (fb + i * z + j * w * z + a[i][j] - 1, 255, 1);

lseek (f, 0, SEEK_SET);
write (f, fb, fs);

for (int i = 0; i < s; i++)
{
for (int j = 0; j < s; j++)
{
switch (a[i][j])
{
case 0: b[i][j] = 0; break;
case 1: b[i][j] = 2; break;
case 2: b[i][j] = 3; break;
case 3:
{
int n = 0;

for (int k = -1; k <= 1; k++)
for (int l = -1; l <= 1; l++)
if (i + k >= 0 && i + k < s && j + l >= 0 && j + l < s)
if (a[i + k][j + l] == 1)
n++;

if (n == 1 || n == 2)
b[i][j] = 1;
else
b[i][j] = 3;
};
break;
}
}
}

for (int i = 0; i < s; i++)
for (int j = 0; j < s; j++)
a[i][j] = b[i][j];
}

return 0;
}
>>
Is Hackerrank good for getting a job or a waste of time?
>>
>>61001736
God damn, fix your indentation.
>>
/dpt/ how to write freestanding javascript?
i need my javascript to run without an os
>>
>>61001765
lmao
>>
File: 1490484678175.png (435KB, 720x720px) Image search: [Google]
1490484678175.png
435KB, 720x720px
>>61001765
Good luck with that.
>>
>>61001736
What does this do?
It just blacked my screen.
>>
>>61001736
>4 space tabs
https://pst.moe/paste/yemtwg
>>
>>61001703
>What is the purpose of Python?
Convenience of libraries and modules.
If I wanted to do ML, I could have a program up and running within an hour with 0 knowledge outside of the fundamentals because someone already wrote the library.
>>
>>61001736
>func ()

stop doing this
>>
>>60999194
An F is a too high of a score for your posts.
I rate your posts a Z. No, even that is too high of a score.
>>
>>61001731
But why isn't stuff like what I mentioned builtin? Why do I have to import multiple modules and call verbose functions just to perform something as trivial as wildcard expansion?
>>
>>61001812
C influenced languages still suck though.
>>
File: 1426948428708.png (9KB, 338x339px) Image search: [Google]
1426948428708.png
9KB, 338x339px
>spend well over an hour trying to figure something out
>it was just a fucking typo
>compiler was trying to tell me all along

why does this happen every time?
>>
>>61001844
>ribbit the reddit frog
I don't want reddit stink nearby. Fuck off.
>>
>>61000419
Isn't "no solution" equal to 0%? :^)
>>
>>61001844
Stupid frogposter, kill yourself.
>>
>>61001797
set your framebuffer resolution and byte depth and switch to a text terminal (ie off xorg) befaure running it, you should see the wireworld cellular automaton

>>61001755
>>61001799
>>
>>61001844
>>compiler was trying to tell me all along
>why does this happen every time?
Should I tell him, guys?
>>
>>61001812
Z is the highest possible score in Dragon Ball Xenoverse 2
>>
File: 6vScT.jpg (137KB, 717x880px) Image search: [Google]
6vScT.jpg
137KB, 717x880px
>>61001859
>>61001870
you two are reddit for thinking frog started with reddit, go away forever
>>
>>61001802
So what about the significant inconvenience I demonstrate? Do you in such instances write the necessary functions in bash, then call said bash script from Python? Is it proper to bundle bash scripts with Python programs?
>>
>>61001797
>>61001872
also remove line 26
memset (a, 0, sizeof a);
>>
>>61001765
JavaScript is basically a Scheme dialect, so you need a Lisp machine.
>>
>>61001844
Because you're a dumb unintelligent frogposter who doesn't read compiler messages?
Kill yourself.
>>
>>61001872
Meh, I'm not gonna reboot to change my framebuffer resolution. Can't I just tinker with the variables?

What is s? The dimension for the arrays that holds the cells state?
>>
>>61001859
>>61001870
n-no bully pls

>>61001877
my compiler yelled at me so i stopped talking to him >:(
>>
>>61001909
Nice filename, you stupid fuck.
>>
Arguing that it's okay to frogpost here is like arguing that it's okay to post trollface and other FB memes here just because they started here.
Your shitty frog memes no longer belong here, they are reddit memes now. Please fuck off back to there.
>>
>>61001912
Bash script is made to interface better with your OS because it was made with that design vs Python which is supposed to be an all rounder. You don't have to use python for everything you know.
>>
>>61001909
It doesn't matter where it started, what matters is where it will end.
>>
>>61001934
>my compiler yelled at me so i stopped talking to him >:(
Oh ok, so you're retarded.
>>
>>61001395
>tfw not linear
here we go:
solve2 :: [Int] -> Int
solve2 as = go (sum as) 0 0 as
where go _ _ _ [] = -1
go left_sum right_sum i (x:xs)
| left_sum - x == right_sum = i
| otherwise = go (left_sum - x) (right_sum + x) (i + 1) xs
>>
File: 1495052878325.gif (158KB, 800x336px) Image search: [Google]
1495052878325.gif
158KB, 800x336px
I'm building a small RPG with a friend
var comfy === true;
function assignKnightsArmor ( knights, armorAvail ){
var x = knights.length;
var y = armorAvail.length;
for(var i = 0; i<x; i++){
for(var j = 0; j<y; j++){
if(armorAvail[j] instanceof ChainMail){
knights[i].armor = armorAvail.splice(j, 1)[0];
y--;
break;
}
}
}
}
>>
>>61001922
oh shit, anon called him dumb AND unintelligent. What a fucking roast
>>
File: file.png (205KB, 1954x1783px) Image search: [Google]
file.png
205KB, 1954x1783px
>>61001959
def main(): 
print "problem?"
main()

main()
>>
>>61001926
i meant to set it in the code variables w h and z
and s is the size yes

use this fixed version
https://qt.catbox.moe/7873d2
>>
>>61001987
>JS
Why?
>>
>>61002026
Because it's like C but without segfaults.
>>
>>61002026
JS is quick, easy and comfy. plus we're just making it a browser based game.
>>
>>61001987
this code is so poorly written it hurts
>>
>>61002026
I'm glad you attacked me for JavaScript, and not my improper for loop (((sweat)))
>>
>>61001926
>>61002007
w,h = $(cat /sys/class/graphics/fb0/virtual_size)
z = $(($(cat /sys/class/graphics/fb0/bits_per_pixel) / 8))
>>
>>61002039
>JS is quick, easy and comfy.
No, no, and no.

>browser based game
I really hate that JS won and not something like Lisp.
>>
>>61000370
not portable at all even a little
probably flat out won't work
compiler might try to optimize it out
generally just a shit idea
at least make it a bitfield so you can be sure the compiler is ok with it
>>
>>61002066
>Shell
I'm sorry about your loss. It must have been painful, right?
>>
>>61002084
it is just pseudo code
>>
>>61002068
its ok we just need to get normies to demand that browsers start interpreting lisp or simila-ahahahahahahhaha
>>
>>61002068
>Lisp
JavaScript is the easiest fucking language on the planet.. plus it's compatible with everything. fucking Discord is in JS.
>>
>>61002099
>JavaScript is the easiest fucking language on the planet
Pretty sure that's Scheme. JS is full of inconsistencies and gotchas
>>
>>60999922
is recursion even possible without ifs?
>>
>>61002099
no, javascript is a difficult language because of how inconsistent it is
>>
>>61002112
factorial 0 = 1
factorial n = n * factorial (n - 1)
>>
>>61002112
f x = f x
>>
>>61001987
let assignKnightsArmor = (knights, armorAvail) => {
for (let knight of knights) {
let i = armorAvail.findIndex(x => x instanceof ChainMail)
if (i != -1) knight.armor = armorAvail.splice(i,1)[0]
}
}


If you're going to write JS, do it right.
>>
>>61002133
>>61002143
well i mean for building actual programs
>>
Friendly reminder that if your language isn't derived from C, you're just an acedemic wanker who doesn't do any real programming.
>>
>>61001922
kek
>>
>>61002112
true x y = x
false x y = y
>>
Solving the classic "check if two strings are permutation of each other" problem as practice. The solution says to use array and decrement counts but I think I found a more optimal solution. Couldn't one just AND all chars in string A, AND all chars in string B and then compare the two?
>>
>>61002174
>Couldn't one just AND all chars in string A, AND all chars in string B and then compare the two?
That would give false positives
>>
>>61002156
I wrote the search indexer of a fortune 500 company in CL. Friendly reminder that you're a pajeet.
>>
>>61002151
How are those not "actual programs"?
>>
>>61002151
There's relatively little use in a program without ifs, since they're one of the main ways to accomplish branching - and a program without branching is basically a book or a video. But that doesn't really have anything to do with recursion.
>>
>>61002156
As if that is an insult. They love the fact that they dont use any practical langs.
>>
>>61002184
CL is derived from C, hence C-Lisp
>>
>>61002156
>real programming
What is an ``real programming"? And why would your language need to be shit to do ``real programming"?
>>
>>61002180
Elaborate?
>>
>>61002197
lmao
>>
>>61002190
>ifs are the only kind of branching
What did she mean by this?
>>
>>61002174
How about I AND my dick into your mothers pussy?
>>
>>61002194
What is an ``practical lang"?
>>
>>61002222
fuck no, everyone knows goto is the only way real programmers branch
>>
>>61002234
>goto
pfft, try setjmp and longjmp
>>
>>61002214
I'm not going to bother coming up with an example using chars, so I'll use arrays of arbitrary nibbles instead
1100 & 0101 = 0100
0110 & 0100 = 0100

Both sets of nibbles AND to the same result, despite all being different values. False positive.
>>
>>61001909
>Le
>Herp
This is like a bad parody of reddit from 5 years ago. Ive not seen any use of either, ironically or not, in years
>>
>>61002234
>gotos and ifs are only kind of branching
What did she mean by this?
>>
>>61002234
Goto is pretty bad, but it's still miles better than any functional trash.
>>
I'm trying to make it so that when a text box receives focus a dialog box appears, using visual basic.
I am total fucking noob.
>>
>>61002245
I don't want reddit stink nearby. Piss off.
>>>/r/abbit/
>>
>>61002222
I said ONE of the MAIN types, not THE ONLY type.
>>
>>61002258
Your problem is that you're not using C++17.
>>
>>61002255
What is an ``functional trash"?
>>
>>61002271
I started programming a week ago anon.
Also this is for a project.
>>
Reminder that youre not any better of a programmer because you refuse to use mainstream languages. At the end of the day C++ or Java can produce any piece of software that Common Lisp can.
>>
>>61002273
The language you use.
>>
>>61002283
So C is an ``functional trash"?
>>
>>61002295
Well, it's not functional, but it is trash.
Also, learn to speak English properly, you fucking mongeloid.
>>
>>61002281
>Reminder that youre not any better of a programmer because you refuse to use mainstream languages
I refuse to use shit languages. And that definitely makes me a better programmer.
>C++
Shit.
>Java
Shit.
>Common Lisp
Shit.
>>
>>60999283
>use a "non-shit" language
>program aborts
kek
>>
>>61002307
>it's not functional
So you lied in this post? >>61002283
>>
>>61002311
No it doesnt. Dont delude yourself NEET.
>>
>>61002311
There are no non-shit languages. You were born in the wrong reality.
>>
>>61002336
>No it doesnt.
It does. Anyone who doesn't willingly and regularly consume shit is a better programmer than someone who does.
>>61002344
>There are no non-shit languages.
My post doesn't refute this.
>>
File: bjarne.jpg (27KB, 320x180px) Image search: [Google]
bjarne.jpg
27KB, 320x180px
>>61002311
>>
You guys have shit to do, right?
Why are you arguing over semantics?


Now give me my (you)'s
>>
>>61002356
>My post doesn't refute this.
I know. I am merely reflecting.
>>
@61002366
Irrelevant. A language being garbage is independent of its use.
>>
>>61002356
Academic wanker with a false sense of superiority detected
>>
>>61002367
The problem is the people who have the ability to actually have a meaningful debate about programming language design decisions choose not to here, and you're left with the rest.

So, you just see ad hominem shit flinging. Most of the conversations you could find+replace names of programming languages randomly and it wouldn't make any less sense. They just aren't even arguing about the content of the words they're arguing about.
>>
>>61002407
>Academic wanker
What is an "academic wanker"?
>false sense of superiority
Someone who doesn't literally consume shit is definitely superior.
>>
>>61002444
So do they just have nothing to do?
I thought this was a thread where you could post what you are working on and ask for critique or help, but it seems to be just circle jerking.
I shouldn't expect less from 4chan though.
>>
ANSI C with K&R syntax is the most powerful programming language.
>>
>>61001921
>JavaScript is basically a Scheme dialect
No wonder it's so shit.
>>
>>61002492
Well, keep in mind that at any given 30 minute interval, x amount of people are watching (pretty hard to measure) and like 3-8 people are posting. (with a lot more regulars if you count larger intervals like days or a month) That's a pretty small sample size. And often you'll see the same set of people in the same thread or the same few days.

So the quality comes in and out with the people. Some days it's been particularly shitty recently. You know, those types will always exist on 4chan. But remember that the smart people are usually around pretty reliably on a threadly basis, ish. And that's plural smart people.

That's why I have faith in these threads - cause I keep seeing smart people willing to discuss things and help people. But due to the anonymous nature of the board, you sometimes have to be a little patient and wade through a bit of shit to get there.
>>
>>61002535
>powerful programming language
What is an ``powerful programming language"? Does syntax change the ``power" of a language?
>>
>>61002549
>But remember that the smart people are usually around pretty reliably on a threadly basis
>And that's plural smart people.
I would like to see a proof of this.
>>
>>61002572
I like to think I'm smart sometimes, so maybe I'll meet your bar. Ask me some questions and we'll find out I guess.

Ruby's smart, OSGTP is smart I think but I don't see him post that much, the couple Haskell anons who know way more than me are smart, there's a couple anons who know C/C++ pretty well (hard to quantify when nobody has names, but the fact that they post means they exist...).
>>
>>61002572
Well if you're the antithesis, then logically there must be the presence of the thesis.
>>
>>61002613
>I'm smart sometimes
Prove it?
>R*by's smart
Only if by "smart" you mean "borderline retarded".

>>61002616
Laughably wrong and retarded.
>>
>>61002616
Where's the synthesis?
>>
>>61002613
Don't forget nv
>>
>>61002649
In a way, we are.
>>
>>61002641
>Prove it?
How? This is your subjective standard I have to meet so you have to give me some sort of information or protocol.
>>
>>61002641
Smart people tend to not waste their time responding to things considered laughably wrong and retarded.
Bazing.
>>
wow everyone here is a fucking retard
>>
>>61002613
hi ruby
>>
>>61002690
including yourself
>>
>>61002660
In a way, are we?
>>
>>61002666
>How?
Just prove that you aren't retarded (by retarded I mean "someone who acts like a usual poster of this thread"). That will be enough for me.
>>61002668
I never claimed to be smart.
>>
>>61002698
>I never claimed to be smart.
So my point remains valid.
Bazing....A
>>
>>61002708
Your point is invalid regardless of me being smart or not.
>>
File: 1406683143104.gif (909KB, 500x500px) Image search: [Google]
1406683143104.gif
909KB, 500x500px
>>61002697
We have now arrived at the junction we deserve.
Endless existential turmoil.
If we are, would it matter?
>>
>>61002712
>continues to be the antithesis of intelligent
>but but you're wrong waahh
>>
>>61002725
If you're not quoting anyone, please stop typing in a retarded fashion.
>>
>>61002717
It would matter, if we are.
>>
>>61002694
I'm not Ruby.

>>61002698
Well, I don't really know how to answer that. If it helps, some of my other posts from this thread include >>61001320 and >>61001431
>>
>>61002730
>doesn't understand greentext as a rhetorical device
woooooooooow
>>
>""greentext""
Kill your own self immediately.
>>
>>61002753
>has a problem with meme arrows staple trademark of the anonymous user on 4chan
>current year
>>
>""""""""""""""meme arrows""""""""""""""
What does that even mean to you? At this point, what you're saying makes no sense.
Are you just flat out stupid?
>>
>>61002779
>flat out
good game mang
But I guess the real staple trademark of the anonymous user known as 4chan is your stupidity.
>>
>good game mang
What sort of retarded dialect of English is this?
>But I guess the real staple trademark of the anonymous user known as 4chan is your stupidity.
Here you go again, talking about things that don't exist.
>>
File: file.png (123KB, 960x876px) Image search: [Google]
file.png
123KB, 960x876px
>tfw not replying to fellow anon's posts
>>
>>61002805
Why did you stop giving me (you)'s
don't you know I need them to fuel my alienware and razr products?
The only thing that doesn't exist is your IQ being in the double or triple digits.
Racist piece of shit give me (you)'s
>>
Anyone else remember when /dpt/ was good?
>>
>file.png
Is that one of those so-called "epic memes"?

>Why did you stop giving me (you)'s
This is not your homework help desk.
>don't you know I need them to fuel my alienware and razr products?
I wouldn't recommend it. That shit rots your brain.
>The only thing that doesn't exist is your IQ being in the double or triple digits.
This is more true than I'd like.
>Racist piece of shit give me (you)'s
She consorts with youkai.
>>
>>61002921
>4chan
>good
>>
>>61002928
Don't tell me you know her?
>>
>>61002925
>youkai.
>>>/a/
Moonspeak belongs in the python threads
>>
>>61000370
Yeah I was going to say, absolutely use a bitfield and then you can at least make this passable


>>61002921
It's just a couple really loud retards who think they're actually doing something impactful. Most of /dpt/ hasn't changed, they've just been drowned out, or at best, yelled at
>>
>>>>/a/
If you have anything to say, it's better to say it, than to live with regrets for the rest of your life, you know?
>Moonspeak belongs in the python threads
Let's not tell lies.
>>
I like programming but I don't like programmers. Caught myself enjoying cooler talk or lunch with our finance guys much more than with my colleagues

Almost everyone is so smug, pretentious, holy shit. I've met bloody math phds who are fun and approachable, down to earth.

It's like being able to write fizzbuzz suddenly develops a god complex in a person
>>
>>61002965
>Let's not tell lies.
Then why haven't you offed your self if every day you live is a lie?
>>
>>60999194
You're right.
No real programmer would ditch the real C language for some bootleg.
>>
>>61002966
>I like programming but I don't like programmers
Programmers are just math rejects. Why would you expect to like most of them?
>>
>>61002987
>Programmers are just math rejects
It hurts man
>>
>>61002987
>Programmers are just math rejects.
DELETE THIS
>>
File: 1489295189775.png (101KB, 246x269px) Image search: [Google]
1489295189775.png
101KB, 246x269px
>every day you live is a lie
Is that so?
>>
>>61002966
Most of my buddies (none of which are the obnoxious programmer type) are into finance and and the business side of tech, incidentally.

>>61002987
What if I'm a math major too
>>
>>61002112
you don't need ifs to implement any logic possible
you don't even need recursion because it can be implemented in simple lambda calculus
>>
>>61003019
>obnoxious programmer type
What do people mean by this? I haven't met many programmers.
>>
>>61003043
The stereotypes are like this: Awkward. Acts they're special (not always overt) because they're a programmer. Probably thinks they're way better than they are. Particularly unwilling to admit when they didn't know something, especially when it's about CS and especially in a group. Thinks AI is "the future" and is super hype about it but doesn't understand a god damn thing even though he could talk about it for hours. Seems to easily make personal judgements about people based on whether they program. Probably browses r/programmerhumor too much.
>>
>>61003121
It sounds like you're angry about people who are smarter than you and are coming up with nitpicks and assumptions to try do demonize them in your own mind
>>
>>61003132
He is objectively correct.
>>
>>61003132
Nah, I'm pretty comfortable where I am now. But I'm pretty keen on it since I used to be that guy, in my opinion.
>>
I started learning Java 8 somewhat recently. I just can't seem to get my head around classes, constructors, and fields. Are there some nice books that explain this stuff in a way a retard can understand? I've been using Java All-in-One for Dummies and Introduction to Java Programming: Comprehensive Version.
>>
>>61002149
looks like it could be monoscript, not javascript. Unity a shit.
>>
File: yukari_chomp.png (24KB, 282x188px) Image search: [Google]
yukari_chomp.png
24KB, 282x188px
>>60999194
Pajeet detected.
>>
>>60999441
casting to bool via !! when the if statement in sdl_try would work perfectly without it

writing __LINE__ everywhere when you could rename sdl_try to _sdl_try and have a simple macro like
#define sdl_try(x) _sdl_try(__LINE__, x)


writing
while(!quit) while (read event) quit = (event is quit event)
instead of
while (read event != quit event)


closing parenthesis on next line down instead of on the same line

a couple other nitpicky things
>>
How does machine code run?
Does it just run linearly through memory, interpreting it as code then altering memory based on that, until a particular pattern in that memory tells it to stop or jump elsewhere?
>>
File: yukari_arxiv.png (211KB, 372x1118px) Image search: [Google]
yukari_arxiv.png
211KB, 372x1118px
>>61002966
>I've met bloody math phds who are fun and approachable, down to earth.
That's because they're tackling difficult problems that make them feel stupid all the time. Anyone who's gone through a math PhD will agree that it's a humbling experience. Math PhDs know where their expertise begins and ends and act accordingly.
Programmers on the other hand tackle only trivial and extremely simple problems; they're never challenged and never learn anything new, making them think that they're the king of their little domain. Anyone who challenges them are seen as an outside invader that threatens their fragile ego. A programmer without any training outside of programming is basically an intellectual sinkhole.
t. theoretical physics PhD candidate
>>
>>61003132
>>61003153
And that isn't to say I've fixed everything but I like to think I'm better about it.

>>61003353
Different anon, I just wanted to thank you for giving him real code feedback.

>>61003369
From a "definition of how the machine operates" standpoint, yeah, that's how machine code runs. From a practical standpoint, there's a vast array of optimizations and techniques that make how it's accomplished essentially unrecognizable. You might want to look up things like CPU pipelines, branch prediction, out of order execution, and how cache works. My knowledge here is limited though.
>>
>>61003401
you're meeting shit programmers then. The programmers I know like programming because of the astronomical number of challenges programming can tackle.

Games programming? That has a range of very challenging tasks like AI, Game Engine, Rendering etc.

Software development? You're making a system for a very specific purpose that has to run well and meet the client needs.

Dickhead programmer? You're making shitty indie games while inflating your ego on youtube.
>>
>>61003369
It normally runs linearly, advancing to the next instruction except in the case of a jump instruction where it goes somewhere else. Data is usually stored in separate areas of memory for security reasons, for the most part memory areas fall into three types:

code - executable, read-only
constant data - non-executable, read-only
variable data - non-executable, writable
>>
File: OpenGL.png (211KB, 3329x2150px) Image search: [Google]
OpenGL.png
211KB, 3329x2150px
I still haven't figured out how to get the correct coordinates when moving the mouse so that I can draw labels for the price levels.
>>
im a noob and i just realized

it's literally impossible to become a programmer if you dont enjoy it
>>
>>61003586
wow who woulda thunk
>>
new thread
>>61003613
>>61003613
>>
>>61003586
I do enjoy it, but I can't fucking do it!?!?!?!?!?!?!?
>>
fun with ternary trees in haskell
data Tree a
= Tree { x :: a
, children :: [Tree a]
}

instance Foldable Tree where
foldr f z (Tree y []) = f y z
foldr f z (Tree y (l:leafs)) = f (x l) (foldr f (foldr f z (Tree y leafs)) (map x (children l)))

instance Functor Tree where
fmap f (Tree y []) = Tree (f y) []
fmap f (Tree y (leafs)) = Tree (f y) (map (fmap f) leafs)

instance Show a => Show (Tree a) where
show (Tree y leafs) = "Tree " ++ (show y) ++ " " ++ show leafs

testTree :: Tree Int
testTree
= Tree 5
[Tree 3
[ Tree 20 []
, Tree 21 []
]
, Tree 10
[Tree 1 []
]
]


depth :: Tree a -> Int
depth (Tree _ []) = 1
depth (Tree _ leafs) = 1 + (maximum (map depth leafs))

thanks to our foldable instance, we get a lot of free stuff:
> depth testTree
3
> maximum testTree
21
> sum testTree
60
> elem 21 testTree
True
>elem 99 testTree
False
> fmap ((+) 1) testTree
Tree 6 [Tree 4 [Tree 21 [],Tree 22 []],Tree 11 [Tree 2 []]]
>>
>>61003637
"x" isn't a great name for a field
>>
>>61003579
You might able to invert the matrix you use to transfer your bars to screen coordinates, and then take the product of the click vector with that matrix to get your equivalent coordinate in "bar space", whatever may be. Then it's just a matter of finding what index you're on top of.
>>
>>61003667
fair point
I also just realized my foldable implementation is bugged ...
>>
>>60999317
so you're one of which
>>
I want to make a multiplayer game. Most of the logic is done for offline but Im not really sure I understand how online would work. Id like for it to be p2p instead of always needing a server, but Im reading things about port forwarding that I dont get. Why is port forwarding not required when you connect to a server for instance.
>>
>>61003726
I don't know enough about how to use OpenGL and so I don't know how to do that. Sofar search results for this are only showing 3D stuff using frustum and not ortho.
I'm even using keys instead of mouse to move around kinda like moving the cursor around in vim.
>>
>>61003894
Well, I'm sorry I'm not much use, then. I know a lot more about math than I do OpenGL.
>>
>>61003850
When you connect to some well-known server (i.e. the game server), your router remembers which of your computers was the one that made the connection and adds an entry to the NAT table. However, when someone connects to your router, it doesn't know which of your computers it's supposed to go to.
There are things like UPnP which can be used for NAT traversal, but I don't really know a lot about it.
>>
>>61002311
Java is actually better than C++, C++ is in the bottom of the barrel
>>
>>61001968
All of 4chan will end up on reddit someday because of the retards using both websites
Thread posts: 314
Thread images: 29


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.