[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: 321
Thread images: 36

File: 1464472158477.jpg (675KB, 940x822px) Image search: [Google]
1464472158477.jpg
675KB, 940x822px
Old thread: >>57799306

What are you working on /g/?
>>
File: category theory.png (7KB, 397x150px) Image search: [Google]
category theory.png
7KB, 397x150px
Too early but at least it's anime edition
>>
>>57807030
second for racket
>>
File: 1475856212384.png (194KB, 419x720px) Image search: [Google]
1475856212384.png
194KB, 419x720px
>>
>>57807060
stupid comic whoever wrote it was a cunt
>>
Lol what a coincidence, I merged 2 datasets and they came out exactly at 250 items, I thought that there must have been something capping it at such a nice number.
>>
golang is gonna be the only language in the future, and there's nothing you can do to stop it.
>>
How do I set an arrays initial value to start at 20 in Java?
>>
>>57807079

I mean, I could commit suicide to never see the day that came true
>>
>>57807079
>implying all python shitcode is just gonna disappear
>>
File: aaaaaa.png (38KB, 789x869px) Image search: [Google]
aaaaaa.png
38KB, 789x869px
why is this not working?

the answer I was given was that there is no method displayBalance visible but I don't really know what he means by that
>>
>>57807042
>image
I chuckled.
>>
Name me stocks I should feed to my neural network as training data.
>>
File: 1459551124207.png (20KB, 809x497px) Image search: [Google]
1459551124207.png
20KB, 809x497px
>>57807030
What's your programming environment?

Mine is generally just vim. I've been looking for a good font though.
>>
File: 1455571524166.jpg (147KB, 600x534px) Image search: [Google]
1455571524166.jpg
147KB, 600x534px
>python doesn't have native boolean indexing
>>
>>57807030
Question generation from a self-managing inference bank, as part of a Strong General AI.
You?
>>
>>57807201

uhhh making fizzbuzz in javascript
>>
>>57807184
It couldn't find its own?
How... old fashioned?
>>
>>57807220
Oh.
I... see.
Toys.
Nice.
>>
>>57807177
I see there's a method called "displayTransaction".

Does the method "displayBalance" exist in "Account"?
>>
File: 1477764387043.gif (3MB, 290x290px) Image search: [Google]
1477764387043.gif
3MB, 290x290px
>>57807177
>TO DO: displayBalance

There is no displayBalance method, odds are you actually have to make it
>>
File: 0003.jpg (220KB, 448x455px) Image search: [Google]
0003.jpg
220KB, 448x455px
>>57807201
>Strong General AI
>>
File: 1471369878214.gif (961KB, 310x212px) Image search: [Google]
1471369878214.gif
961KB, 310x212px
>>57807257
>>57807264
aww fuck, you are correct yeah I didn't make one.
>>
whoever made the OP: put the SICP cover on the monitor and make the mug the original cat mug
>>
File: 1463562702375.jpg (76KB, 640x640px) Image search: [Google]
1463562702375.jpg
76KB, 640x640px
Much like the DJ/Producer of yesteryear, programming, aka "making apps" has become the latest must-have personality accessory.
>>
How's that class going /dpt/?
>>
File: death.png (14KB, 819x343px) Image search: [Google]
death.png
14KB, 819x343px
>>57807278
how do I even go about doing that? I'm guessing he wants me to copy something similar to the displayTransaction one but I don't even know what half of these symbols and percentages do
>>
>>57807223

I'm just messing around with Torch.

I could scrape some indice and download all .csv's with a shell script or something, but I'm being lazy right now
>>
File: 1455891954807.png (274KB, 478x528px) Image search: [Google]
1455891954807.png
274KB, 478x528px
>passed phone interview
>>
>>57807357

happy patty flipping my friendo
>>
>>57807220
>javascript

>using the jewscript botnet
Learn two haskell brah
>>
>>57807199
go back 2 matlab
>>
>>57807320
Operating Systems is lame as fuck
>>
>>57807393
but i came from R...
>>
File: 1450294610045.png (499KB, 483x814px) Image search: [Google]
1450294610045.png
499KB, 483x814px
>>57807325
>I don't even know what half of these symbols and percentages do
I don't even familiar with Java but here have a read
https://docs.oracle.com/javase/tutorial/java/data/numberformat.html

>how do I even go about doing that?
How about printing out the current balance of the account
>>
>>57807199
Has there been a PEP about it?
Write one.
>>
>>57807436

The Moors weren't black...
>>
>>57807199
(x for x in y if f(y))
>>
I love the Eva OPs
>>
>>57807484
>Moors weren't black
nigga
>>
>>57807199
>>57807520
meant
(x for x in y if f(x))
>>
>>57807538
they weren't you uneducated ape
>>
>>57807325
%s
Is a string format.

\n
Is a new line.

%4.2f
It's formatting a float number to a specific way.

.format is basically telling it the indicated format then what's it supposed to show after the comma.

so you'd need to instance the balance class where the account number matches then retrieve the balance for that account.
>>
>>57807541
>>57807520
i meant proper support for somethinglike
list1[list1 < 1]
, not a hacked-together list comprehension
>>
File: 1478158070123.gif (2MB, 179x320px) Image search: [Google]
1478158070123.gif
2MB, 179x320px
>>57807357
>passed phone interview
>next stage is doing fizzbuzz in person
>>
>>57807177
either you didn't make a method called displayBalance in the Account class

or its not visible where you are calling it, perhaps it is a private method?
>>
>>57807538

I mean, the group we call the moors today is black yeah, but back then it was the muslims inhabiting the Iberian peninsula, which would have been a shade of bedouin brown since arabic conquerors are literally what they were.
>>
>>57807593
What would be the effect of that statement?
>>
>>57807593
It's just syntax suger.
[i for i in list1 if i < 1]
>>
>>57807593
Should use Ada, the syntax is kind of similar to Python.
>>
>>57807614
it's equivalent to:
indices = list1 < 1
subset = list[indices]


>>57807620
I know that. But for a language that supposedly prides itself on readability and simplicity, the lack of that syntactic sugar and the reliance on unnecessarily complicated list comprehensions for the same behavior in daily use is surprising.
>>
>>57807642
And the typing is completely different.
>>
>>57807661
But it does that the guy needs
>>
>>57807193
I like Fira mono
>>
>>57807651
I guess that makes sense but you could just use filter.

l1 = [-5, 2, 0, -3, 10, -23, 15, -7]
l2 = filter(lambda n: n < 1, l1)
>>
>>57807651
List comprehensions are basically set-builder notation.
>>
>>57807674
>>57807193
hmm I thought I added a picture
>>
>>57807030
Is there a tool that allows to slowly play assembly code and see registers in linux? better if emulates arm.
>>
File: ENDMYLIFE.png (8KB, 365x226px) Image search: [Google]
ENDMYLIFE.png
8KB, 365x226px
>>57807577
>>57807436
thankyou thankyou IM SO CLOSE FUCK IVE BEEN DOING THIS FOR 6 HOURS NOW

WHATS THE SYMBOL FOR A DOUBLE EVEN GOOGLE WONT TELL ME
>>
>>57807701
gdb binary
tui
stepi
>>
>>57807651
I suppose I'm just used to list comprehension form that I don't see them as complicated.
>>
>>57807701
I remember something like that when I was first studing microcontrollers, but was for windows.
>>
>>57807651
>it's equivalent to:
That's not valid python.
I'm assuming that's valid in numpy.
>>
Austin, post negresses.
>>
>>57807709
Unless you want to give your double a specific format, you can use %s to convert it to a string.

Otherwise is the same as a float. if it's a balance i guess you'd want 2 decimals so "%.2f" would do.
>>
File: 20161202_155338.png (341KB, 1069x1690px) Image search: [Google]
20161202_155338.png
341KB, 1069x1690px
I got no answers on stack overflow, but I really need help with this. I'd really appreciate some help with this.

Screens hots of my explication of the problem 1/2
>>
>>57807739
It's R, anon. Not everything that uses brackets is Python.

>>57807676
The reason why I want to do it is because I can then do things like filter on one list and apply it to another list of the same length.
for example:
list1[list2<1]


My specific use case is that I need to generate the reverse complement of a DNA sequence and I don't want to install and import a whole package just to do it.

The way I'd do this in, say, R is:
dnaForward <- c('g','c','a','t')
dnaReverse <- c('c','g','t','a')
oldSeq <- c('g','g','t','a','a','g','c','g')
newSeq <- rep("n",length(oldSeq))
for (eachPosition in seq(1,length(oldSeq) ) {
newSeq[eachPosition] <- dnaReverse[dnaForward %in% oldSeq[eachPosition]]
}


I mean, I could probably make that cleaner if I used apply() instead of a loop but you should be able to get the jist of it.

>>57807719
For the most part they're not, they're even rather nice, it's just that when I get into more complicated problems that would be pretty trivial in other languages, I find myself stumbling a lot on them.
>>
>>57807832
bleh i missed a closing paren on the for header
>>
File: 20161202_155300.png (297KB, 1061x1375px) Image search: [Google]
20161202_155300.png
297KB, 1061x1375px
>>57807814
2/2
>>
Does anyone have any tips for refactoring old / absolutely insane code bases?

I've inherited a complete mess and a rewrite isn't on the table yet. Thick-client ASP.NET website with majority of the code in jquery/js, string manipulation to get HTML made. 3-4 40,000 line js files, and some shoe horned in angular where the last developer tried to "improve things".

Its not looking good (its really hard to maintain - moving the order of where a checkbox is instantiated (yes, its done in JS) causes the entire page to fuck up and not render properly.

Should I just quit and/or kill my self or is there some reasonable way to go about attacking this?
>>
File: 1479860171242.jpg (41KB, 643x580px) Image search: [Google]
1479860171242.jpg
41KB, 643x580px
This might be a borderline retarded question to ask but how do you tell the level of a node by it's index in a binary heap?

I know the answer is probably simple but my brain just isn't working with me on this one.
>>
>>57807897
Walk up the heap until you're at the root node and count the number of steps along the way?
>>
>>57807880
what is the error?
>>
>>57807923
>>57807880
also show that board object
>>
>>57807701
if you want a gui you may like "visual", exists in ubuntu. Also in AUR if you use archlinux
>>
>>57807895
>asp.net
>make everything in JS anyway

but why.
>>
File: 1476548756328.jpg (134KB, 500x880px) Image search: [Google]
1476548756328.jpg
134KB, 500x880px
>>57807799
Thank you, it's finally fucking done. And just like that my module is finished

thank fuck
>>
>>57807966
I know Anon, I know. This thing started 6 years ago by C++ devs as a hobby project that got shoved into production. majority of the internal libraries are abandoned as well, but stuck with them.
>>
Someone, please try to defend dynamic typing
>>
>>57807982
I hope your lack of knowledge required for classes will bite you in the ass sooner than later. I wish retards that helped you could tell the difference between guidance and spoonfeeding.
>>
>>57807832
>>57807719
Actually, after playing with it some more I think I've come up with something that works and I'm satisfied with

for eachBase in seq1:
oldPosition = [y for x,y in zip(dnaForward,[0,1,2,3]) if x is eachBase][0]
seqNew = seqNew + dnaReverse[oldPosition]


I do still wish I could index with booleans without a third party package but this is ok too.
>>
>>57807999
if you're not a shitty programmer it shouldn't matter whether typing is strict or not because you actually remember what types things are
>>
>>57808010
I was spoon feeding my wife during the starting of the semester but quickly found out how much that was fucking her over. Had to throw her in the deep end and not help her at all the last month or so. She is a much better programmer because of it.
>>
>>57808028
No. A good programmer know how to separate what a computer must do and what a human must do.
>>
>>57807999
Is var pseudo dynamic typing?
>>
>>57807193
I switched from Vim to Visual Studio Code. Fira Code with ligatures, Mensch or good old Consolas.
>>
>>57808068
No. It's type inference.
>>
>>57808068

I would say so, same with "any" in TypeScript. You can abuse the shit out of it.
>>
>>57807923
>>57807934
I'll do these in a bit when I can
>>
Hey, I'm a bit confused...

Why is it that in PHP, I can do something like

switch($i){
case ($i == "hello"):
//stuff
break;
default:
}


but not in C/C++? Cases are much nicer to work with than if-else.

Is there a way around this, to use logical operators in each switch case?
I also tried switch(true)
but I still get the error:
error: the value of I is not usable in a constant expression


Fuck, sorry. I forgot a slash...
>>
>>57807201
Bullshit.


I want in.
>>
>>57808108
isn't it like this?
switch(variabe){
case "hello":
//stuff
break;
}
>>
>>57807287
What anime is it btw?
>>
>>57808121
this>>57808133 was meant for you, heh I got dubs XD
>>
>>57808121
switches in c/c++ only work on word size values, so the max is int64. Strings are variable length so you cant switch on them.
>>
File: book.jpg (21KB, 309x408px) Image search: [Google]
book.jpg
21KB, 309x408px
I'm working on finally sitting down and learning this god damn fucking horse shit Jesus Christ why is it so hard it's like it's a whole 'nother language fuck
>>
>>57808156
>like it's a whole 'nother language
>"The C Programming Language"
wew
>>
>>57808028
If you're a good programmer, dynamic types are providing no benefits and yet they're killing performance. Static types at least hint to the compiler that it can do more optimizations.
>>
>>57808010
i mean im good at all my other classes and never need to program again so i dont give a fuck
>>
>>57808133
I was referring to the use of logical operators in each switch.

For instance, my Discord Bot has stuff like:
case preg_match("/baka/i", $incomingMsg) == true:
$message->channel->sendMessage("*NO! YOUR THE BAKA~!*");
break;
case preg_match("/OwO/i", $incomingMsg) == true:
$message->channel->sendMessage("OwO :blush:");
break;


but in a C++ program, I looked at what the hell a FizzBuzz is, and part of my code looked like:
for(int I = 1; I < 101; i++){
switch(i){
case ((i % 5 == 0) &&(i % 3 == 0)):
//FizzBuzz
break;
case (I % 5 == 0):
//Buzz
break;
[...]
}
}


Just always saw people saying they made a FizzBuzz, so I wanted to look it up, but I noticed C++ won't lemme run it like that...

>>57808151
Well, if that's the case, it should have done it as a bool, right? And it would've been equivalent to a 1 or 0, right?

I'd have thought maybe to cast it, but it's saying the variable I can't be used like that, whereas I'd have been only casting the return value of, say, (I % 3 ==0)...
>>
>>57808141
you're fucking with me right
>>
>>57807917
It's a binary heap, not just a tree.
>>
>>57808241
Evangelion? I just want to be sure, because if it's not, I want to watch it.
>>
>>57808232
For reference, those variables were not different. That's my browser's autocorrect.
They're all lower-case i
>>
>>57808028
>>57808199
That said, a good programmer could also prefer to spend his mental effort on something that a computer can't easily do. Types are documentation, optimization, and verification all in one.
>>
>>57808232
I don't think switch in c++ works like that, the cases are just used to check the value of i, you're going to have to use ifs and elses or ?: (I don't know the name for this).
>>
>>57808289
Hmm.... that is a shame. It's formatted so much nicer in switches. I mean, I'll do it if there's no way around it, but ok.

Also, just for reference, ? : is called "Ternary operator"
Actually, I shoulda considered that earlier... That can still maintain some decent formatting. Just gotta get all the ending )s right
>>
File: image.png (3KB, 564x78px) Image search: [Google]
image.png
3KB, 564x78px
Alright so I'm >>57806086 and I'm still stuck.
I need to
>have a user input loop that takes 3 things (name, hours worked, pay rate) until the user decides to stop, then the data the user entered must be saved to a file
>then I must take the data from the file and figure gross pay, and display each piece of data in a chart, see pic related
I can't seem to figure out how to use the data from the file to do what I need to. I can't use pickle, no OOP, and can only use shit we've covered so far. I feel retarded, might give up tbqh.
>>
>>57808316
I'm not too sure about this but I think using the switch statement is a bit slower because of the conditional jumps or something like that. I'm tired.
>>
>>57808325
Return the list and pass it as a parameter to another function.
>>
>>57808378
Hmmm, well, it is what it is.

Just rewrote it like this, though, and it works
#include <stdio.h>

int main(int argc, char** argv){
for(int i = 1; i < 101; i++){
((i % 5 == 0) && (i % 3 == 0)) ? printf("FizzBuzz!\n") :
((i % 5 == 0) ? printf("Buzz!\n") :
((i % 3 == 0) ? printf("Fizz!\n") : printf("%d\n", i)

));
}
return 0;
}


I guess it's no big deal. Just a preference, really.
>>
>>57808413
that's true. have a nice day buddy
>>
>>57808431
thanks, you too
>>
>>57808260
yes, it's eva
>>
>>57808316
Switch statements aren't great for a FizzBuzz anyway. For instance, imagine you're at a job interview and you're asked to do a FizzBuzz. But once you finished, they ask you to add Pop and Whack for multiples of 7 and 11. Now you're scrambling to do some quick math and add a bunch of cases.

This is a better way to do FizzBuzz in C++.

 
std::string string;
for(int i=1; i<100; ++i)
{
if(i%3==0)string+="Fizz";
if(i%5==0)string+="Buzz";

if(string.empty())
std::cout<<i<<"\n";
else
{
std::cout<<string<<"\n";
string.clear();
}
}


And then if you need to expand it, you just add lines like:

if(i%7==0)string+="Pop";
if(i%11==0)string+="Whack";
>>
>>57808021
Use enumerate instead of zipping with indices. If you only want the first entry of a list comprehension call next on a generator expression instead. Something like
oldPosition = next(n for n,x in enumerate(dnaForward) if x is eachBase)


If I'm reading the code right though it seems like oldPosition is simply the index of eachBase in dnaForward?
Why not use index method?
>>
Okay, fuck me, does file:read() in lua automatically seek to the next line or not???
>>
>>57808705

Lines and seeking are implementation details you should not rely on.
>>
>tfw interview tomorrow
>tfw it's technical and programming

I'm scared
>>
>>57808763

I am reading .csv's...
>>
can depression cure programming
>>
Am I doing it right?
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Fizzbuzz is

type Working_Range is range 1..100;
type Array_Check is array (Working_Range'Range) of Boolean;

package Rand is new Ada.Numerics.Discrete_Random(Working_Range);
Seed : Rand.Generator;

protected Check_Buffer is
procedure Check (Item : in Working_Range);
function Get_Count return Natural;
private
Numbers : Array_Check := (others=>True);
Count : Natural := 0;
end Check_Buffer;

task type Fizzer is
entry Go;
end Fizzer;

task body Fizzer is
Item : Working_Range;
begin
accept Go;
loop
Item := Rand.Random(Seed);
Check_Buffer.Check(Item);
exit when Check_Buffer.Get_Count = 100;
end loop;
end Fizzer;

protected body Check_Buffer is
procedure Check (Item : in Working_Range) is
begin
if Numbers(Item) = True then
Count := Count + 1;
Numbers(Item) := False;
if Item mod 15 = 0 then
Put_Line("Fizzbuzz");
elsif Item mod 5 = 0 then
Put_Line("Buzz");
elsif Item mod 3 = 0 then
Put_Line("Fizz");
else
Put_Line(Working_Range'Image(Item));
end if;
end if;
end Check;

function Get_Count return Natural is
begin -- Get_Count
return Count;
end Get_Count;
end Check_Buffer;

F_1 : Fizzer;
F_2 : Fizzer;
F_3 : Fizzer;

begin -- Fizzbuzz
Rand.Reset(Seed);
F_1.Go;
F_2.Go;
F_3.Go;

end Fizzbuzz;
>>
>>57808791
What's the job?
>>
>>57808847
Robotics programmer
>>
File: common-lisp-benchmark.png (11KB, 512x384px) Image search: [Google]
common-lisp-benchmark.png
11KB, 512x384px
>mfw Common Lisp isn't even as slow as I thought
Year of Lisp when?
>>
>>57807832
>>57808021
Encode the complement mapping in a dictionary then just run through sequence and then reverse sequence.
Why do biologists make everything so complicated.
>>
What's a sane way to build large C++ project on linux? IDEs suck and writing makefiles by hand is even worse.
>>
>>57808905
Javascript in V8 is fucking ludicrous speed.
>>
>>57808974
>writing makefiles by hand is even worse
Why? It's fucking easy.
>>
>>57808974
By using an IDE you fucking hipster.
>>
>>57808974
>>57808974

> using makefile in 2016

use cmake

also it's called code::blocks, nigga
>>
>>57808325
consider how you're formatting your file

for ease i'd save it CSV style with each name,hoursworked,payrate comma separated on separate lines each. It should be pretty easy to read in each line one at a time and split it using a string split function (not sure exactly what python's is called). you can then do your calculations and output them line by line. consider that if you take this approach the inputs should be sanitised and not allow commas in them or it'll fuck up. that might be out of the scope of your homework though.
>>
>>57808984
Makefiles are so fucking archaic and need to die

>>57808987
>>57809003
Using codeblocks for now, can you recommend me something else that doesn't crash every other second?
>>
>>57809041
>Makefiles are so fucking archaic and need to die
They work and are fully supported.
>>
>>57809041
>Makefiles are so fucking archaic and need to die
What the fuck are you talking about?
Makefiles are great. You can write a makefile which will compile 95% of software that hasn't done any stupid shit in like 20 lines.
You can also build your targets in parallel.
>>
Sent an email off to the dude that does the Advent of Code challenge asking him to provide a common dataset for those who wish to do his programming challenges without signing in with a social media account, and don't particularly care about being on his leaderboards.

>>57808974

CMake.

>>57809041

They're actually pretty easy to work with.
>>
>>57809041
I wrote a generic makefile once that wildcards all *.c files and even handles projects with multiple mains.

I copy it into all my projects because it just works.
>>
>>57809154
Mind sharing?
>>
>>57807320
Programming Abstractions are fun!

On a related note, would it be possible to make a C++ class where you have an include statement that only applies to that class? (Including <std::vector> in a class, but making it such that any program that uses that class needs to #include <vector>)
>>
File: 1474090275094.png (11KB, 800x600px) Image search: [Google]
1474090275094.png
11KB, 800x600px
CMake? More like...
...
CuckMake
>>
>>57809184
Any make is for cucks.
>>
>>57809182
not yet, unless it isn't templated in which case you can #include in a .cpp
>>
>>57809184
XXXXXXXDDDDDDDDDD EPICCCCCC
kys senpai
>>
>>57809184
hahh
aaa
ha
a
hahhaa
haha

ha
hah
a
hah

ha
hah
a
ha
hah
ah
ha
ha
hahaha
h
hah
ah
ah
a
hah
a
h
ha
hah
ah
a
ha
haahaha
ahha
hah
a
ha
ha
h
hah
a
ha
hahah

ha
ha
ha
ha
hahah
ha
ah
haha
hah

hahah
haha
hha
haha

ON SUICIDE WATCH
>>
>>57809134
thank you kindly for this.

i went to advent of code and read the first two problems which were completely incapable of understanding what was going on - then it clicked - the dataset is missing to solve teh problem and i left after that.

doesn't help i'm knee deep in a project of my own that seems more interesting then the challegneson there.
>>
>>57809177
http://pastebin.com/FcdKLYGT
>>
File: 1478609742190.jpg (80KB, 478x644px) Image search: [Google]
1478609742190.jpg
80KB, 478x644px
>want to dev at cool open source project
>get ignored
its just like searching for a job
>>
>>57809283
your life is a joke

im off to fucking my real hot gf now in my indoor pool in my mansion
>>
>>57809283
You have to ask?
>>
Hahaha, how is using OpenCL in torch like 20x slower than just CPU
>>
>>57808844
Kek
>>
>>57807087
Bump
>>
>>57809177
Not him, but here is mine:
# Shit you can modify

TARGET = myprog
CFLAGS += -std=c11 -Og -g -Wall -Wextra
LDFLAGS +=
# Arguments to pkg-config. Here are some example ones.
LIBS = egl glesv2 gbm libdrm

# Shit you shouldn't need to modify

CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDLIBS = $(shell pkg-config --libs $(LIBS))

SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)

$(TARGET): $(OBJ)

clean:
$(RM) $(OBJ) $(TARGET)

It assumes that there is a file named $(TARGET).c, so myprog.c in this situation.
>>
>>57809283
>anon's pull request to remove the CoC gets rejected
>>
>>57808596
>Why not use index method?
I couldn't find an easy way to get the index inside a list comp, although I'm sure I was looking for the wrong thing.

As for why not enumerate, I was playing around with it but I got the zip() approach to work first so I just stopped.
>>
grad CS student here
what are some essential programming projects i should complete
>>
>>57808933
well fuck me, i'm an idiot.
>>
>>57809278
Are you that C imageboard guy?
>>
>>57809358
A for loop
>>
>>57809466
yeah kinda

I rewrote it to grep for the main files instead of explicitly naming them.
https://github.com/microsounds/akari-bbs/blob/thread-mode/makefile
>>
>>57809405

>libdrm
If I hadn't googled that to find out that it has nothing to do with DRM, I would have to give you a personal ass-whooping.

>>57809436

Make a compiler.
>>
im sort of tempted to put "CS major graduate" on my resume and see if it makes a difference, im confident i can get myself a job as long as i actually make it to a interview
they dont actually contact universities to check that shit right?
>>
>>57810118

fuck off tripfag
>>
File: Capture.png (11KB, 1272x296px) Image search: [Google]
Capture.png
11KB, 1272x296px
Is it possible to make this java/android code simpler?
>inb4 stupid comments on brackets' position
>>
>>57810118
>If I hadn't googled that to find out that it has nothing to do with DRM, I would have to give you a personal ass-whooping.
Linux's direct rendering manager
>>
>>57810118
Ruby, what languages do you know?
>>
File: Screenshot_1.png (3KB, 205x288px) Image search: [Google]
Screenshot_1.png
3KB, 205x288px
Made a snek game.

Kinda confused why people keep mentioning that you should use queues and whatnot for the implementations.
A simple array storing how many ticks each part has until it disappears works just as well.
>>
>>57810147
Your brackets are misplaced
>>
>>57810147
tab1swipeToRefresh.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new UpdateAsync().execute();
}
}
)
>>
>>57810221
>tfw you'll never a simple game like this even though i'm on my 3rd year programming
>>
>>57810221

Usually it's just because the learning resources you use tries to teach you how to program in ways that would scale. Look at frameworks for programming languages and how they use super simple examples where a shorter pure javascript or php version would be simpler and better.

But even if things like frameworks or libraries are made to solve big problems or be make it simpler for many poeple to work on a huge project they still have to use simple examples to get peopel started with the tech.
>>
File: m8 wut.jpg (422KB, 907x1500px) Image search: [Google]
m8 wut.jpg
422KB, 907x1500px
>>57810251
>mfw I did touhou ripoff for android for my 2nd year project and got 80%
>mfw I hate actually programming and never touched it before starting uni
I even used the same music and sound effects.

Either you are really shit at programming and it's your fault, or your course is useless and you should request money back.
>>
>>57810295
sounds like a (You) problem
>>
>>57810195

Define "know". I've used Ada for my assignments almost exclusively for about a year, but I've forgotten most of it. Some languages I consider myself capable of reading easily, but couldn't reproduce off the top of my head if asked to. Others, I know the syntax well, but not the standard library well. Python and JavaScript would probably fit into that area, plus maybe C# and Java to a lesser extent (although I've been using them more, so have a basic grasp over the standard library). I consider myself very proficient with C, C++, and Ruby above all else.
>>
>>57810251
Welp, I'm on my 6th or 7th, so I guess there's that.
It's really not as complex as it seems at first. You just keep an array with the ticks-until-part-disappears, decreasing them at every tick.
And, every time you move, you just set the open space you're moving to to your current snek size.
If it already has a size in it, your snek is a ded snek.
The food things are just randomly placed on non-snek spots.

