[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: 1440709792186.png (137 KB, 301x312) Image search: [Google]
1440709792186.png
137 KB, 301x312
Previous thread: >>53960084

What are you working on, /g/?
>>
a=1 b=2 c=3 d=sentence with spaces


Trying to create a regular expression that can parse that.
The keys never have spaces, but the values might.

I didn't think it would be that hard to make an expression that worked, since it boils down to:
>get the word before the =, and get everything after up to and not including a word proceeded by an =
but I can get anything that comes even close to doing that
>>
>>53966582
([^=]+)=([^=]+)

Or similar.
>>
>>53966688
Oh fuck. Just woke up. That's not gonna work.

>>53966582
Regexp is greedy, you can't program "just leave out one". You'll need to you a more general parsing algorithm like PEG or just fix up the output to what I wrote.
>>
>Tfw no gf who programs exclusively in Java
>>
>>53966582
write a tokenizer instead
>>
    private static final String defaultBackgroundColor;

static{
defaultBackgroundColor = "#FFFFF2";
}


Is this bad design?
>>
When you're choosing a high level language, why would you choose Python if it's so slow?
>>
>>53966760
Duh?
>>
>>53966582
>a=1 b=2 c=3 d=sentence with spaces

Couldn't you simplify by requiring sentences with spaces to be enclosed in quotation marks? That would make a pretty easy regex.

I've never seen that not being a requirement (except possibly if it is the last argument)
>>
>>53966760
Why are you surrounding the assignment in a static block?
>>
>>53966773
Java doesn't have the abstraction of Python and if I decide Python is sufficient it's because the speed of the program doesn't matter. There's no reason to write scripts in Java.
>>
File: seals.webm (3 MB, 1280x720) Image search: [Google]
seals.webm
3 MB, 1280x720
Ask your favorite programming literate anything (IAMA)

>>53965858
kek http://ideone.com/nRguYO

>>53966773
>cpython
>>
>>53966773
Depends what you want to do really.
Python has many great applications.
>>
How do I figure out if a point lies on a polygon's edge.
I can figure out if it's inside or outside of the polygon but not if it's on the edge.

Everything is in integer coordinate so I'm finding it hard to figure out.

I implemeneted the polygon as a list of 2D vertices and a list of edges.

The edge object has it's starting point, ending point, and the a, b, c parameters that define the line it lies on.
class Edge
{
int a, b, c;
Vertex start;
Vertex end;
}


My first idea was to just check if for the vertex it holds true that
a*v.X + b*v.Y + c = 0

for some edge and that vertex lies within the polygon

But it doesn't really work.
>>
>>53966779
Not my standard that I have to parse, it's from a yEnc encoded output.
I'm not sure why quotations aren't part of the standard, but you're right, it's only spaced if it's the last argument.
>>
In c++ if there are 2 libraries with same macro that causes error in when compiling how should I go on about getting around it?
Is it even possible?
>>
>>53966582
What about this?

$ echo a=1 b=2 c=3 d=sentence with spaces | grep -oE '[^= ]+=[^=]+($| )'
a=1
b=2
c=3
d=sentence with spaces
>>
>>53966881
#undef
>>
trait Predicate {
fn is_match(self, c: char) -> bool;
}

impl Predicate for char {
fn is_match(self, c: char) -> bool { self == c }
}

impl<F> Predicate for F where F: Fn(char) -> bool {
fn is_match(self, c: char) -> bool { self(c) }
}

struct Parser<I> where I: Iterator<Item=char> {
iter: I
}

impl<I> Parser<I> where I: Iterator<Item=char> {
fn satisfy<P>(&mut self, predicate: P) -> Option<char>
where P: Predicate
{
match self.iter.next() {
Some(c) if predicate.is_match(c) => Some(c),
_ => None
}
}

fn take_while<P>(&mut self, predicate: P) -> Option<String>
where P: Predicate
{
let mut s = String::new();

while let Some(c) = self.satisfy(predicate) {
s.push(c);
}

if s.is_empty() { None } else { Some(s) }
}
}


prog.rs:32:36: 32:45 error: use of moved value: `predicate`
prog.rs:32 while let Some(c) = self.satisfy(predicate) {
^~~~~~~~~
note: in expansion of while let expansion
prog.rs:32:3: 34:4 note: expansion site
note: `predicate` was previously moved here because it has type `P`, which is non-copyable
error: aborting due to previous error


Can anyone explain how to fix this? I get that it can't use predicate more than once, but making it pass by reference would change the semantics of my program in a bad way and making it copy-able seems wasteful.

I don't see why a function has to take ownership of a pure closure and can't simply reuse it multiple times.
>>
>>53966810
(v.y - start.y) / (v.x - start.x) == (end.y - start.y) / (end.x - start.x) && sign(v.y - start.y) == sign(start.y - start.y) && sign(end.y - v.y) == sign(end.y - start.y)
>>
File: 1359236051-gcc-llvm.jpg (106 KB, 1070x400) Image search: [Google]
1359236051-gcc-llvm.jpg
106 KB, 1070x400
>>53966881
#pragma push_macro("Foo")
#undef Foo
#include <...>
#pragma pop_macro("Foo")
>>
>>53966987
>sign(start.y - start.y)
sign(end.y - start.y)
>>
>>53966987
nvm i pulled this out of my ass
>>
>>53966981
Damn, that's fucking beautiful, thanks.
>>
>>53966810
function onSegment(A, C, B):
// Whether C lies on AB [3]
return |AC| + |CB| = |AB|
>>
>>53966810
>a list of 2D vertices and a list of edges
Not sure if I understand 100%, but wouldn't that mean some edges are shared and some aren't? If so, any edge that isn't shared by another poly would be an outer edge.
>>
>>53966997
Well fuck that worked.
>>
>>53966844
>yEnc encoded output
You are that same faggot whose been working on this for the better part of 4 days now.

>>53966981
>($| )
Dammit. Shoul've thought of that
>>
Creating a REST API, should I use PUT or DELETE when removing an element from an array of the actual object?

DELETE /users/pubs/:pubId


Versus

PUT /users/pubs/remove/:pubId
>>
>>53967054
he means if a point is on edge or not.

he already has the answer, checking if line equation of edge == 0 should be sufficient.
>for some edge and that vertex lies within the polygon
it should work, are you sure you calculated a, b and c correct? maybe you are truncing some values in integer division? why a, b, c are integers
>>
>>53967099
Yep, it's slowly getting there.

Usenet and yEnc standards are both so retarded that I'll probably be spending another few days on it.
>>
>>53967159
All so you can pick up hentai of the internet automatically? Wew lad.
>>
>>53967131
there is no integer division

a b and c are figured out through a cross product which involves only multiplication
since the coordinates are integers so are a, b and c

>>53967053
this is too slow because of the sqrt in calculating the distances
>>
What's the best way to build C/C++ projects nowadays? Personally I use CMake to generate Ninja build files.
>>
>>53967491
then your line equation is incorrect. can you give an example
>>
>>53967491
you don't need sqrt to compare the (squared) distances dummy
>>
>>53967538
    public Edge(Vertex start, Vertex end) {
this.start = start;
this.end = end;
left = start.getY() < end.getY();
a = start.getY() - end.getY();
b = -(start.getX() - end.getX());
c = start.getX() * end.getY() - start.getY() * end.getX();
}
>>
That feel when want to join "the movement" but don't know what to program.

https://www.youtube.com/watch?v=OWsyrnOBsJs
>>
>>53967569
How do you compare the squared distances?
2 + 2 = 4
4 + 4 =/= 16
>>
>>53967678
oh lol i'll kill myself
>>
>>53967668
>Coding
>Coded in college
fucking ayyyyy
>>
>>53966805
>Java doesn't have the abstraction of Python
>mfw it has more
>>
>>53967640
this is not an example. It looks like it is OK, in which case it is failing?
>>
>>53967523
http://gittup.org/tup/

anything having make in its name should be avoided at any cost.
>>
>>53966773
I just really hate how Java requires classes and shit. If I could put code outside a main-class I'd do it.

But I haven't programmed Java much at all.
This comparison is including startup right? Like VM and shit.
>>
>>53967735
I implemented the distance check the anon posted (the squared one)

It works but only for straight edges (lines parallell with x or y axis)

It might be because i'm doing this interactively.

The user draws a polygon then clicks around and every point that is clicked is checked to see where it lies.

Maybe this is hard because it's pretty tough to pinpoint the exact pixel of the line and it's even harder when the lines are slanted because bresenham's algorithm does some inherent rounding.
>>
What is the most "fun" programming language?
>>
>>53967815
racket
>>
>>53967802
integer coordinates will fail unless coordinates are exactly integer and on the line, which will be false for most of the time.
>>
>>53967833
Yeah thought as much. That's probably why all the algorithms I searched for online only make calculations if the point is within or outside the polygon.

I guess I could add some kind of buffer zone, if it's like... within 3 pixel distance of the edge and qualifies as within the polygon then the point is close enough to the edge to be qualified as on th edge.
>>
>>53966502
That photo, I have the weirdest boner at the moment.
>>
>>53967863
I just think the white guy's face is hilarious.
IDK how you cold get a boner from this, whipped cream fetish?
>>
>>53967815
JAI is looking like it's gonna be genuinely fun actually. I almost feel like I'm just wasting time writing C++ just looking at it.
>>
>>53967724
okay kid
>>
>>53967857
your threshold should probably depend on the slope, I am not sure how that works though. a better/easier way would be just marking edge points while drawing the polygon
>>
>>53967815
C.
>>
>>53966773
p. is generally just fucking shit and shitters that use p. are shit at programming
>>
>>53967897
>JAI is looking like it's gonna be genuinely fun actually
do you mind explaining
>>
File: worry.png (3 KB, 188x128) Image search: [Google]
worry.png
3 KB, 188x128
>mfw I was accidentally setting up identical vertex attribute streams almost 400 times per frame
>>
File: 832px-Bresenham.svg.png (6 KB, 832x448) Image search: [Google]
832px-Bresenham.svg.png
6 KB, 832x448
>>53967938
>a better/easier way would be just marking edge points while drawing the polygon
The edges are marked it's just that drawing the edges relies on bresenham's line algorithm and that algorithm does some inherent rounding, it colors points that mathematically should not be on the line if the line isn't vertical or horizontal.
>>
>>53966773
Because writing stuff in python is easier and faster when you can just stuff objects inside tuples and lists and do all sorts of shit with that.

What do you do in Java when you want to return two objects of different types at once? You gotta waste time writing a wrapper class.

If your goal is top performance you should probably use C++.
>>
>>53968006
you could store the pixels and just look up the color of the pixel that corresponds to the point. but that could take too much memory if you need to keep track of many lines individually
>>
>>53967984
https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md
This is a far better thing to read if you wanna know than anything I can say but a short summary would be :
>performance and data-oriented programming
C++ sort of has this, SoA is still clunky in C++. In JAI it isn't
>friction
C++ is high friction (friction, as described in github). Just that would make it far better.
>Code Refactoring
Hard to explain, read the github segment
>Arbitrary Compile-Time Code Execution
This is just awesome. You don't need to make a million small programs to offline shit anymore. You can just put it in there.

Also error messages are supposed to be more descriptive. I obviously haven't programmed in it but if it keeps what it promises to some extent, or is just a small upgrade over C++ I'm happy. I really like the fresh ideas.
>>
File: what.png (15 KB, 508x181) Image search: [Google]
what.png
15 KB, 508x181
Started project euler today and now stuck on problem 3, kek.
Not really "stuck", but I try to do it rite and learn a bit C at the same time maybe.
>>
>>53967802
sqrt is not too slow for human interaction
>>
>>53968084
system("factor 600851475143 >/dev/null 2>&1");


then just take the last number from stdin :^)
>>
>>53968091
Yeah but theoretically if the polygon has a million edges then you have to make a million calls to check on which edge the point lies in the worst case scenario.

But yeah I left it in because it's really short and simple to understand but I still have the issue of it not working for slanted lines.

I don't give a shit at this point, the use case for this is practically non existant anway.
>>
>>53968076

It actually doesn't look too bad. Some of the design choices remind me of Rust, except without the incredibly annoying ownership model.
>>
>>53968076
JAI seems like it's a very long way off. He might not even start the LLVM implementation this year, which might be a good thing in the long run.

It's neat to see the language developing over time though, even if it's just compiling to C right now.
>>
File: 1458615653768.jpg (148 KB, 962x722) Image search: [Google]
1458615653768.jpg
148 KB, 962x722
In javascript how do I "adapt" a unix timestamp with a given timeoffset? for example if the unix timestamp I have has a 240 timeoffset and I want to correct it with a 180 offset
>>
>>53968300
>JAI seems like it's a very long way off
Yeah.
>>53968287
Yeah people have said that. I haven't looked at Rust at all so I don't see it though.
>>
>>53968330
>I haven't looked at Rust at all so I don't see it though.

If you ever do, prepare to spend 100 hours on the simplest tasks.
>>
>>53968306
subtract it?
>>
File: lol-lang.png (3 KB, 144x144) Image search: [Google]
lol-lang.png
3 KB, 144x144
>>53966985
make satisfy take predicate by reference. It should be enough, at least in my mind... ?
>>
Why the fuck would our c++ professor make us copy paste our assignment source code to word and submit it through turnitin.com. What the fuck is this. 50% plagiarized. I did everything correct too(first year cs student never did c++ before) and I was happy now Ill get a fuking 0. REEEEEEEEEEEE
>>
>>53968353
Shouldn't have cheated
>>
>>53968353
don't cheat next time, kiddo
>>
>>53968372
I didnt ...
>>
>>53968348
what did you mean by that
>>
>>53968353
>cheats at fizz buzz
>comes 4chan and cries
faggot
>>
>>53968353
nice try, next time try changing the variable and function names, don't just copy and paste
>>
>>53968400
Well I finished my assignment wtf do you want me to do on my free time other than shitpost
>>
>>53968306
>>53968398

Do not, under any circumstance, define what a "timeoffset" means. It would instantaneously solve your problem, which you don't want to happen.
>>
>>53968414
>he does not finish first two year's CS assignment on first month
you are a failure
>>
File: 1438876826872.gif (622 KB, 480x304) Image search: [Google]
1438876826872.gif
622 KB, 480x304
>>53968372
>>53968382
>>53968400
>>53968408
samefagging level 9reddit
>>
File: Untitled.png (880 KB, 840x1010) Image search: [Google]
Untitled.png
880 KB, 840x1010
I'm thinking about tracking down some floating point rounding 'errors' causing lines in the grid, but first I need to decide it they bother me enough to deal with.
>>
>>53968446
>first two year's CS assignment
idk what you're talking about we dont have that
>>
File: segregation.jpg (127 KB, 1200x795) Image search: [Google]
segregation.jpg
127 KB, 1200x795
>>53968353
>copy paste our assignment source code to word
I smell something funny and odd...
Quickly looking, this turnitin bs is about WRITING right? Does it even support any language apart from English ffs? I'm sure whatever algo they use should have its results considered nonsensical on programming languages by default if it's the same on that they apply to English! And yeah, trivial problems lead to trivial code and therefore not a lot of ways you can word it differently than your neighbour, as opposed to what you can do with writing style, right?
You've been abused by this madman, anon. FUCKING GO COMPLAIN TO IRL STAFF AND NOT 4CHAN LIKE IMMEDIATELY!!!!
>>
>>53968473
>he didn't get assignments from his seniors and finish them already
>>
I'm having trouble finding something to capture inputs while the program window is minimized in C
>>
>>53968466
>browser #112
Where? I only have 110 since /rs/ is gone.
>>
>>53968626
it's right here, on my computer. :^)

how's 110 working out for ya?
>>
File: 2013-08-27-howtomakefriends.jpg (157 KB, 900x338) Image search: [Google]
2013-08-27-howtomakefriends.jpg
157 KB, 900x338
>>53968654
Poorly. It still links to /res/#threadnumber instead of /thread/#threadnumber
I mainly use the catalog for this reason. Please help me out anon.
>>
using Jaunt-API with Java i got a table i want however it gives me the html but i want it to be readable how do i make this?
>>
>>53968702
maybe by the end of the month you'll be able to find it, probably by using google or pastebin.
>>
>>53968734
Ok thanks.
>>
Is this how memcheck works?
for (uint8_t *i = 0; i < MEM_MAX; i++)
{
*i = i;

if (*i != i)
memory_error();
}
>>
>>53968352
fn satisfy<P>(&mut self, ref predicate: P) -> Option<char>
where P: Predicate
{ }

fn take_while<P>(&mut self, ref predicate: P) -> Option<String>
where P: Predicate
{ }


prog.rs:32:28: 32:46 error: the trait `core::ops::Fn<(char,)>` is not implemented for the type `P` [E0277]
prog.rs:32 while let Some(c) = self.satisfy(predicate) {
^~~~~~~~~~~~~~~~~~
note: in expansion of while let expansion
prog.rs:32:3: 34:4 note: expansion site
prog.rs:32:28: 32:46 error: the trait `core::ops::FnOnce<(char,)>` is not implemented for the type `P` [E0277]
prog.rs:32 while let Some(c) = self.satisfy(predicate) {
^~~~~~~~~~~~~~~~~~
note: in expansion of while let expansion
prog.rs:32:3: 34:4 note: expansion site
error: aborting due to 2 previous errors


Changing it to take a reference results in this.
>>
>>53968941
Isn't a reference written
predicate: &P
in Rust? I meant a borrow, then, have you tried this? It seems to me that the is_match call has no problem taking a reference to predicate from inside satisfy... Wait no,
&self
would mean that it borrows, I was wrong about the syntax. What if you borrow in both places? Seems logical to me...
>>
>>53966773
My time is more valuable than my machine's time.

If my machine takes a couple extra minutes when running my prototype for a problem, I don't really care, because generally I'm still looking something up while I'm running it, not just sitting there staring at my compiler
>>
>>53968798
Yes, that's the basic principle. But in practice you'll need more complicated tests to catch memory errors. Simply storing an increasing integer isn't enough. You need all sorts of patterns (101010..., 11001100, etc.) that you roll, invert, shift, etc. in various ways and compare the results.
>>
How to get a job that pays and let's you learn on the job/they teach you to some extent?
Should I be looking into paid internships, or just find any job and hope they take you under their wing?

Have experience programming but nothing solid or fancy to show off. Plus, it's been some time since I've programmed. Just need to get up to speed and get paid at the same time. Don't have time to sit and learn all tech they want you to know under qualifications section.
>>
>>53969148
So why exactly is an increasing integer not enough?
What kind of memory errors are you talking about that require more complex tests?
>>
>>53969210
I would just get a degree in the meme computer science field.
>>
>http://wiki.osdev.org/Memory_Map_%28x86%29
So a 32bit machine without PAE can actually only use 3gb out of 4gb because of that huge hole at the top?
Fucking hell.
>>
>>53969210
dude you might pull it off but you have a serious risk of getting blacklisted if you apply to companies without knowing fuck all
>>
>>53969217
Because an increasing integer won't test all possible bit patterns. You have to systematically test them all (or nearly all) to catch errors.

I'm no hardware expert, but I'd imagine some errors prop up only when adjacent cells store certain patterns, so an integer that only uses 8 bits isn't enough, you need a "bigger" pattern to test cells from a wider area.
>>
Anyone know off-hand how to fetch the default browser's user-agent string on Windows? A brief googling turns up lots of android stuff.
>>
>>53969360
gotta catch em all
>>
>>53969247
Not an option. Can't get into any more debt. Neither do I want to spend another 4 years in shcool.

>>53969332
Why blacklisted? I'm not going ot lie I know the shit and then improvise on the job. No. I meant an hoest way to learn while on the job - with employer know I don't have much experience but I still do have some.
>>
>>53969420
dont spoof user agents anon, thats rude
>>
>>53969500
It's more rude to be blacklisted for no good reason.

There's absolutely NOTHING wrong with "spoofing" the user-agent. Prove me wrong.

> "For historical reasons, Internet Explorer identifies itself as a Mozilla browser."

https://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx
>>
>>53969017
fn satisfy<P>(&mut self, predicate: &P) -> Option<char>
where P: Predicate
{
match self.iter.next() {
Some(c) if predicate.is_match(c) => Some(c),
_ => None
}
}


prog.rs:22:15: 22:24 error: cannot move out of borrowed content
prog.rs:22 Some(c) if predicate.is_match(c) => Some(c),
^~~~~~~~~
error: aborting due to previous error


Is it just not possible to do this with Rust's type system? It seems no matter what I do it won't compile.
>>
Is programming an inherently feminine activity?
>>
>>53969533
is_match shouldn't be moving self, it should be borrowing it. Do as I suggested.
>>
>>53969539
o-only if it somehow involves a feminine penis
>>
>>53969539
it's manly as fuck fucking fairy
>>
>>53969584
Most penises are small and dainty and girly most of the time.
>>
File: girl code.jpg (150 KB, 869x1776) Image search: [Google]
girl code.jpg
150 KB, 869x1776
>>53969539
coding = feminine
programming = masculine

here's an example of coding vs programming
>>
>>53969607
This can't be real.
>>
>http://ethereum.stackexchange.com/
if ethereum has a stackexchange does that mean it's legit? is it at all relevant for us software developers? what can we do with it in order to make money?
>>
>>53969647
i think shalom ayash was trolling but other than that idk lad
>>
>>53969582
trait Predicate {
fn is_match(&self, c: char) -> bool;
}

impl Predicate for char {
fn is_match(&self, c: char) -> bool { *self == c }
}

impl<F> Predicate for F where F: Fn(char) -> bool {
fn is_match(&self, c: char) -> bool { self(c) }
}


I can get it to compile like this, but now I have to pass arguments to satisfy and take_while by reference which is quite ugly. Is there no other way?

I want to be able to write
parser.take_while(is_vowel)
instead of [core]parser.take_while(&is_vowel)
>>
>>53969539
No, it's an inherently male activity.
>>
>>53969675
>One of the terrorists pulled out a laptop, propping it open against the wall, said the 40-year-old woman. When the laptop powered on, she saw a line of gibberish across the screen: “It was bizarre — he was looking at a bunch of lines, like lines of code. There was no image, no Internet,” she said. Her description matches the look of certain encryption software, which ISIS claims to have used during the Paris attacks.
>>
>>53969733
Then why am I better at it with a vagina than a penis?
>>
>>53969758
How are you hotswapping your genitals?
>>
guys I'm poor, should I learn Ruby or JavaScript to help get me a job fast. I hate both equally. Actually I hate all languages except C.
>>
>>53969778
Strapons.
>>
>>53969807
You should learn D, it's like C but without the risk of employability.
>>
>>53969815
Then you don't really have a penis, ever.
>>
File: feels ascii man.gif (1 MB, 720x720) Image search: [Google]
feels ascii man.gif
1 MB, 720x720
>>53969744
>It was bizarre — he was looking at a bunch of lines, like lines of code. There was no image, no Internet
>>
>>53969314

More reasons you should be using x86-64 for everything.
>>
>>53968044
Regarding returning two objects of different types. You could just work around the return by passing in the objects you want to change (because they're passed ByRef) and change them accordingly.
>>
>>53969838
Now I'm sad.

Still, I don't know how guys manage to function and concentrate so well, with that massive distracting bulge in your pants.
>>
>>53967744
>anything having make in its name should be avoided at any cost.

blasphemy
>>
>>53969895
We have refractory periods, which helps us concentrate properly until we get horny again.
>>
File: marcus_aurelius_4.jpg (202 KB, 1344x1344) Image search: [Google]
marcus_aurelius_4.jpg
202 KB, 1344x1344
>>53969895
>not being able to control your urges and emotions
How girlish.
>>
>>53969726
>pass arguments to satisfy and take_while by reference
>quite ugly
Pick one

Do you agree with the idea of lending the Predicate down the line? If yes, then accept that code as it is, semantically.

As for the syntax at the call site, I feel like there should be a solution... wait. You wrote
fn take_while<P>(&mut self predicate: &P) -> Option<String> where P: Predicate
, right?
You don't have to.
>>
>>53969939
u stoic breh?
>>
>>53969966
Stoicism is GOAT, or, as they say on /pol/, the ultimate redpill.
>>
>>53969956
How should I write it?
>>
>>53969939
It's not even urges or emotions. It's the physical sensation of having something there. Like an itch. Like how when there's something lodged between your teeth, it's almost impossible to keep yourself from examining it with your tongue.
>>
>>53969987
Don't borrow predicate from the caller there if you don't want the user of your parser to have to do so.
>>
>>53969987
With a biro pen.
>>
>>53969895
I masturbate a lot in the morning until my dick is sore and sex repulses me for the rest of the day. Then I can spend 100% of my focus on the intellectual pursuits.
>>
>>53970007
We're used to it being there.
I'm sure I would feel the same thing you're feeling if my "something" was missing, and there was only a hole.

>>53970043
I can't seem to get into it in the morning, I tend to masturbate at night when I'm tired, for some reason sleep deprevation increases my horniness.
>>
>>53969744
>It was bizarre — he was looking at a bunch of lines, like lines of code. There was no image, no Internet
terminals confirmed for terrorist tools. citizens, please turn in any computing devices that can access terminals.
>>
>>53970007
If I were a grill, I couldn't stop thinking about fingering myself, so yeah, it's just like that I guess.
>>
File: wrong.png (21 KB, 817x229) Image search: [Google]
wrong.png
21 KB, 817x229
Where is my mistake?

#include <stdio.h>

const int div = 20;

int main() {
int isDivisible = 0;
int num = 20;

while(!isDivisible) {
int i;
for(i = div; i > 0; --i) {
if(num%i == 0) {
isDivisible = 1;
} else {
isDivisible = 0;
break;
}
}

num += 20;
}

printf("num: %d\n", num);
}
>>
>>53970043
just take testosterone blockers and estrogen bro, you spend 3 seconds swallowing a pill rather than 3 minutes masturbating
>>
>>53970089
>3 minutes masturbating
lol
>>
>>53969895
it's nice, you can rest your hand on it
>>
>>53970089
what the fuck
>>
>>53970088
Using C. Just kidding.
Just compute the least common multiple of 2,3..20.
Nice digits, btw.
>>
>>53970089
But masturbating feels good, and I don't turn into a faggot at the same time.
>>
>>53970089
I don't want to turn into a girl, I just want to kill my sex drive.
>>
>>53970089
you need testosterone
>>
>>53970089
I had no sex drive before taking hormones but now it's impossible to focus on programming for long periods of time without wanting to masturbate. not having a refractory period doesn't help either...
>>
>>53969895
we manage fine, I don't know how females manage bleeding and getting cramps though
>>
>>53970125
why, when you could turn into a girl and keep your sex drive?
>>
>>53970160
are you a trap or on roids?
>>
>>53970173
The trick is to skip the placebo pills, so you don't have to have a period every month.
>>
>>53970018
So have satisfy borrow it and pass as reference from inside take_while?
>>
File: 1437577528302.jpg (32 KB, 400x400) Image search: [Google]
1437577528302.jpg
32 KB, 400x400
>>53970089
>3 minutes masturbating
>>
>>53970088
>Where is my mistake?
I do not understand what your intentions are with that code. You algorithm makes no sense when compared to the problem statement.

I can think of two obvious ways to do this. One is the naive method, in which you start with some number, check to see if the remainder for all numbers 1-20 is zero, and if it isn't, increment it and check again until you find a number that can be divided evenly for all numbers 1 through 20.

The other method is to factor all numbers, 1 - 20 down to primes, stack/sort out duplicates, and multiply to compute the number directly.
>>
>>53970181
trap but my equipment is laughably small so I stick things up my butt
>>
>>53969938
this

and we don't get distracted by bulges unless we're fags
>>
>>53968798
do you need to make i volatile?
>>
>>53970258
where you at
>>
File: kodewithkarlie.jpg (175 KB, 813x767) Image search: [Google]
kodewithkarlie.jpg
175 KB, 813x767
Have you remembered to encourage a woman to get into #koding today?
>>
>>53970270
ohio no bully pls
>>
>>53970286
>using a laptop

If this and >>53969607 are real, then I despair. She's setting the cause back.
>>
>>53970311
someone post her gay video
>>
>>53970267
I don't know, do I? why?
>>
>>53970352
You should always mark variables volatile.
>>
File: yes.png (44 KB, 461x338) Image search: [Google]
yes.png
44 KB, 461x338
>>53970248
I was doing the 'naive way' except that I added always 20, because anything else would be dumb.
Found my mistake. If my number would have been divisible by 1 to 20 then 20 would get added up anyways at the end. So I just had to move the incrementation.

#include <stdio.h>

const int div = 20;

int main() {
int isDivisible = 0;
int num = 20;
int i;

while(!isDivisible) {

for(i = div; i > 0; --i) {
if(num%i == 0) {
isDivisible = 1;
} else {
isDivisible = 0;
num += div;
break;
}
}

}

printf("num: %d\n", num);
}
>>
>>53970360
No, you shouldn't, let the compiler optimized out variables you don't actually need. And I don't see why the compiler would optimize out that variable.
Why should I make it volatile?
>>
>>53970332
https://www.youtube.com/watch?v=Bwiln7v0fdc

>coding is a weapon
how masculine and aggressive
fucking misogynist pigdog not wanting girls to feel welcome right off the bat
>>
I know this is slightly unrelated to programming, but can anyone remember a few years ago, some due took two fixtures, I think it was of some singer and then manipulated two different pictures of this singer by making tiny changes to the pixels to generate the exact same hashes?
>>
>>53970196
Fugg anon?
>So have satisfy borrow it and pass as reference from inside take_while?
This is already what you do

Use your fucking brain
>>
>>53970427
no right
>pass a reference from inside take_while

YES why is that so complicated?
>>
>>53970417
Any more context?
>>
File: IMG_1581.jpg (1 MB, 1920x1200) Image search: [Google]
IMG_1581.jpg
1 MB, 1920x1200
I have a list of coordinates (x,y). I need to iterate it so that for every iteration I get to substract x(i+1) - x(i-1); so for 4 elements in the table the first one is x(2) - x(4). Problem is I don't know how many coordinates I'm going to have in the table.
So basically I need some list that loops around. I'm coding in Java. Is there a neat data structure that will let me do this?
>>
>>53970406
Big deal. My school didn't offer CS or programming lessons either. I got into it because I was interested in it.
>>
>>53970406
>it's important to break that stigma of thinking that it's not cool to be smart
>stigma of thinking that it's not cool to be smart
What the fuck is wrong with Americans?
>>
>>53970440
It's not I'm just making sure that's what you meant.
>>
>>53970473
index % length
>>
>>53970473
Just use mod table size.
>>
>>53970521
kawaii++
>>
does anyone know the most simple way to get this c# code
string[] files = Directory.GetFiles(path)

to order the files by date created, rather than alphabetically?
>>
File: 1447651462253.jpg (3 MB, 4973x3089) Image search: [Google]
1447651462253.jpg
3 MB, 4973x3089
>>53970525
>>53970549
Please elaborate.
>>
>tfw our company is very pro-divesity, interviews with "women leaders" being emailed out, stats about women vs men ratios in every department put on the walls
>work on an all-male engineering team
>we finally get a qt female engineer, guess the campaigning paid off
>she's a little weak at programming, team and I spend a lot of 1-1 time getting her up to speed
>kinda annoying but damn shes a qt really nice too
>after 6 months she quits, saying programing is not for her
I just want a qt engineer gf to pair program with ;_;
why world
>>
Why do all the 'learn to code! omg' things always use terrible languages, like Python, or Ruby, or JavaScript?
>>
>>53970618
you can pair program with me anon
>>
File: 1453591006533.jpg (61 KB, 318x306) Image search: [Google]
1453591006533.jpg
61 KB, 318x306
>>53970088
>project euler
>programming
>not using math identities
>>
>>53970618
Does your company use Haskell?

I'll also accept Scala, if you let people use Scalaz, and don't use Play.

I ask because I'm done with unproductive languages.
>>
>>53970580

Use FileInfo ... that supports you can pull the creation time off that and sort.

FileInfo(fileNames[i]).CreationTime;
>>
File: Y55SeCb.jpg (49 KB, 1038x393) Image search: [Google]
Y55SeCb.jpg
49 KB, 1038x393
https://www.youtube.com/watch?v=QNxwuR9gPyk
>we're constantly being defined by our race, color, *gender*
>all of that doesn't matter
>it just matters that "we as young *women* are able to..."
>I want to help other *girls* who can teach other *girls*

fucking hell I wanna just hang these misandrist marxist cunts pushing their agendas on impressionable kids like this one
>>
>>53970683
Why is she wearing a hood when it's not raining?

Fucking hoodlums
>>
>>53970647
is this bait
>>
>>53970647
No haskell in the codebase but we have a fp group that meets at lunch and does haskell stuff often. A team is using scala with scalaz but its still in the experimental stage where its breaking the build all the time and everyone is annoyed.
>>
>>53970708
because it's cool
all the kids do it nowadays, grampa
>>
>>53970719
No. I've seen enough bad Java code to last a lifetime. To me, it's just not worth the stress.
>>
>>53970630
are you a real girl or a /dpt/ girl?
>>
>>53970723
Where are you based?
>>
>>53970761
Silicon Valley
>>
>>53970835
Damn.
>>
>>53970618
hahahahaha fucking pathetic dickless retards
>>
>>53970738
what's the difference?
>>
>>53970683
>I'm being marginalized for being a gril

Programming is one of the most self taught activities out there. The only thing holding her back is her feigned victimization. The fuck is with that american accent btw?
>>
>>53970874
>dickless
That's hardly relevant, surely?
>>
>>53970607
If n is the table size, i the index. Your 1..n index is weird, you should go from 0..n-1 but you can just adjust it by subtracting 1 from i then adding 1 after the mod.

So, i=1, n=4.

(i-1+1)%n+1 = i%n+1 = 2
(i-1-1)%n+1 = (i-2)%n+1 = 4
>>
>>53970886
One has a dick, one doesn't.
>>
>>53970934
I don't have a dick
>>
>>53970939
Bullshit.
>>
>>53970738
why can't you pair program with qt boi?
>>
>>53970939
Yet.

It's known that only men can be competent programmers, so if you're good, your body will begin growing a dick of its own accord.
>>
>>53966502
johnny manziel spraying whipped cream into al rokers mouth
>>
>>53970939
at any point in your life, have you ever had a dick?
>>
>>53970918
i hope you're not the confirmation bias troll from yesterday

there are countless studies that have shown that the smartest males (top percentile) are much smarter on average than the smartest females
>>
>>53970088
The gcd of any amount of numbers is the union of the multisets of each number's prime factors.
>>
>>53970964
qt bois are whiny and needy
>>
>>53970980
how is this question relevant?
>>
File: 1459453914188.jpg (633 KB, 690x2121) Image search: [Google]
1459453914188.jpg
633 KB, 690x2121
>>53970683
I know that feel. Why don't they push for women at mining, truck driving, construction and military?
>>
File: wait wut.gif (3 MB, 257x212) Image search: [Google]
wait wut.gif
3 MB, 257x212
>>53971006
>>
>>53970981
Not me, I wasn't on /g/ yesterday.
>>
>>53970862
In conclusion, Google is right and my company's executives are wrong. The lack of women in the tech field is a pipeline problem, not a sexism problem. My company has most inclusive policies imaginable and when we finally get a qualified female engineer, she quits! We cant just magically hire 50 female engineers to balance the team out because there aren't 50 female applicants! There's nothing more we can possibly do and yet we still get a yearly lecture that white males are privileged for having jobs that we must have got though old-boy networks.
>>
>>53970994
Nope, they are behave better than qt girls because they are self sufficient and less entitled
>>
File: you-dont-say.jpg (19 KB, 500x280) Image search: [Google]
you-dont-say.jpg
19 KB, 500x280
>>53971034
>>
>>53971034
No disagreement from me that there are far fewer female applicants than male applicants for tech jobs. The problem starts earlier - at university my course was 90% men, and before that my A-level math class was about 80% boys.

As for racial diversity: there wasn't a single black person in either.
>>
I can understand the choice of the designers of the ARM ISA to make the exclusive or instruction as EOR instead of XOR (Acorn was a British company, so they might as well not shit on their own language), but why is the inclusive or instruction ORR instead of just OR? For what reason is there an extra R? Just a need to make everything 3 letters?
>>
Fucking off by one error in this bioinformatics code that I got from my prof. I don't think I introduced it; I'm trying to track this shit down and fix it
>>
>>53971076
Oh, and: I must have interviewed over 200 people for my current company by now. Fewer than 10 were women.
>>
>>53971088
>Just a need to make everything 3 letters?
Easier and faster interpretter if all the ops have the same length.
>>
>>53971076
it's not sexism/racism, not at university either, it's just that some people are naturally more predisposed to be good at and interested in doing certain things. diversity is about recognizing the varying strengths and weaknesses of individuals, not about forcing everyone to fit the same cookie cutter template.
>>
>>53970923
Any idea why
          double x1 = tblPunkt.get((i+1) % tblPunkt.size()).x;
System.out.println(x1);
double x2 = tblPunkt.get((i-1) % tblPunkt.size()).x;
System.out.println(x2);

it crashes (array index out of bounds) on the 'double x2 = ' line?
>>
File: 1451285853152.jpg (59 KB, 680x680) Image search: [Google]
1451285853152.jpg
59 KB, 680x680
Any tips on how to approach problems that require a recursive function? First time I'm working with such problems and I feel like I'm losing my mind trying to come up with the right way for the algorithm to work. I start thinking I'm getting to a solution, then I hit a roadblock and I realize the entire function is wrong working that way, and I have to go back to square one.
>>
>>53971194
Split it into the base case and the recursive step.
>>
how the fuck do I get sed to delete everything inbetween single quotes every time I try it just escapes
>>
>>53971194
Start from the degenerate (lol) case.
a number 1 or an empty array or an array of length 1
>>
>>53971191

if you don't care about being terrible it's literally faster to just catch the exception without thinking about bounds, on condition that it would do what you want it to
>>
>>53969607
I always chuckle at that Fast inverse square root hacks "What the fuck" comment. kek
>>
>>53971194
Imagine that you want to solve the problem of turning any number, like 4, into a string of numbers below that number down to zero, like "43210"

1. Solve, manually for a very simple case.
def count(n):
if n == 0:
return "0"

2. Assume you've solved it for all cases up to, but not including n. Given the solution for (n-1), can you solve for n? In this case, if you have the string "3210", you can get the solution to 4 by appending "4" to the front of "3210", like so:
def count(n):
if n == 0:
return "0"
return str(n) + count(n-1)
>>
>>53971191
Oh right, java. % is the remainder, not modulo. So you're going out of bounds because it's returning a negative number.
>>
File: anime.png (251 KB, 956x535) Image search: [Google]
anime.png
251 KB, 956x535
We decoded anime now, only took like 20 hours
>>
File: tumblr_n691fyTO4z1tuv1u6o1_400.jpg (72 KB, 400x336) Image search: [Google]
tumblr_n691fyTO4z1tuv1u6o1_400.jpg
72 KB, 400x336
you guys might like this

https://www.quora.com/My-sister-thinks-shes-so-great-because-she-builds-ALL-of-her-software-from-the-bottom-up-with-C-how-do-I-tell-her-off#

>>53966807
>tfw +230 posts later and still no question
>>
>>53971134

It's an assembly mnemonic, not the opcode (all actual instructions are 32 bits). Making all mnemonics the same length isn't going to improve interpretation by anything, and it will only make assembling marginally faster (but running an assembler isn't that slow)
>>
>>53971351
lel, this girl would be /dpt's queen
>>
>>53971328
So just make a mod function and use that:

int mod(int a, int b)
{
return (a % b + b) % b;
}

mod(i+1, tblPunkt.size())
mod(i-1, tblPunkt.size())
>>
>>53971382
Also to illustrate the difference:

-1 % 4 = -1
mod(-1, 4) = 3
>>
>>53971351
>>tfw +230 posts later and still no question
Okay:

What is the point of dependent types?
>>
So I was writing some code snippet at cpp.sh and another random user's code ran instead of mine.

Are there online C++ compilers that don't do that creepy shit? C++14 preferably.
>>
>>53971378
no, c is no more welcomed here for some time now.
>>
>>53971378
Only if she has a queen-sized penis.
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.