[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 37
File: shig pee.jpg (133 KB, 960x624) Image search: [Google]
shig pee.jpg
133 KB, 960x624
Old thread - >>52297205

What are you working on, /g/?
>>
File: 1430382295434.gif (773 KB, 285x228) Image search: [Google]
1430382295434.gif
773 KB, 285x228
>>52304354
first, suck it faggots
>>
File: ;D.png (57 KB, 800x334) Image search: [Google]
;D.png
57 KB, 800x334
What's the best programming language and why is it D?
>>
How to you feel when you see an imperative monkey trying to show off his shit register-juggling language?

Amused?
Pity?
>>
>>52304432
Triggered
>>
>>52304432
>register-juggling

No one needs to care about this nonsense.
>>
File: 1353264807771.jpg (26 KB, 530x353) Image search: [Google]
1353264807771.jpg
26 KB, 530x353
>>52304405
are you importing libraries inside of functions...
>>
File: le lol over lisp.png (162 KB, 571x307) Image search: [Google]
le lol over lisp.png
162 KB, 571x307
>>52304432
How do you feel when you see a Haskell monkey trying to work around the restrictions of his shit blub language?

Amused?
Pity?
>>
>>52304502
do you use variables inside of functions
>>
>>52304521
this was more of a question than a debate and honestly I have never seen that done before. What are the benefits/drawbacks of doing something like this?
>>
>>52304508
How do you feel when you see someone that isn't programming in ocaml or a derivative of it?

Amused?
Pity?
>>
>>52304508
How do you feel when you see a lisp monkey sweat noticeably upon realizing he mismatched a parentheses pair somewhere in the body of his function?

Amused?
Pity?
>>
>>52304530
Locality of everything imported, potential compilation speed
>>
>>52304301
Ah, but foldl is a derivative of foldr.
foldl f z xs = foldr step id xs z 
where step x g a = g $ f a x
>>
>>52304533
Emacs takes care of that.
>the greatest criticism of lisp that blubfags can shit out is "muh parentheses"
LOL indeed. Feels good to code in the best language.
>>
>>52304558
>implying
>>
>>52304574
How do you feel when you see an emacs monkey wince noticeably from the carpal tunnel syndrome he's rapidly developed since he decided he was too much of a special snowflake for vi?

Amused?
Pity?
>>
So... apparently Rust's "panic!" macro generates a ud2 instruction on x86-64 (literally an undefined/illegal instruction). It also generates a function called _ZN10sys_common6unwind12begin_unwind21h17424040669044986343E that it does not even call.
>>
File: stallman spurdo.png (89 KB, 680x433) Image search: [Google]
stallman spurdo.png
89 KB, 680x433
>>52304595
I shiggery didgeridoo.
>>
>>52304626
for use in NLP bindings.

Feminism and all that. Hivemind flags. It's probably why Terry Davis went from bad to worse to realizing he doesn't need to give a shit because it's just stupid women misusing yet another thing

Also, hi Ruby!
>>
I need to learn C, what's the best way to learn it??
>>
>>52304650
Read K&R, then pick up the changes in C99/C11 from their respective Wikipedia articles.
>>
>>52304650
K & R C. Buy it, read it, learn C.
>>
>>52304650
K&R
>>
>>52304650
C The Hard Way. Ignore anyone who recommends K&R as it's outdated and teaches bad practices.

>>52304658
>Telling a beginner to read coding standards

Jesus fucking Christ.
>>
Literally was just coding a tic tac toe game using object oriented paradigms.

I stopped half way through because it was mind numbing
>>
>>52304650
>>
>>52304665
Kill yourself, Zed.

>>Telling a beginner to read coding standards
He didn't say his experience level. I assumed he isn't an absolute beginner. Also I said to look at a Wikipedia article, not read the standards themselves.
>>
>>52304676
Do you not see the fucking problem here?

But if you actually do want to learn C++, don't bother with C first.
>>
>>52304650
Don't read K&R
>>
>>52304639
>install trisquel
ftfy
>>
>>52304698
Better yet, don't learn C.
It's harmful as fuck.
>>
>>52304626
Generally speaking, anything iShit dishes out is going to be riddled with fem-friendly "advocacies" and women are generally going to take to them as the means to relay more and more subversive methodologies. I believe Stranger Danger picked up around the time the first iPhone was created if I'm not mistaken.

I only know this now because I had a child of my own and his mother is taking to things this way. He's too young to be concerning himself with these things so we've managed some work arounds between the two of us. Don't know why I felt like telling you that. Of course, btw, I could be wrong about all of this and it's his mother and her feminist socialist groupie tumblrina crew fucking with me.
>>
>>52304712
>>52304645
How you doing today buddy?
>>
File: b8a.jpg (20 KB, 495x495) Image search: [Google]
b8a.jpg
20 KB, 495x495
so, are std::vector insert and erase optimised for primitive types? it just says linear complexity.

do i have to maniually resize and std::copy?
>>
>>52304676
>>52304689
I really need to learn C for this semester, and the next one is for C++
>>
File: 1450354826559.jpg (56 KB, 640x696) Image search: [Google]
1450354826559.jpg
56 KB, 640x696
>>52304719
>>
>>52304727
Going to a school that does things in this outdated way must suck. But C is actually not very hard to learn.
>>
>>52304732
Alright take it easy man.
>>
>>52304432
What? Haskell doesn't use registers?
Garbage language lol.
>>
Should I learn assembly?
>>
Guys, what's a good book on program structure in OOP?

I need things like how to structure and design programs.
>>
>>52304764
No
>>
>>52304765
Google Gang of Four OOP
>>
>>52304354
thank you for doing your part in preventing trap proliferation
>>
File: 1445509350207.jpg (201 KB, 436x600) Image search: [Google]
1445509350207.jpg
201 KB, 436x600
>>52304748
>>
>>52304650
http://speakspeak.com/resources/pronunciation/when-to-pronounce-the-letter-c-as-s-or-k
>>
>>52304765
Try looking into a UML design book

>>52304771
Gonna check this out myself. Hadn't heard of it til today. Thanks anon.
>>
>>52304771
Thanks anon, much appreciated.
>>
>>52304784
did he died?
>>
>>52304770
Why not?
>>
>>52304764
Yes. It'll teach you the nitty-gritty details of how languages like C works, with shit like the stack, calling conventions etc.
You'll probably never write anything non-trivial in it, but I still think that understanding assembly will make you a better programmer.
>>
>>52304802
I hope not
>>
>>52304840
A stream interpreter might be short and non-trivial. Especially for secure communications.
>>
>C++ is a good language



return
{
{
vect[0].x * sOther.vect[0].x + vect[0].y * sOther.vect[1].x + vect[0].z * sOther.vect[2].x,
vect[1].x * sOther.vect[0].x + vect[1].y * sOther.vect[1].x + vect[1].z * sOther.vect[2].x,
vect[2].x * sOther.vect[0].x + vect[2].y * sOther.vect[1].x + vect[2].z * sOther.vect[2].x
},

{
vect[0].x * sOther.vect[0].y + vect[0].y * sOther.vect[1].y + vect[0].z * sOther.vect[2].y,
vect[1].x * sOther.vect[0].y + vect[1].y * sOther.vect[1].y + vect[1].z * sOther.vect[2].y,
vect[2].x * sOther.vect[0].y + vect[2].y * sOther.vect[1].y + vect[2].z * sOther.vect[2].y
},

{
vect[0].x * sOther.vect[0].z + vect[0].y * sOther.vect[1].z + vect[0].z * sOther.vect[2].z,
vect[1].x * sOther.vect[0].z + vect[1].y * sOther.vect[1].z + vect[1].z * sOther.vect[2].z,
vect[2].x * sOther.vect[0].z + vect[2].y * sOther.vect[1].z + vect[2].z * sOther.vect[2].z
}
};
>>
>>52304645

Hello, Anon. Sorry I cannot stay, but I have to be up in less than six hours.

And yeah, whoever is managing the creation of this language does indeed have a few screws loose. Try compiling a static library with it. Just one use of panic! makes it throw in everything plus the kitchen sink. And yes, that includes the networking libraries. Why? Because why the hell not?

I may just end up defining my own error function that will just print what I want and call exit().
>>
>>52304885
I hate to defend Meme++ in any way, but whoever wrote that should just use a macro and it would make it look very clean.
>>
>>52304889
Just use C then you fuck. Rust is like that for very specific reasons (which you should know since you're learning it)
>>
>>52304899
I did, and as much as I'd like to I think I'd lose marks for it
It's for coursework

I'd do a neat version doing something like a fold or a map or something, but then it wouldn't have the same performance (even though it theoretically could)
>>
>>52304926
>I think I'd lose marks for it
What? Why on earth would you lose marks for not making your code stupidly long?
>>
/dpt/ what's the dumbest thing you've ever done while debugging, I'll go first with what I just fucking did.

I added a pause state for my game that, believe it or not, would pause the game when you pressed the Pause key.

Long story short, it worked fine, then suddenly after handling some other semi-unrelated code, my pause state wouldn't stick, it seemed to pause and then unpause straight away, like a stutter.
It only seemed to work when I held it down, but after releasing the game would look like time passed instead, like the game kept updating through the pausestate which was supposed to be impossible.

About 20 minutes later I release I was pressing the print screen key instead of the pause key.

Of all the fucking keys on the keyboard that could give a buggy looking pause state error, it would be that key.

Any one else have any stories? This was so dumb I had to share it, maybe someone else wants to share a similar experience?
>>
>>52304540
nope

you're just a retard.
>>
What are my nimfriends making right now?
>>
>>52304860
i looked it up and it's a talking CGI bird from a shitty movie
>>
>>52304936
A lot of C++ people and OO people and 'idiomatic code' people don't like macros
Module leader is a fan of idiomatic c++ OO code
Will check though

>>52304966
That's literally what it does though

Compilation can be faster (depends on the compiler) because anything outside of the function doesn't need to check the local symbols

Locality is obviously good for the same reason local variables are good
>>
>>52304915

For very dumb reasons! A language designed on the principles of "you don't pay for what you don't use" should not add in so much junk to an executable that can be guaranteed to never be reached. And no language, under any circumstances, should generate an illegal instruction, especially as a way to terminate a user process. I can see some uses for the instruction in kernel level code as Linux uses it (Linux uses ud2 in inline assembly where there's a bug to completely shut down the kernel), but in userland code, it has no place.
>>
>>52304996
Fucking C++ memers, thinking they're too good for C and anything that comes from C. Some of them even have the audacity to call C++ a superset of C.
>>
>>52305009
I'm very glad someone who knows more than the Rust designers is among us. Any more insight would be appreciated.
>>
>>52305012
They don't hate macros because they're from C
>>
File: 1451860435462.png (354 KB, 600x700) Image search: [Google]
1451860435462.png
354 KB, 600x700
>>52304885
use glm, you fucking retard. how do you even imagine a language that doesn't use any libraries?

there's also some other linear math library, whatever the fuck it's name, but glm's compatible with ogl.
>>
>>52305083
this fucking retard is doing coursework and not wanting to lose marks for using lots of other peoples' work
>>
>>52304354
So in C# in VS on a WPF Canvas, how do you detect collison between two rectangles?

I am trying to make a game of snake and I was able to detect collision on the border of the window, but I cannot figure out how to detect collision between my snake and a rectangle.

Anyone help me out?
>>
File: 1451851649542.png (55 KB, 419x248) Image search: [Google]
1451851649542.png
55 KB, 419x248
>>52305102
why won't he write a vector class that isn't total shit then?
>>
>>52304966
not him but all it does is read from file real quick and add it to the dependency list...unless the function is called hundreds of times and there are synchronization issues, the code will run fine.

I can't immediately come up with any bad habits one might pick up from this besides issues with buffers and perhaps making for dips in performance where performance is key, like in games.
>>
>>52305103
>WPF Canvas,

> how do you detect collison between two rectangles?

Probably manually, since you're using a canvas, right?

Not that I know anything about WPF, but generally the "canvas" idea is just to give you, effectively, the direct ability to draw in an area, pixel-by-pixel.
>>
Someone make a new thread quick, the trap boogeymen are gonna beat us!
>>
>>52305137
I dont know dude I am pretty shit at programming.

How would you do it in a regular window then? Also what do you mean by manually?
>>
>>52305116
>vector
>>
>>52304354
reject the false mascot stallman.

Jerry Sussman, author of SICP is the one true mascot of /g/
>>
>>52305192
We need a /prog/ board tbqh desu
>>
>>52305210
no

we need a /phi/ board
philosophy, logic and mathematics
(that includes programming)
>>
File: keep calm.png (314 KB, 448x630) Image search: [Google]
keep calm.png
314 KB, 448x630
>>52305148
Why are you using WPF for a game? You've got XNA, or even Unity which has built in collision detection.
>>
>>52305103
by manually he means check for an intersection between x1, y1 and x2, y2.

[0][0][0][0]
[0][0][1][1][0][0]
[0][0][1][1][0][0]

Here there are two rectangles a 4x3 and a 2x4 and they intersect at the points marked with [1].
To check this manually you would take a point at any of the corners and check if it shares an x and a y with the other rectangle.

if it shares an x it could just be below or above but if it shares both an x and a y it is over-lapping at some point. If you need to find the rectangle/square of intersection, you would just need to find all points that share x and y across the top most row and then repeat the process on any column rows that happen to also share a y, with special consideration to x values that were shown to be overlapping.

so you go across from the the point that shares an x and y and note the number of points across from that point
apply the same process over time and increase y at each time interval
>>
>>52305223
I think they've made it so that philosophy falls under the humanities banner and that board exists after a tyrade on the science boards. lol.
>>
>>52305148
>How would you do it in a regular window then?

I have no idea what you're asking. WPF is a framework for building business applications, not games.

> Also what do you mean by manually?

I mean you're using a canvas. It's roughly equivalent to working directly with video memory. You don't have any libraries to support what you're trying to do.

You should either use some babby gaming library or start reading books on advanced concepts like efficient collision detection.
>>
>>52305271
errr the x1 y1 x2 y2 deal might be off, heh

I meant to infer that one of the corners belongs to an object 1 and the other corner belongs to object 2. Sorry if this was more confusing than helpful.
>>
>>52305309
hotspot collision detection makes me so hot
>>
File: 2016-01-08_12-19-21.png (10 KB, 521x154) Image search: [Google]
2016-01-08_12-19-21.png
10 KB, 521x154
>>52305137
I think this works
>>
Is SICP any good or is it just a meme?
what books do I need to read before I'm a pro?
>>
>>52305210
We had prog and it sucked shit
>>
>>52305326

I don't think that works at all.

Also, X, Y, Right, Bottom are horrible names.

Either x1,y1,x2,y2, or a.x,a.y,b.x,b.y, or left, top, right, bottom, or left, top, width, height.
>>
>>52305391
way better than /g/
>>
>>52304885
Does C++ not have function pointers? You can easily write this with a few maps and folds.
>>
>>52305401
You weren't even there
>>
File: 1.png (139 KB, 1920x1080) Image search: [Google]
1.png
139 KB, 1920x1080
>>52305394
It's the built in rectangle of XNA.
>>
>>52305309
Well, unfortunately for me, this assignment is due in 5 hours and we have to use WPF application in Visual studio to do it.
>>
>>52305423
I considered doing that but I'm not sure if it would be optimised very well

If the performance is good (I don't need amazing performance, it's a simple project) I'll do that
>>
>>52305394
It works and I think x, y, right and bottom work well for what the particular utility calls for. That is to say that a rectangle does not account for intersections, some kind of event handler would, and in handling events it specifically looks for a certain set of circumstances to occur. If it can be sure that only the right and bottom are necessary for placing the one rectangle in reference to the other's draw point then the handler need not be so "informed". What would it do with all that superfluous info? It'd be wasting space.
>>
>>52305429

So it has X, Y, and Left, Top? WTF?

Anyway, make it readable. Be consistent.
>>
>>52305461

The first line makes no sense.

If (rec.Bottom < other.Y)

which I assume is equivalent to (rec.Bottom < other.Top).

Maybe your coordinates are all fucky, but that logic is bad.

You're going to have to be doing comparisons to, for example, X + width. You can't test for collision by looking only at each X, Y, right, left.
>>
File: 2016-01-08_12-39-38.webm (209 KB, 800x450) Image search: [Google]
2016-01-08_12-39-38.webm
209 KB, 800x450
>>52305394
And I'm pretty sure it does work senpai.
>>
>>52305523
they clearly aren't colliding

the smaller one is clearly in front of the larger one
>>
File: una vela.jpg (195 KB, 983x1013) Image search: [Google]
una vela.jpg
195 KB, 983x1013
>>52305523
NOW TRY AND MAKE THE SMALL BOX BOUNCE OFF THE BIG BOX WITHOUT LOOKING UP HOW TO DO IT PROPERLY THEN POST CODE
>>
File: 1389081724281.gif (2 MB, 150x173) Image search: [Google]
1389081724281.gif
2 MB, 150x173
>>52305518
Right is a property that calculates X + Width, you'e just embarrassing yourself.
>>
File: rectangle.png (9 KB, 737x340) Image search: [Google]
rectangle.png
9 KB, 737x340
>>52305518
Look at it for yourself.

Also, please note that drawing to screen implies that 0, 0 starts at the top left hand corner and not be the bottom left hand corner like on a cartesian grid.
>>
>>52305622
sorry about that "be" in there. It wasn't me. Probably some CIA nigger.
>>
File: 1452231770341.jpg (20 KB, 600x338) Image search: [Google]
1452231770341.jpg
20 KB, 600x338
>>52305518
you right now
>>
File: jkhjhkjh.jpg (23 KB, 418x202) Image search: [Google]
jkhjhkjh.jpg
23 KB, 418x202
I'm not familiar with graphical stuuf and I have to learn it (I know it's easier with NetBeans but I don't have the choice).

I fucked up several times in my code but I don't know where. Here's how it goes.


import javax.swing.*;
import java.awt.*;
public class Labo13 extends JFrame
{
public Labo13 ()
{
Container c = this.getContentPane();
c.setLayout(new FlowLayout());
JPanel pan1 = new JPanel();

setSize(600,300);
setTitle("Application Zougataga");

ButtonGroup groupe = new ButtonGroup() ;
JRadioButton sMR = new JRadioButton("Monsieur");
JRadioButton sMD = new JRadioButton("Madame");
groupe.add(sMR);
groupe.add(sMD);
pan1.add(sMR);
pan1.add(sMD);

JLabel mag = new JLabel("Magasin");

JTextField nom = new JTextField(8) ;
JComboBox ville = new JComboBox();
ville.addItem("Bruxelles");
ville.addItem("Mons");
ville.addItem("Namur");
ville.addItem("Liège");

JButton enr = new JButton("Enregistrer");
JButton suprr = new JButton("Supprimer le client");
JButton vider = new JButton("Vider la liste");

JTextArea txt = new JTextArea(10,10);

this.getContentPane().add(pan1, BorderLayout.NORTH);
this.getContentPane().add(nom);
this.getContentPane().add(mag);
this.getContentPane().add(ville);
this.getContentPane().add(enr);
this.getContentPane().add(txt, BorderLayout.WEST);
this.setVisible(true);

}

public static void main (String args[])
{

Labo13 lab = new Labo13();
}

}



If someone would be kind enough to explain me what it lacks or what's retarded about this, I would be glad.
>>
>>52305753
Mostly the fact that you're using Java over C#.
>>
>>52305775
Being this cucked by microsoft.
>>
>>52305753
wait, what's wrong with it?
>>
>>52305781
Couldn't care less about microsoft, but the language is just a joy working with.
>>
>>52305781
Microsoft is love
Microsoft is life

F# is best lang
>>
Can some explain to my retarded ass why this wouldn't work as hit detection between two rectangles? This is on Visual Studio using C# WPF application

Left is the SetCanvas left for my snake and the height is the left for the food

 // Statements that detect hit collision between the snakeHead and food
if (left == randomFoodSpawnHeight)
{
foodEaten = true;
}
>>
>>52305753
It looks to me like it could use a little bit of grey poupon!

don't forget to allow it to exit on close. Aside from that, I dont' really know what you're trying to do with it so I can't say much more beyond exit on close.

If it's a program for pracitcing using swing gui tools, why not make one that swaps out panels using the layered pane?
>>
>>52305800
It's fairly unlikely that they'll be exactly equal, unless they have an offset that's a multiple of their step (i.e. if they move by 3 each time, be 3K apart)
>>
>>52305785
Nothing is at the right place.
Even the NORTH, EAST thing I used does nothing since when I change the size of the window everything is just side by side.

>>52305775
Like I said I don't have any choice. And I like Java anyway.
>>
>>52305821
Funny you say that since the left does moves by += 3 and -= 3. So if they aren't exact, how do I go about doing this?
>>
File: rterere.jpg (22 KB, 985x393) Image search: [Google]
rterere.jpg
22 KB, 985x393
>>52305812
Well I just have to reproduce exactly the picture I posted.
Here's what I have when I run it (I change the size of the window and didn't add al the buttons but it's already a mess).
>>
>>52305800
It could be that maybe your snake takes steps that set it over the tile offset, it could be that your code implies that simply landing on a tile in the same column row would mean it has eaten even though it would have to land on the same point to do so...

Really, there's a lot of things it could be.
>>
File: lisp_koans.png (63 KB, 1366x768) Image search: [Google]
lisp_koans.png
63 KB, 1366x768
>>52304354

Currently going through the Common Lisp Koans

See https://github.com/google/lisp-koans

(LOOP
(PRINT
(EVAL
(READ))))
>>
File: 1383063871592.gif (2 MB, 295x211) Image search: [Google]
1383063871592.gif
2 MB, 295x211
>>52305800
Yfw 10 lines of code have 20 lines of comments.
>>
>>52305799
To bad Microsoft doesn't give a fuck about what you use F# for, It's literally a language developed for their purposes only.
>>
what am i doing wrong? Im trying to find the largest number in an array

var nums = [56, 34, 67, 435, 38];
var largest = null;

for (x = 0; x <= nums.length; x++) {
for (y = x+1; y <= nums.length; y++) {
if (nums[x] >= nums[y]) {
largest = nums[x];
}
else {
largest = nums[y];
}
}
}

console.log(largest);
>>
>>52305192

Sussman is awesome.
>>
>>52305899
>Running Emacs in a terminal
But why
>>
>>52305925
for(x=0; x < length)
if(largest < nums[x]) largest = nums[x];

It feels like the thread is filled to the brim with highschool students. I don't like this.
>>
Hello guys, I have a short problem, i'm programming in Python and I'm using a forLoop but it don't works correctly, or maybe I'm doing wrong.
I have a list with True or False values, my loop is looking on the list and it has to tell me if the value is True or False, it's okay with "i" but "i-1" always tell me it's False, here is this part of the program :

for i in range(len(quadrillage)):
voisines = 0
if i!=0:
#To not read the last entry of the list
if quadrillage[i]:
voisines=voisines+1

Then i return voisines and it always return 0 instead of 1 if i-1 == True.
>>
>>52305955
YEAH FUCK PEOPLE TRYING TO LEARN HOW TO PROGRAM
>>
>>52305985
No, but it's a shame when those are the only things being discussed here.
>>
File: lisp_koans_xorg.png (164 KB, 1366x768) Image search: [Google]
lisp_koans_xorg.png
164 KB, 1366x768
>>52305954

Switching windows in screen is handy.

Actually emacs is running as a daemon process, so that's just a terminal window, I could be using an X window as well.
>>
>>52305997
>>52305985
Since we're talking about it, anyone to help me with my problem ?>>52305852
>>52305753
>>
I'll never figure out why my horse shit programs get so popular

https://github.com/Codeusa/SteamCleaner
>>
>>52305903
Yeah, every time I get stuck I just start writing comments to try and think through how it is supposed to work.
>>
>>52306035
And then you rename your shit to be self explanatory, and delete most of the comments? Right? ;(
>>
>>52304595
>wut is godmode

but desu i have dequervains syndrome(wrist tendonitis), but thats not from emacs, thats i think from me lying down on the bed, putting the laptop on my tummy and fapping. my wrists hurt from the weird angle i have to type.
>>
>>52306049
my life desu
>>
>>52305955

i still cant figure it out. I guess its true not everyone can program because i cant logically think this through. It's like my brain just comes to a screeching halt. I'm going to google it.
>>
>>52305969
I've done a dozen of tests and : It always works for i+x, it works for i-0, it don't work for i-x (x!=0)
>>
File: why.png (86 KB, 627x309) Image search: [Google]
why.png
86 KB, 627x309
>>
>>52306129
write out your algorithm in proper writing:

set max to the first element of the list

for every element in the list:
if the element is bigger than max:
set max = element
>>
>>52306154
When is this from though? ROR has been going out of fashion it feels like.
>>
>>52306154
>know 5 of these
Where's the $$$$$
>>
>>52306170
RoR is probably highly paid for the same reason as COBOL

java or python/django is where it's at
>>
>>52305753
>>52305852
Don't forget to call the constructor to the super class?

Btw, I tried to run some code I know runs correctly and my compiler wasn't having it. It threw a few problems at me, the same problems I'll have you know, for several programs attempting to use awt and swing.
>>
>>52306170
probably bullshit
the description contains
>3,500 courses unlimited and online.

>Start your 10-day FREE trial now: https://www.pluralsight.com/a/subscri...
https://www.youtube.com/watch?v=qz8zIlnxjvc
if you want it

there's apparently a source hidden behind youtube's play bar thing and I can't be bothered putting myself through the seven circles of hell pausing and rewinding a dozen times to transcribe it
>>
>>52306129
var nums = [56, 34, 67, 435, 38];
var largest = 0;

for(x = 0; x < nums.length; x++)
{
if(nums[x] > largest) largest = nums[x];
}
console.log(largest);
>>
>>52306203
>seven
fuck
>>
how many programming languages do you know?

I feel like nowadays everyone knows a billion languages and it's impossible to keep up. I know python, java and C and would say I'm very competent in them (I've written a tonne of code in each of them) but it takes me quite a long time before I master the ins and outs of a language and can say I know it.

Are people just bullshitting about this or am I just slow?
>>
>>52306129
You're a female aren't you? That's literally what most of the girls used to say in my class.
>>
>>52306227
Knowing the syntax and some classes of the core lib of a language is what people usually mean when they say they know a programming language.
>>
>>52306129
if it helps to use your hands, do it. For example:

the largest item goes in my left hand.

I pick up the first item in this arbitrary array. As it is, this item is the largest.
I check if the next item is larger than the item in my left hand. If it is then I drop the item in my left and using my right I put the new largest item in my left hand. Else I continue traversing through the array.

Now go back and replace left hand for a variable called largest and right hand for arr[i ].

Most sorting algorithms can be figured out using two hands in this way. You are over-complicating it for yourself. Fuck the rules. Just make money, smoke trees and don't worry about fucking bitches. .
>>
>>52306159

i did it thanks bros

var nums = [56, 34, 67, 435, 74, 654, 45353, 38];
var largest = nums[0];

for (x = 0; x <= nums.length; x++) {
if (nums[x] >= largest) {
largest = nums[x];
}
}

console.log(largest)
>>
I want to extract some loud and sudden noises from very long audio recordings. I don't want to do it manually because it would take too much time and because those noises aren't easy to find by just looking for them in Audacity.

Is there any Python framework that I could use to somehow analyze and manipulate the audio? Like OpenCV but for audio.
>>
>>52305753
Just so you know, the radio buttons, textfield, label, combo box and enregister button are all on North. The text area is in center. The other two buttons are also in center.

I think so anyway.

Try not extending the JFrame class and instead just create a JFrame variable and modifying that to fit your needs. It does what you need it to do that way and then allows you to call the SwingUtilities.invokeLater() function to allow it to redraw correctly.
>>
Where can I learn functional programming?
also why should I learn functional programming? I'm told I should, but not why?
>>
>>52306227
C++, C#, Javascript
In a pinch I can do C, but it's not great quality code
>>
>>52306441
cause then you can do things as you would explain them to another person, without the "need" for serious abstraction.

So, after you've implemented your functions you can simply say

Subtract( these two numbers )
Take the result of subtract( these two numbers ) and multiply( subtract( these two numbers ) by 7 )

calculateWeeks( multiply( subtract( num, num ), 7 ) )

It basically allows you to omit certain convolutions you'd find in procedural code by allowing to split the processes at points more in tune with natural language over the abstracted version presented by the "blank slate" of the memory map.
>>
>>52306537
err...calculateWeeks is more informational.
It might look more like

calculateWeeks( num, num )
and then apply num, num as it was in the function declaration.
>>
>>52306391
Reading raw PCM data isn't that hard. Use a library that will load a WAV file into memory, and you can just go through the samples.
libsndfile is one for C, so there is probably a python wrapper for it or some other library you can use.
You may want to do some sort of Fourier Transform on it though, because the amplitude at different frequencies will appear louder to humans. e.g, The same amplitude will sound a lot louder at 2KHz than it does at 20KHz.
>>
>>52306627
There's always sox on bash.
>>
night dpt

It was nice talking to you all again. It had been almost a week since I last logged on.
>>
>>52306537
yeah but I read functional code and it's just a jumble of weird ascii art arrows and shit with variable names randomly thrown in the middle

what the fuck is closure and anonymous functions and delegates?
I just need a good book on it, or a youtube video or some shit

is there a good statically typed, bracketed language that I can learn functional in? I know about D, but there's fuck all in the way of tutorials out there
>>
File: logocaml.gif (5 KB, 375x352) Image search: [Google]
logocaml.gif
5 KB, 375x352
>>52306667
Try OCaml with that book
http://caml.inria.fr/pub/docs/oreilly-book/index.html
>>
Is it true that in America people you don't know just randomly talk to you like they're your friend?
>>
>>52307045
Yes. When I was there about 8 years ago, that did happen to me a few times.
>>
>>52307074
super weird
>>
>>52307074
>>52307110
Yeh weird as hell
>>
Is there a way to save images to a specific folder using JavaScript in a chrome extension, /dpt/?

I can't seem to find anything about it.
>>
is there a way to execute SQL queries in somekind of "safe" mode? (no modifications allowed, only reads)
preferbly without using roles on the db itself
im adding a statistics tool to the company website which is basically just a wrapper for basic SQL queries that are saved in code/on db
>>
Is it true that in Europe you get semen rations delivered to your door every morning?
>>
>>52307267
maybe
>>
>>52307267
yes
>>
>>52307267
no
>>
>>52307267
no
>>
>>52305083
>calling someone a retard while posting an anime pic
now i've seen it all.
>>
>>52307267
i don't know
>>
File: sponge.png (5 KB, 730x730) Image search: [Google]
sponge.png
5 KB, 730x730
#!/usr/bin/env python

import turtle

length = 729
level = 5
speed = 0

def square (level, length):
# heading = turtle.heading ()
# position = turtle.position ()
if level == 0:
for i in range (0, 4):
turtle.forward (length)
turtle.left (90)
else:
for i in range (0, 4):
square (level - 1, length / 3)
turtle.penup ()
turtle.forward (length)
turtle.left (90)
turtle.pendown ()
# turtle.penup ()
# turtle.setheading (heading)
# turtle.goto (position)
# turtle.pendown ()

def center (length):
turtle.penup ()
turtle.right (90)
turtle.forward (int (length / 2))
turtle.right (90)
turtle.forward (int (length / 2))
turtle.left (180)
turtle.pendown ()

def main (speed, level, length):
turtle.speed (0)
turtle.hideturtle ()
center (length)
square (level, length)
turtle.mainloop ()

main (speed, level, length)
>>
>>52307361
>it's not a fractal
>it repeats two lines of code once
>it's in python
>>
>>52306031
I'll never figure out why people are obsessed with "cleaning".
>>
>>52307426
being clean is a white people thing, you wouldn't get it
>>
File: triangle.png (14 KB, 637x572) Image search: [Google]
triangle.png
14 KB, 637x572
#!/usr/bin/env python

import random
import turtle

speed = 0
length = 600

# def point (p):
# turtle.penup ()
# turtle.goto (p)
# turtle.pendown ()
# turtle.forward (0)

def loop (length):
turtle.penup ()
ps = [
(-length / 2, -length * 3 ** 0.5 / 4),
(length / 2, -length * 3 ** 0.5 / 4),
(0, length * 3 ** 0.5 / 4)
]
p = ps[0]
while True:
choice = random.choice ([0, 1, 2])
p0 = (p[0] + ps[choice][0]) / 2
p1 = (p[1] + ps[choice][1]) / 2
p = [p0, p1]
turtle.goto (p)
turtle.dot ()

def main (speed, length):
random.seed ()
turtle.hideturtle ()
turtle.speed (speed)
loop (length)

main (speed, length)
>>
>>52307526
put the sub-triangles on the clockwise edge
>>
>>52307541
What?
>>
>>52307556
\' _
./ '
>>
>>52307643
I don't get it.
>>
>>52307643
if this code reaches 88 miles per hour you're gonna see some serious shit
>>
>>52307744
|_|¯
._|¯|
>>
>>52307917
literally a symbol of peace
>>
File: fuckingreddit.png (34 KB, 1298x414) Image search: [Google]
fuckingreddit.png
34 KB, 1298x414
have you coded in javascript today, /dct/?
>>
>>52307971
Pretty sure JS is ridiculed on /r/programming just as much as it is on here.
>>
>>52307971
lol no
>>
>>52307971
currently coding in js, python, and groovy

fite me
>>
>>52307917
the windmill of friendship
>>
>>52308077
if you see this symbol while scrolling, you've been visited by the windmill of friendship
|_|¯
._|¯|
eternal friendship and good crop yield will come to you, but only if you repost the windmill in this thread
>>
>>52308095
|_|¯
._|¯|
>>
quick poll how many /dpt/ are actually from /pol/
>>
>>52308188
Not me
>>
        _
/ /\
/ / /
/ / / _
/_/ / / /\
\ \ \ / / \
\ \ \/ / /\ \
_ \ \ \/ /\ \ \
/_/\ \_\ / \ \ \
\ \ \ / / \ \_\/
\ \ \/ / /\ \
\ \ \/ /\ \ \
\ \ / \ \ \
\_\/ / / /
/ / /
/_/ /
\_\/
>>
>>52308188
i'm not, i just really want eternal friendship
>>
>>52308194
nice art skills
>>
>>52308219
i'll be your friend
but i won't live forever
>>
>>52308222
thanks. graduated top of my class. 200 confirmed alt codes.
>>
>>52308222
nice art trips
>>
File: file.png (1 KB, 62x49) Image search: [Google]
file.png
1 KB, 62x49
>>52308194
why are these green?
>>
>>52308235
sorry anon, i already have my mind set on one person :(
>>
>>52308240
How about these dubs?
>>
current progress on my first python project, simple timer
import time
import datetime


#recorded times#
shift_start_time = 0

break_start_time = 0
break_end_time = 0

lunch_start_time = 0
lunch_end_time = 0

shift_end_time = 0

total_shift_time = ((shift_end_time - shift_start_time) + (break_end_time - break_start_time))



def shift_start():
shift_start_time = datetime.datetime.now()
print("shift started at %s" % shift_start_time)

def shift_break():
break_start_time = datetime.datetime.now()
print("Break started at: %s" % break_start_time)

def shift_break_end():
break_end_time = datetime.datetime.now()
print("Break ended at: %s" % break_end_time)

def shift_lunch():
lunch_start_time = datetime.datetime.now()
print("lunch started at: %s" % lunch_start_time)

def shift_lunch_end():
lunch_end_time = datetime.datetime.now()
print("lunch ended at: %s" % lunch_end_time)

def shift_end():
shift_end_time = datetime.datetime.now()
print("Shift ended at: %s" % shift_end_time)

print("This is a basic Shift Timing function.\nType \'start\' to start your shift, \'break\' to start your break, or \'lunch\' to start your lunch")

user_state = ""
user_state = input()
while user_state != "end":

if user_state == "start":
shift_start()
user_state = input()

elif user_state == "30break":
shift_break()
user_state = input()

elif user_state == "end 30break":
shift_break_end()
user_state = input()

elif user_state == "lunch":
shift_lunch()
user_state = input()

elif user_state == "end lunch":
shift_lunch_end()
user_state = input()

else:
print("please enter a command from the available options, or type \n'help\n' for a basic guide")
user_state = input()

print("Great job buddy, you're done for today!")
print("your total hours worked today were: %s" % total_shift_time)
input()
>>
File: you don't get to make friends.jpg (79 KB, 716x768) Image search: [Google]
you don't get to make friends.jpg
79 KB, 716x768
>>52308219
You don't get to bring friends
>>
>>52308188
from turtle import *

deg = 90
multi = 5
color('black', 'red')

while True:
forward(30*multi)
right(deg)
forward(10*multi)
right(deg)
forward(20*multi)
left(deg)
forward(10*multi)
left(deg)
forward(20*multi)
right(deg)

>>
>>52308255
getting /dubs/ in /g/ is as unimpressive as trips in /po/ or quads in /j/
>>
>>52308251
comments.
>>
>>52308270
If it's so easy why didn't you get any?
>>
>>52308251
it's in a code block m8 they would be comments
>>
>>52308276
What do you mean?
>>
>>52308294
this
>>
>>52308274
>>52308284
then why aren't the rest of the lines commented as well? Look at the second line for instance
>>
>>52308262
from turtle import *
deg = 120
multi = 5
color('black', 'red')

while True:
forward(30*multi)
right(deg)
forward(10*multi)
right(deg)
forward(20*multi)
left(deg)
forward(10*multi)
left(deg)
forward(20*multi)
right(deg)


:^)
>>
>>52308313
This?
>>
>>52308326
that
>>
>>52308323
NO ONE CARES ABOUT YOUR TURTLE LANGUAGE. GO SMOKE SOME WEED YOU FUCKIN' HIPPIE.
>>
>>52308256
you should study underwater programming
>>
>>52308326
>>52308328
I'll help you guys out.
>>
>>52308338
Thanks, that really helps
>>
>>52308326
>>52308328
self
>>
>>52308095
|_|¯
._|¯|
>>
>>52308337
Have you thought about undercover programming?
>>
>>52308331
>not liking turtle graphics and their simple application to fractal drawing
turtle graphics are comfy as fuck man c'mon they're in a lot of languages
>>
I can fizzbuzz too : 3 ~nyaa~
>>
FIZZ
>>
>>52308371
>not telling /pol/ fags to fuck off
>>
>>52308380
this desu

>>52308379
idiot

BUZZ
>>
>>52308400
checked
>>
Keep spamming, this thread has gone to shit.

Need a new one sooner than later.
>>
>>52308421
Just make a new one now
>>
>>52308400

Daily reminder that if you can't fizzbuzz your post ID, you can't fizzbuzz at all
>>
Is there a more elegant way to handle key bindings than a hundred lines of switch statements?
>>
Dumb question here. Rape me if you want. I just need to know...

So im learning java (for school) and one thing i noticed is this in oop (excuse my noobiness i havnt actually coded on my own in a long time and as i realise how bad i am. Im literally lost)

Class shit
Int pie
Public shit (int frosting)
Pie = frosting;

Okay now why the fuck do we set pie equal to frosting. Why not just use pie throughout the code? Explain to me /dpt/
>>
>>52304725
Vector handles everything for you, you don't need to manually resize and copy. Primitive types are treated no different than Objects. Objects are just pointers after all.
>>
>>52306537
So FORTRAN I is functional programming now?
When will the FP shills stop?
>>
>>52305680
What are you doing on here, Terry?
>>
>>52308448
Not sure what you're asking. Pie is global and can be used throughout the class and possibly outside it.
>>
>>52308466
when all languages are functional languages
>>
>>52308508
"Pie is Global"
Hello new t-shirt idea.
>>
>>52308095
>>
>>52308508
Lol. Well its for java oop apprently we have the uninitialized variable outside the constructors and then witin the constructor were setting it equal to another variable.

In short im asking why would you do this? Benefits?
>>
>>52308095
>all these people in /dpt/ so desperate for friends

(or crop yield)
>>
>>52308350
H          DNEIRF OLLEH
E N
L E
L I
O R
F
F
R O
I L
E L
N E
DNEIRF OLLEHELLO FRIEND
E N
L E
L I
O R
F
F
R O
I L
E L
N E
HELLO FRIEND H
>>
>>52308550
That's called a setter and is used to control what changes variables. The alternative is a getter. Basically you create a class for others to use and so this helps you control how they use it. It could also be because your class is initialize by a user given variable and don't want to make the user pass it in to every function so they give it once and you save it within the class.
>>
File: 2000px-XMPP_logo.svg.png (152 KB, 2000x2057) Image search: [Google]
2000px-XMPP_logo.svg.png
152 KB, 2000x2057
I want to integrate some kind of real time communication into my program, preferable I'd like peers to be able to detect each other locally through something like mDNS but also over the internet somehow, I'd like to avoid a server and have peers detect themselves through other means, maybe peers in a group share their peerlist or peers try to mutually find each other, I'm not sure yet, either way it wouldn't be conventional client/server, I'd like it to be decentralized or distributed so there's no need for the users to worry about the state of a server or addresses etc.

Does XMPP seem like something I should read up on and use for this, is there a better alternative or should I consider rolling my own methods and protocol for this kind of thing?

The intent is just to have something easier for the users in the end, I just want them to be able to connect to each other no matter what the circumstances (no reliance on servers, NAT problems, WAN connection, etc.).
>>
>>52308508
Pie is not global, it has package visibility, but it won't be inherited.

>>52308448
This example doesn't make much sense, but it's useful in more complex classes. It allows you to maintain consistent state within your classes members, without having to remember to manually update related members. A classic example is a temperature class.
public class Temperature {
private int celsius;
private int farenheit;
public setCelsius(int tempC) {
celsius = tempC;
farenheit = convertCToF(tempC);
}
public setFarenheit(int tempF) {
celsius = convertFToC(tempF);
farenheit = tempF;
}
}
>>
>>52308590
def swastext(s):
print ("\n".join([(s[0] + " " * (len(s)-2) + s[::-1]) if i == 0 else s[i] + " " * (len(s)-2) + s[::-1][i] if i < (len(s)-1) else s[::-1]+s[1:] if i == (len(s) - 1) else " " * (len(s)-1) + s[i-len(s)+1] + " " * (len(s)-2) + s[::-1][i-len(s)+1] if i < (2 * len(s) - 2) else (s[0] + " " * (len(s)-2) + s[::-1])[::-1] for i in range(2 * len(s)-1)]))
>>
>>52308627
>>52308448

Just realized I am an idiot, pls ignore.

That shit method is a constructor. When you create a new object in Java using new, you call a constructor of your class, which has the same name. This means that when you create a new object of type shit, you can customize the value of it's pie variable during creation time, rather than manually altering it later, which would be bad form. You can also have multiple constructors with different argument types, which are useful for objects you can initialize in different ways.
>>
>>52308640
All that >in only one line of code
>>
When programming in C++, which file extensions do you use?

Source
>.cpp
>.cc

Headers
>.h
>.hh
>.hpp

First of each for me, the .h thing stuck from when I studied C/C++
>>
>>52308735
cpp/hpp
Thread replies: 255
Thread images: 37

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.