I don't recommend doing it in ncurses though, that, and C, are just the way I like to torture myself.

>>57810295
Not really using resources, mate.
Just watched a guy attempt, and fail, to do it in 15 minutes, in JS.
So I thought I'd do it in C and ncurses just for the fun of it, since I've had nothing better to do lately.
>>
>>57808391
>>57809036
I did get it by passing it through the other functions, now I'm just trying to figure out how I can separate the hours worked and pay rate from the names so I can use them as integers.
>>
>>57810376
How is ncurses?
How do you represent the game field?
>>
File: 1479023698525.jpg (38KB, 540x233px) Image search: [Google]
1479023698525.jpg
38KB, 540x233px
>>57810309
>tfw cant draw
>>
Advent of Code guy seems uninterested in allowing an account-less dataset. Suggests we all make fake Reddit accounts
>>
>>57810468
do it and you are forbidden from posting here again
>>
>>57810468
why dont you use your real reddit account?
>>
>>57810518
>>57810468

ruby btfo once again
back to r/mlp
>>
>>57810440
Ncurses is certainly... something...
I've made a wrapper library around it by now though, so I guess it's not that bad.

The game field's just an 15x25 int array.
Snek pieces are positive numbers that get reduced each tick.
Empty spaces are 0, and food spaces are -1, both don't get reduced, for obvious reasons.
>>
>>57810505
>>57810518

I don't have a reddit account, and can't be bothered to make one. I do have a github account, but don't feel like tying it to this shit.

>>57810537

Never been to /r/mlp, actually. Just /mlp/ and /pone/, plus a small amount of time at mlpchan.
>>
>>57810626
>I do have a github account,
post it
>>
>>57810626
wtf is pone
>>
I haven't been here in 2.5 years and the same namefags are still here lmao
>>
>>57810221
A queue storing snake will be smaller than storing state of all the grid.
>>
>>57810758
haskell
>>
>>57807030
Beginner's guide - pyhon wiki.
>>
>>57810776
Fair enough, but unless you're working in a language that already has queues, or on a massive snek based mmo or something big like that, it seems like more of a waste of time than anything else...
>>
File: wf08.png (81KB, 1301x1040px) Image search: [Google]
wf08.png
81KB, 1301x1040px
I've started rewriting some of the assembly code in Forth (although could hardly be called Forth since it's just copying machine code bytes).
But it means I can start really trimming down the asm core and get rid of all bootstrapping stuff.
Also started playing around with how I wanna do further code gen, an example of an inliner which just gets the code bytes for a word and copies them into the current definition.
I'm guessing I'm gonna need some more meta-data to do more intelligent optimizations, probably wanna annotate every word's stack effects (i.e how many items they consume vs produce).
>>
>>57810576
> I've made a wrapper library around it by now though, so I guess it's not that bad.
I want to look at it.
>>
Is A+ certification worth it anymore
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
Who was first, the function or the object?
>>
>>57811173
Function.
>>
>>57810872
>forth
What the fuck. m8 I suggest you check the current date.
>>
>>57811173
Wew
>>
I am an alligator. What programming language would be best for me?
>>
What is a good book to start learning algebra for beginners ?
>>
>>57811062
Eh, sure.
It's just boilerplate code and some simple sanity-saving stuff though.
http://pastebin.com/cPZYFhUi
>>
>>57811235
principia mathematica
>>
>>57808156
Its easy as. Once you understand pointers it's gg.
>>
For class I have to simulate a virtual memory paging scheme (not the translation, just the swapping on page faults) with various standard page replacement algorithms.

Otherwise, these days I've been focusing a lot more on sysadmin stuff than pure programming.
>>
>>57808156
Pretty much what, >>57811277 said.
It still baffles me that people even consider C to be hard, when I only use it because it's so simple and easy to keep in your head.

Maybe it's the association with the horrid mess that is C++ that keeps scaring people away?
>>
>>57808247
a binary heap is a complete binary tree tho....
>>
What's the proper way to deal with possible malloc failure in C?

Pass a null pointer through half a dozen functions back to main with each function having to check that?

Exit out of the program as soon as it happens?

Just ignore it and let the program shit itself because it's rarely gonna happen so it's not worth checking?

Everything feels bad
>>
This is just a random rant, but why isn't C's macro system recursive?
If it was, it would've been a Markov Algorithm-like Turing-complete language in another language.
My mouth waters at the mere thought of all the possible ways you could exploit that...
>>
>>57811346
Do whatever is appropriate for your program.
>>
>>57811368
It's retarded and you should be ashamed for posting such a cringeworthy sentence, let alone for thinking that's a cute idea or that it is in any way original.
>>
>>57811346
1. Is it even possible to recover -> pass it up or call a function to fix it
2. No? -> might as well kill it
>>
>>57811203
7th September 2016 was the latest Forth 200x meeting.
>>
>>57811346
Certainly never to "just ignore it because it's rarely gonna happen".
Exit out of the program because you can assume if malloc failed you no longer have a valid program state going forward.
Use http://www.cplusplus.com/reference/cstdlib/atexit/ to register a function to clean up your resources when you're exiting like a responsible programmer.
>>
>>57811173
The object. Women were around before they had a function.
>>
>>57811270
Thanks senpai
>>
>>57811173
The lambda calculus was invented before the turing machine
>>
File: 1279106080475.jpg (97KB, 389x388px) Image search: [Google]
1279106080475.jpg
97KB, 389x388px
>>57811448
>>
>>57811460
i'm kidding
>>
>>57811445
>Use http://www.cplusplus.com/reference/cstdlib/atexit/ to register a function to clean up your resources when you're exiting like a responsible programmer.

can I do so without the use of global variables?
>>
>>57808905
Don't you just love graphs that should be rotated 90 degrees, but they aren't so it's a pain in the ass to read?
>>
>>57811514
why do you think you would have to use global variables?
>>
>>57808905
>C
>C++
>Haskell
Wew
>>
anyone here a data analyst/scientist.

I've learned VBA, and i'm learning R atm.
How essential is SQL?
>>
>>57811575
Absolutely essential.
>>
>>57811573
how would I cleanup something that was allocated in main for example? how would I access that pointer if it weren't global?

or am I just being retarded right now?
>>
Say I'm writing a thread pool implementation, and I have the situation where all threads are busy, what is the best route to take?
A. Queue the job until a thread is ready
B. Synchronously execute the job immediately and return back to caller when it finished.
>>
>>57811596
how long do you think it'll take to learn SQL enough that I can put it on a resume?
>>
>>57811469
Meh what would one recommend then ?
Even online study guide would be good.
>>
>>57811645
A week at most if you have a brain.
>>
>>57811573
Because whoever designed atexit was a fucking retard and made it only take a function pointer and not at least a function pointer and void user pointer.
>>
>>57811645
Took one of the interns at work about a month to get up to speed and spit out queries that were usable with our data but they were sloppy and still required one of our other guys to clean it up and optimize them.

>>57811667
If the people who contributed to the stdlib are retarded, why haven't you taken one of their place and written some non-retarded functions?
>>
>>57811667
>>57811639

You need a global because atexit is global. There is no need for a void* because atexit has no context because it can only call the callback once.
Global variables aren't bad on their own. They are bad if you use them wrong, just like goto.
>>
>>57811709
And what if it's dynamic?
>>
https://www.youtube.com/watch?v=6-_4Uoo_7Y4
>>
>>57811720
You can only have on instance of your program running in it's memory space. It is not possible for it to be dynamic. Just store it in a (static) global.
>>
>>57811737
What if the number of times you call atexit is dynamic, I mean?
>>
>>57811463
>tfw a babby meme gives you nostalgia
>tfw nostalgia over 4chan memes
Just end me now
>>
>>57811744
Just like how if you set a variable multiple times, it only retains it's last value. atexit is the same.
>>
>>57811763
Oh, I see.
>>
For large python scripts, should I store my functions in a separate file and import them, or keep the functions in the same file as the script?

Which one is better for performance?
>>
>>57811877
It doesn' t matter for performance. If you care about performance that much you should use something that isn't python.
>>
>>57811877
Won't affect performance, but modularity is a good practice.
>>
Is it okay practice to split up something like a gigantic update method into several smaller methods, with the main one calling the others for readability?
>>
>>57811929
If it improves code locality, split it. Just keep things that operate together, together in code as-well.
>>
>>57811929
That won't really help readability, though it might help with other things.
>>
>>57811929
Yes, do that.
>>
I'm writing a java program for my intro to programming course.

It's a simple app that lets you input an amount to deposit, withdraw, and calculate simple interest.

I have a prompt that asks the user if they would like to create a new account. If the user answers 'no' the program just closes.


I'd like to display a login window if the user clicks no. I'd also like to store the username, password, and account balance in a text file. I know it sounds stupid to store that sort of info unencrypted in a text file but it's just an intro level course.

Could anybody please provide some insight to at least get me started? I've googled around and found some examples but none of them seem quite right for what I want to do.
>>
>>57812292
back in my day, intro to programming courses taught you about lambdas and shit, not apps
>>
>>57811929
just use a where. you are using haskell, right?
>>
We were given a month to write an iPhone app in Swift that updates student records in a database. That's all. An entire month.

One student wasn't able to get a single line written. He said "you wouldn't believe the month I've had!"

He got an extension.

Why are people so bad at programming?
>>
>>57812309
It's a programming course for business majors. It's pretty dumbed down and emphasizes OOP principles.
>>
>>57812309
I've never heard the word lambda in relation to programming anywhere other than here.
>>
File: 1480730759323.jpg (41KB, 400x400px) Image search: [Google]
1480730759323.jpg
41KB, 400x400px
>>57812347
>I've never heard the word lambda in relation to programming anywhere other than here.
>>
>>57812362
It's probably the other way around, tbqh
>>
I am an alligator. Which programming language would be best for me?
>>
>>57809184

CMake = I can't write plain makefiles... So i much download a bunch of crap to help me :(((
>>
>>57812347
then you're a codemonkey. google search lambda calculus you memelord
>>
What are the best strategies for getting up to speed with a huge codebase fast? Anything besides reading the files one by one starting in the root directory?
>>
>>57812411

must*
>>
>>57812412
Not in my c, Ada, VHDL, or verilog. It can go fuck itself.
>>
>>57812433
Yep, codemonkey confirmed.
>>
Got offered an unpaid internship at a startup. How JUST is this?
>>
>>57812471
give more details

what language

what are you going to do etc
>>
Is there a way to get just integers from a string in python without using regex or .join
>>
>>57812471
Refuse it.

CS is one of the few fields where interns are still paid. Don't let them change that.

Anyone doing an unpaid internship in this field is an incompetent cuck.
>>
>>57812433
t. codemonkey
>>
>>57812498
It's impossible. Python is the new Perl.
>>
>>57812448
Stay mad about your useless meme
>>
>>57812517
Fuck my life then.
>>
>>57812518
You mean the useless meme that got me my job, and that I use every day?

These days, C stands for Cuck. Nobody needs C programmers any more. It's all going to C++ and Rust. Both of those have lambdas now.
>>
File: 1478132750140.png (624KB, 484x734px) Image search: [Google]
1478132750140.png
624KB, 484x734px
>>57812347
This is the most pathetic display of pajeet I've ever seen
I don't even have a proper education in programming and I use lambda expressions daily. And I work in fucking C#.
>>
>>57812494
This is their site.
http://www.testgrid.io

Writing test cases for their clients is what I was told. They wanted knowledge in java, c, obj c, swift, but the girl who interviewed me was a girl who I'm pretty sure has little programming knowledge.
>>
>>57812545
Income if you take it: $0
Time lost if you take it: 40+ hours a week
What you can put on your resume after taking it: "I am a cuck who will work for free"

Income if you don't take it: $0
Time lost if you don't take it: 0 hours a week
What you can put on your resume after not taking it: ""
>>
>>57812545
>Delivering Greater Efficiencies To Agile Teams Through Increased Collaboration, Smarter Tools, Cloud Innovation, and Intelligent Insights.
Buzzwords: the company
>>
>>57812545
>Unpaid
>Testing
>Need to know four languages
Tell them to fuck off until they give you a paycheck.
>>
>>57812543

C# best.
>>
>>57812559
I work another job and they told me that I could do part time. Definitely planning on telling them to shove it.
>>
>>57812563
Idris > Haskell > Scala > OCaml > F# > Rust > C++ > C# > Java > Python > JavaScript
>>
>>57812563
>implying
>>
>>57812604
>Scala
>Anywhere near the front
>>
>>57812614
It has dependent types and higher-kinded types, implemented better than the languages below it.
>>
>>57812618
i saw today a job offering and the guy has looking for Scala guys

what can you do with scala?
>>
>>57812604

Utterly incorrect.
>>
>>57812626
Make $300k starting
No wait, that's Haskell
>>
>>57812563
C# is comfy but can be kinda slow.
And if you don't know what you're doing (e.g. literally everybody using unity to make games) it comes out as bloated slow shit.
>>
>>57812626
It has good interoperability with Java, which a lot of companies like because they have lots of Java code and/or lots of people who only know how to use Java.

It has enough advanced features to keep programmers who are
>to intelligent for Java
from going insane for a while.
>>
>>57812618
Scala managed to turn FP into Java
>>
>>57812618
>It has dependent types
>>
>>57812636
Are you upset because it's the only language you know?
>>
>>57812656
I'd much rather write Scala than write Java all day.
>>
>>57812650
is Scala scalable?
>>
>>57812694
No, it's not stack-safe.
>>
>>57812563
C++ best
>>
>>57812706
Rust > C++
>>
>>57812677
I'd much rather write Haskell than Scala all day
>>
>>57812736
That's the dream.
>>
>>57812639

>can be kinda slow
It's about as slow as Java, and it has a few optimization options over Java, so it's not terrible.
>>
>use Java
>anything not primitive goes on the heap
>nearly every operation requires at least one pointer dereference, probably more
>>
>>57812761
fuck you talking bout?
>>
>>57812770
Here we see the common Pajeet floundering when confronted with reality.
>>
>>57812782
nah bruh, take nerd shit is for you

i make money from ma youtube videos

keep it real tho
>>
>>57812809
I doubt that.
>>
File: 1452831938935.jpg (42KB, 327x316px) Image search: [Google]
1452831938935.jpg
42KB, 327x316px
>Scala "dependent types" are actually just singletons exactly like Haskell has
>>
>>57812827
>someone who doesn't know scala showing his ignorance
>>
>>57812832
what does Scala "dependent types" even mean?
>>
>>57812832
Do something with Scala's so-called dependent types that I can't do in Haskell.
>>
>>57812844
functions from values to types
>>
>>57812761
>anything not primitive goes on the heap
>nearly every operation requires at least one pointer dereference, probably more

Pointer dereferencing is cheap. You don't even understand the performance costs of heap-allocation.
>>
>>57812844
trait A {
type T
}
>>
>>57812471
>cs internship
>unpaid
wew
>>
>>57812847
>Do something with Scala's so-called dependent types that I can't do in Haskell.
I can get a job.
>>
Vote for me as president of /dpt/ and i'll delete Scala from history along with lisp and any other FP based languages.
>>
>>57812847
>>57812901
rekt
>>
New thread: >>57812957
>>
Itt: code monkeys calling others code monkeys.
This place needs to be gassed.
>>
>>57812668

I actually know a handful of languages, but I prefer C#
>>
>>57813060
Why?

Asking honestly, I tried C# (admittedly quite an old version now) and it didn't seem much better than Java.
>>
>>57810147
The whole "Let's use interface implementations to simulate lambdas!" style pioneered by Google is disgusting.
>>
I want to make something that uses brute-force to find the function that produces a given output from a given input, but I worked out that it would lose efficiency very fast as it tested longer functions, since the longer a function is the more redundant rearrangements of it there are.

What's a computationally inexpensive way to make sure I only test unique functions and none of their aliases?
>>
Pajeet here. Testing something ignore this post.

class Formulas {

double crit = 0, health = 11645;

public void setCrit(double x) {
//Critical Chance = (Precision - 895) / 21
//https://wiki.guildwars2.com/wiki/Precision
this.crit = (x - 895) / 21;
}

public double getCrit() {
return crit;
}
public void setHealth(double x){
//The character's Vitality, providing 10 points of health per point of Vitality.
this.health = this.health + (x*10);
}
public double getHP() {
return health;
}
}
>>
>>57814056
*ignores this post*
Thread posts: 321
Thread images: 36


[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.