[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: 327
Thread images: 35

File: 1442750574870.png (1MB, 1200x1800px) Image search: [Google]
1442750574870.png
1MB, 1200x1800px
What are you working on, /g/?

Old thread: >>58556533
>>
>>58562697
First for D
>>
>made after bump limit
this is the real thread
>>
File: 1459086790045.png (320KB, 540x643px) Image search: [Google]
1459086790045.png
320KB, 540x643px
>>58562697
Thank you for using an anime image!
>>
C# is best waifu
>>
>>58562697
C++ is the sexiest.
>>
>>58562744
shame about the language though
>>
what is faster ? allocating 542 kilobytes or or setting 131'068 floats to 0?
>>
I've made a romanian numbers converter:

#include <stdio.h>

#define ROMANIAN_PLACE(x) r_output[ro_counter++]=romanian_numbers[x]

int main(int argc, char *argv[]) {
char romanian_numbers[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
char r_output[15];
unsigned char places = 0, i = 0, j = 0, ro_counter = 0;

if (argc == 1) goto exit;
while(argv[1][places++]);
if (places < 2 || places > 5) goto exit;
places--;

if (places == 4)
if (4 < (argv[1][0] - 32) && 0 > (argv[1][0] - 32))
for (ro_counter = i = argv[1][0] - 32; i > 0;)
r_output[--i] = romanian_numbers[6];

for (i = !!ro_counter; i < places; i++) {
switch (argv[1][i]) {
case '9':
ROMANIAN_PLACE((places-i-1)*2);
ROMANIAN_PLACE((places-i)*2);
break;
case '8': case '7': case '6': case '5':
ROMANIAN_PLACE((places-i-1)*2+1);
for(j = argv[0][i] - 5; j > '0'; j--)
ROMANIAN_PLACE((places-i-1)*2);
break;
case '4':
ROMANIAN_PLACE((places-i-1)*2);
ROMANIAN_PLACE((places-i-1)*2+1);
break;
case '3': case '2': case '1': {
for(j = argv[0][i]; j > '0'; j--)
ROMANIAN_PLACE((places-i-1)*2);
break;
}
case '0':
break;
}
}

printf(r_output);
printf("\n");

exit:
return 0;
}

It doesn't work properly, though. I will debug it later.
>>
>>58562741
>>58562744
>not ruby or vb
>>
Baby's first Racket:
#lang racket
(define lower 0)
(define upper 1)

(define (start n m)
(set! lower (min n m))
(set! upper (max n m))
(guess))

(define (guess)
(quotient (+ lower upper) 2))

(define (smaller)
(set! upper (max lower(sub1 (guess))))
(guess))

(define (bigger)
(set! lower (min upper(add1 (guess))))
(guess))
>>
>>58562780
pedo
>>
>>58562778
>but it is a very fundamental question which will influence the design of the whole program
Explain
>>
>>58562697
MPEG-1 Decoder, then an encoder. Just finished a Transport Stream multiplexer/demultiplexer.
>>
>>58562787
set!s everywhere. It's OK using them on Lisp's dialects, but you should avoid writing imperative code when not needed.
>>
>>58562787
too imperative
>>
>>58562779
>goto
instead of "return 1"
>>
>>58562778
Setting the floats if they are packed contiguously and is done with a memset(). malloc() requires a syscall and would be somewhat expensive.
>>
>>58562825
>>58562832
It's collection of snippets I typed over from the book I'm reading.
>>
>>58562697
I want to marry that perl girl
>>
>>58562809
ok that was maybe too much pathos. but I only want to write the whole paging shit only once and I dont want to change later because I made a shit decision.

>>58562840
it's java and the floats are sitting in a direct bytebuffer.
>>
>>58562852
try making a less imperative version
>>
>>58562778
float *yourmem = calloc(542 * 1024);

Done.
>>
>>58562741
Best language and best waifu.

Ruby a close second in waifu. Shit language though.
>>
>>58562871
542 * 1024 * sizeof(float)

Oops.
>>
>>58562863
Just set the floats then.
>>
Is SQL the only commonly used database and query language?

Its kinda ugly tbqh.
>>
>>58562890
Yes
>>
>>58562871
doesnt calloc need a number of elements too?

calloc(num,size);
>>
>>58562890
>Is SQL the only commonly used database and query language?
There are many dialects of SQL, but it is pretty much the only database language that matters, other than abstractions to actual programming languages.

It's not that bad. Pretty expressive for working with sets of data.
>>
perl is literally me
i'm 1,63m and 50 kg
>>
>>58562837
Why do I need its own errorlevel? It's not like this program is intended to handle input errors (now).
>>
>>58562920
Why use that abomination of syntax when you can just use a "return" keyword?
>>
>>58562870
Care to give my a hint? I don't see how I can remove the lower and upper variables.
>>
>>58562960
have guess take two parameters
>>
>>58562697

Where is Lisp?
>>
>>58562992
On my dick
>>
I'm working on a f# file explorer but stuck on creating functions that will

1) Get a directory from a string
2) list all dirs in it that matches my free text query
3) list all files in it that matches my free text query
4) Return it as my own type which has a name, path and type (file or dir)

Right now I have 1, 2, 3 but I can't combine the two lists of different type to one list of my own type.

f# is kind of fucked if you come from a OO background.
>>
>>58562992
She's coding.

>>58562960
Something like this:
(define (guess lower upper)
(if (guess-ok)
(do-guess-ok-thing)
(guess (new-lower lower) (new-upper upper))))

(guess (your-lower) (your-upper))


I don't know what you are trying to do, but something like that should work.

If you're thinking a recursive call is too expensive, most Lisp compilers optimize them to efficient loop-calls (if they're called at the end of the procedure/function).
>>
>>58563016
>stuck on creating functions that will get a directory from a string
Stop trying to make a file browser
>>
>>58562884
I think neither is necessary. due to the nature of the buffer it's irrelevant if there is old data beyond its limit.
>>
>>58562697
Does anyone know how to compute the upper limit on the number of edges in an Aho-Corasick automaton? While it does find dictionary word in a string in O(n) I'm worried about space use. A trie would consume a lot less space, but would run in O(n*m) (m being length of diction words) because of the need to keep up with with up to m current unterminated partially matched words.
>>
>>58563027
>))))
>>
>>58563027
>I don't know what you are trying to do, but something like that should work.
Now, let’s think about the strategy behind this simple game. The basic steps are as follows:
Determine or set the upper and lower limits of the player’s number.
Guess a number halfway between those two numbers.
If the player says the number is smaller, lower the upper limit.
If the player says the number is bigger, raise the lower limit.
>>
>>58563016
Ugly but it works

filterFunction @"c:\temp" "*"
;;
val it : Item [] =
[|{Name = "AMD";
Path = "c:\temp\AMD";
Type = DirType;}; {Name = "demo";
Path = "c:\temp\demo";
Type = DirType;}; {Name = "Downloads";
}|]
>>
>>58563320
let filterFunction dir freeText =
Array.concat [ Array.map mapDir (listDirs freeText (getDir dir)); Array.map mapFile (listFiles freeText (getDir dir))]
>>
>>58563320
Take your
 tags and reformat the post.
>>
>>58563084
(define (guess lower upper)
(case (read-answer)
('bigger (guess (1+ lower) upper))
('smaller (guess lower (1- upper)))
(else
(result-is-here lower upper))))
>>
>>58563320
>>58563332
OH FUG.
[-code-][-/code-] tags and remove hyphens and reformat the post.
>>
>>58563332
Where can I find the tags? For example pre tag
>>
>>58563352
Thanks, but I'm not logged in so I can't reformat.
>>
>>58563365
Only code tags, sorry.

>>58563373
and lurk moar newfag
>>
let mapFile (foundFile:FileInfo) = 
let f = {
Name=foundFile.Name
Path=foundFile.FullName
Type=FileType
}
f

let mapDir (foundDir:DirectoryInfo) =
let f = {
Name=foundDir.Name
Path=foundDir.FullName
Type=DirType
}
f

let filterFunction dir freeText =
Array.concat [ Array.map mapDir (listDirs freeText (getDir dir)); Array.map mapFile (listFiles freeText (getDir dir))]


I want to make mapDir and mapFile into one method, that shouldn't be that hard should it?
>>
>>58563373
>>58563365
>Thanks, but I'm not logged in so I can't reformat.
You have to go back.

Remove your name. This isn't reddit.
>>
>>58563016
F# is probably one of your better choices if ya come from an OO background I guess, considering if you really feel the need to you can basically use it as C# with minimalist syntax
>>
>>58563439
why are they called mapDire and mapFile?

also, what language? OCaml?
OCaml has row polymorphism so you might be able to do that
>>
>>58563496
More of a fun project so I can learn F# than anything. I plan on making a F# microservice (because why not) and call that from a UI program that will display the results.
>>
I hate thread synchronization.
>>
>>58563590
Well, I'd be willing to bet that thread synchronization isn't particularly fond of you either.
>>
>>58563602
I'm trying to implement mutexes in my kernel, I'm using atomic operations to check-and-set the mutex, yet i'm still getting some desynchronisation, one time a thread took a lock on a mutex that was already locked!
>>
>tfw my programming prof is an old coot who doesn't know python
Best books on C++? I've familiarized myself with the main() and cout stuff. I don't need a book that'll teach me programming all over again, just the syntax and keywords of C++. Something like a reference book, I guess.

also python a CUTE!
>>
>>58563746
Is he teaching a python class?
>>
>>58563746
Learn C syntax, then C++ OOP, templates, etc. will be easier to understand.
>>
File: Screenshot_104.png (455KB, 572x773px) Image search: [Google]
Screenshot_104.png
455KB, 572x773px
>>58563776
A class on programming. Majority of the other kiddos are turning in psuedocode/flowcharts. I want to be
>that guy
and do it all in coding. For one, I already know Python. And imo it's easier to just code the shit out.

>>58563783
Is pic related a good book? It is pretty old.
>>
how do I become a webdev? I can write python
>>
>>58563806
>Majority of the other kiddos are turning in psuedocode
>I want to be that guy and do it in pseudocode that happens to be interpretable

Lofty goals anon
>>
File: Screenshot_52.png (73KB, 187x164px) Image search: [Google]
Screenshot_52.png
73KB, 187x164px
>>58563831
kek.
>>
if it's not assembly it's always pseudo code
>>
>>58563821
>>>/g/wdg
>>
>>58563898
Assembly is the pseudocode too.
>>
>>58562787
You can do it!
>>
beginner-beginner c programmer here

the exercise is so the number you input tells you if the year is a leap year
this is what it says "A leap year is any year divisible by 4, unless the year is divisible by 100, but not 400".

if I do:
if (year % 4 == 0) {
if (year % 100 == 0)
printf("This year is not a leap year.");
else
printf("This year is a leap year.");
}

what am i doing wrong what the fuck
>>
>>58563898
Are you implying that Assembly is low-level?
>>
>>58563928
400 is divisible by 100 as well.
Figure it out on yourself what happens.
>>
>>58563806
>>58563831
I always pseudocode in BASIC.
>>
>>58563928
Transfer to another class with another language and use
.IsLeapYear
.
>>
>>58563928

&
>>
>>58562697
>no x86 ASM waifu in list
shit pic
>>
File: .jpg (79KB, 662x720px) Image search: [Google]
.jpg
79KB, 662x720px
>>58563986
>go become a code monkey
nigger, please, we already have enough
>>
>>58562744
Agreed, now that's a woman.
>>
>>58562697
XML is a fucking joke
>>
>>58564029
C is classy and top choice
>>
>>58564040
2old4me
>>
>>58564026
Are you implying this chucklefuck who literally CAN NOT DETERMINE IF A YEAR IS A LEAP YEAR is going to be anything but a codemonkey?
>>
Abstraction: The Biggest Mistake in Programming?
>>
>>58564061
He's learning now, don't bully him.
We weren't born professional fizzbuzzers, we had to learn the stuff.
>>
>>58564093
The greatest success.
>>
>>58562697
PHP, Javascript, Visual Basic, R, and Scala are the best
>>
>>58564093
define abstraction
define """""""""""programming"""""""""""
>>
>>58563954
if i add after the year % 4 == 0 to print that the year is a leap year and % 100 with % 400 (and switch what the printf statement says accordingly) 2000 is a leap year, 2004 is a leap year however 2200 is a leap year now but according to the instructions 100 is divisible by it and 400 is not

what the fuck is this difficult curve in this book
>>
File: 1366649303124.jpg (97KB, 960x783px) Image search: [Google]
1366649303124.jpg
97KB, 960x783px
>>58563806
Remembering syntax isn't what makes you a great programmer.
Pseudocode exists for a reason.
>>
>>58564093
Abstraction is not a mistake, but something happened and now lots of people prefer making abstractions to actually programming.
>>
>>58564093
If you can pass your work on someone other, you'll probably do it.
The same with computers, at one moment it became cheaper to spend extra cycles instead of having people to write machine code.
And what would you think, programmers initially were punchcard punchers, when engineers had the real work.
>>
>>58564100
He had his chance to learn at the same time I did. He should have thought about the consequences before he fell behind.
>>
File: Screenshot_53.png (153KB, 285x215px) Image search: [Google]
Screenshot_53.png
153KB, 285x215px
>>58564138
>tfw don't pre-plan my coding projects
>just jump in with a simple hello world and its trial and error after that
>>
File: 979829892924658370.jpg (30KB, 425x382px) Image search: [Google]
979829892924658370.jpg
30KB, 425x382px
>>58564138
This.
Good programming logic is everything you need.
>>
>>58564138
>Pseudocode exists for a reason.
Why? Are you not capable of "thinking in" an actual programming language?
I've never found it to be useful. I always just go straight to code.
>>
>>58564179
>Antifragile programming
>>
>>58564138
>>58564187
thanks for posting anime
>>
>>58564192
> not dreaming in code
>>
>>58564192
Planning is necessary if you're a primate and use OOP excessively because the code ends up so brittle.
>>
>>58564248
> b e i n g a retard
>>
>>58564132
Please think harder and try to compute the code by yourself.
Not just push strings into the compiler, but actually read aloud your program line by line and figure out how the spice^H^H^H^H^H program must flow.
It really helps.
>>
File: 979839585895680999.jpg (129KB, 757x502px) Image search: [Google]
979839585895680999.jpg
129KB, 757x502px
>>58564248
I actually dreamt about coding this night
>>
File: anal beads.png (20KB, 865x347px) Image search: [Google]
anal beads.png
20KB, 865x347px
>>58563928
>>58564061
Rate my leap year discovery function, /dpt/:

string IsLeapYear(int year)
{
goto step1;
step1: if (year % 4 == 0) goto step2; else goto step5;
step2: if (year % 100 == 0) goto step3; else goto step4;
step3: if (year % 400 == 0) goto step4; else goto step5;
step4: return $"{year} is a leap year. It has 366 days.";
step5: return $"{year} is not a leap year. It has 365 days.";
}


It's based on official Microsoft documentation:
To determine whether a year is a leap year, follow these steps:

If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.
If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4.
If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5.
The year is a leap year (it has 366 days).
The year is not a leap year (it has 365 days).

https://support.microsoft.com/en-us/help/214019/method-to-determine-whether-a-year-is-a-leap-year
>>
>>58564248
>>58564271
I dreamt browsing 4chan several times.
>>
>>58564239
What's that mean?
>>
File: 110964122874.png (939KB, 1079x767px) Image search: [Google]
110964122874.png
939KB, 1079x767px
>>58564289
How do we know this is not a dream?
>>
File: 1473854651307.jpg (454KB, 1280x720px) Image search: [Google]
1473854651307.jpg
454KB, 1280x720px
Obviously I cannot use a mutex in the scheduler code itself, since the mutex relies on the scheduler code, it'd cause an infinite recursion or a dead lock.
But global data in the scheduler still needs to be protected. How do you go about protecting this data? spinlocks? something else?
Disabling interrupts is NOT a good option, what would happen if I missed an important interrupt? Only chaos could come from that.
>>
>>58564283
Nice code for 70s-80s BASIC.
Now please learn structured programming and take some Pascal pills.
>>
>>58564283

Javafags on suicide watch! They wish they had goto!
>>
>>58564320
Just use an anime
>>
I'm a beginner, having trouble trying to print prime numbers in C.

I'm doing these brain-teaser coding challenges, and this one is telling me to write a program that takes a given range and prints all the prime numbers in the range.

What I have is this:
for(int num = lowerBound; num < upperBound; num++)
{
for (int i = 0; i < num / 2; i ++)
{
if(num % i != 0)
printf("%d\n", num);
}
}


This doesn't work, and I can't really figure out what I'm doing wrong. Any tips to get me unstuck?
>>
>>58564395
Disabling preemption temporarily seems to have worked.
Would there be any downsides to that?
>>
>>58564402
Right now you're printing a number every time you find one of its factors, so you're printing non-primes repeatedly instead of printing primes...

Try to run the program in your head to see what it does, don't just piss random code on your editor and hope it works.
>>
>>58564310
Because it's 2017
We should have been complemented by now
We didn't get to see epic angel battles

And don't say you have no void in your heart to fill
>>
>>58564402
Great job, anon! You'll be programming USB device drivers and microservices in no time!
>>
>>58564402
That's easy anon.
#include <iostream>
#include <vector>

class generator {

public:
generator ();
int next ();

private:
std::vector<int> _primes;
int _current;

bool _is_new_prime () const;

};

inline generator::generator ()
: _primes ()
, _current (2) {}

inline bool generator::_is_new_prime () const {
for (size_t i (0); i < _primes.size (); i++) {
if (_current % _primes[i] == 0) {
return false;
}
}
return true;
}

inline int generator::next () {
for (; !_is_new_prime (); _current++);
_primes.push_back (_current);
return _current;
}

int main () {
generator generator;
for (int i (0); i < 1000; i++) {
if (i > 0) {
std::cout << ' ';
}
std::cout << generator.next ();
}
std::endl (std::cout);
return 0;
}
>>
>>58562697
>making JavaScript hot
>>
>>58564485
>being a c*mmunist
>>>/r/ibbit
>>
File: 1479600745037.png (222KB, 564x334px) Image search: [Google]
1479600745037.png
222KB, 564x334px
>>58564546
>>being a c*mmunist
u wot
>>
>>58564590
>We should have been complemented
only a literal c*mmunist can possibly say this as something positive
please don't reproduce
>>
Why does using the operator new give an exception in a visual studio unit test?

int * test = new int;

Exception C0000005
>>
File: 1484287634452.gif (1MB, 320x213px) Image search: [Google]
1484287634452.gif
1MB, 320x213px
>print "even" if the user inputted number is even, otherwise "odd"
>you cannot use modulo
>>
>>58564640
n & 1
>>
>>58564634
Are you sure that it's exactly where the exception is raised? Because it works on my computer:
int *p (new int);
*p = 42;
>>
>>58564640

int x; // the integer to check
bool y = (ceil(x/2) == (x/2));
// y is true if even, false if odd
>>
>>58564640
>store the result of dividing the input number by 2
>if integer division is converted to floats, check for a fractional portion
>if integer arithmetic is performed, multiply the stored number by 2 and check if it's equal to the input
>>
>>58564620
Am I being baited now by (You)?
>>
File: vs.png (33KB, 1462x519px) Image search: [Google]
vs.png
33KB, 1462x519px
>>58564678
>>
>>58564725
Add a print before the line and one after the line. And see if only the first print is executed.
>>
>>58564716
what part of my post warranted that response?
i'm really interested. are you implying anything I've said there is wrong?
>>
>>58564179
>not using flowcharts
>not doing any mental planning
>having to resort to "trial and error"
Jumping straight into developing any large project is just asking to waste time at the computer fixing trivial, but widely used, errors
>>
>>58564740
Only the print before donew() shows up, not the one after
>>
guys what are some good ideas for projects

i can never think of any ideas
>>
File: Selection_004.png (71KB, 572x355px) Image search: [Google]
Selection_004.png
71KB, 572x355px
>someone has the audacity to use this on their "serious" twitter
Post red flags
>>
What is a good book on regular expressions?
>>
>>58564803
make an anime program
>>
>>58564807
>the thread doesn't use an anime image
>>
>>58564668
correct
this will also work
int32_t n = 0;
std::cin >> n >> std::endl;
bool odd = !!(n << 31)
>>
>>58564817
>>58564813
>>58564803
Make /dpt/ anime OP detector.
>>
>>58564640
doIt x = case even x of  
True -> "even"
_ -> "odd"

tomatoProb = (putStrLn . doIt) =<< readLn
>>
>>58564838
Oops, I forgot to add
"In haskell this is just"
>>
>>58564838
doIt (even -> True) = "even"
doIt _ = "odd"
>>
>>58564838
>>58564855

interact (bool "odd\n" "even\n" . even . read)
>>
>>58562697
Please desist from posting poorly drawn Japanese cartoons.
>>
@58564910
cease using this site and return to your home
heres the link -> >>>/r/eddit
>>
>>58564830
>std::cin >> n >> std::endl;
Absolutely disgusting.
>!!(n << 31)
Nice implementation-defined behaviour, idiot.
>>
>>58564926
back off fagman
>>
>>58564747
>are you implying anything I've said there is wrong?
You have fucking insulted me by calling a commie and you fucking dare to ask if there is something wrong?
If you aren't going to apologize right now, I'll format all your drives for insulting an honest man. Moreover, I already know your IP, it's 127.0.0.1
>>
>>58564802
Is int really int? Isn't the default int type overridden somewhere?
>>
>>58564962
>by calling me a commie
fixed
WHERE ARE YOUR APOLOGIZES
>>
>>58564962
>insulted me by calling a commie
yes, because that's what you are if you think instrumentality somehow isn't an abhorrent thing
either that or some other form of leftism which still makes you an animal as far as i'm concerned.
>man
really wouldn't call you that lmao
>>
>>58562863
>>58562871

you're supposed to just make an array of floats

that's probably what the compiler expects you to do

that way the java interpreter will call the function for you (since you clearly can't be trusted)
>>
File: datalist.png (2KB, 161x131px) Image search: [Google]
datalist.png
2KB, 161x131px
I'm getting data from an api and using it to fill a datalist for an autocomplete form. It works most of the time, but rarely, the graphical glitch in this image occurs and some of the datalist options aren't show, but I can still select them with arrow keys and it still completes the word when I hit enter. Is this probably an error in Chrome?
>>
>>58564938
>Absolutely disgusting
Either your a faggot for hating C++, or being retarded for using
using namespace std;

>Nice implementation-defined behaviour, idiot
You can take the absolute value of n and fix that
>>
>>58565080
>faggot for hating C++
No, I just don't have incredibly shit taste.
Also, how the fuck can you defend iostreams? They're ridiculously ugly and are retarded overall.
>>
>>58565104
>Also, how the fuck can you defend iostreams?
he's a sepplesfag, are you really that surprised?
>>
>>58565067
do you know of any popular sites that are leaning on datalist heavily? it feels like there's always something fucked with it
>>
File: 979839897966885559.jpg (52KB, 500x500px) Image search: [Google]
979839897966885559.jpg
52KB, 500x500px
Daily reminder that C++ is the only language you need in your life.
>>
>>58565128
And one day you meet OCaml.
>>
>>58565128
Daily reminder that C++ is a monstrosity
>>
>>58565017
>either that or some other form of leftism which still makes you an animal as far as i'm concerned.
oh well
your not just a faggot
your an ultrafaggot
and you just have a shit taste
>really wouldn't call you that lmao
come to me and say that in my face, ultrafaggot
>>
>>58564283

Gross.

int is_leap_year(int year)
{
if (year % 4) return 0;
if (!(year % 400)) return 1;
if (!(year % 100)) return 0;
return 1;
}


>>58564807

Looks like someone who has never played with Ruby before. Remove getName and getDescription, replace with an attr_reader. Rename getInfo method as just info (it's the Ruby way), and remove the return keyword. And then ask yourself how many Treasures in your game you want to describe as "Legendary".

And really, you could just use a Struct if you don't mind letting the Treasure class have some setters.
>>
>>58565168
>Gross.

It's intentional.
>>
>>58564807
if you aren't an exceptional person and you post on twitter then you're probably a narcissist and unable to properly evaluate your output
>>
>>58565156
>and you just have a shit taste
i think you misunderstood, i'm not one of your kind
>come to me and say that in my face, ultrafaggot
sure, let's meet up. i'm assuming you're in e*rupe, right?
i'm in its most non-shitty country right now.
>>
>>58565286
if you aren't an exceptional person and you post on 4chan then you're probably a narcissist and unable to properly evaluate your output
>>
>>58565298
>i'm in its most non-shitty country right
i don't know european countries
>>
I'm working on stats collection for my decentralized TV system (BasicTV, IRC channel is #basictv on Freenode). It doesn't use an organized node system, but instead just queries random nodes for data, and uses the data received to generate statistical likelihoods that a given peer has the information I want.

Every piece of data has an ID associated with it, and every piece of data that goes through a socket has the ID and timestamp added to a vector. Once a request has been made to receive data, each socket has that table pulled, the corresponding pointer is fetched (fast ID pointer lookup table), and the next item in the linked list is pulled. Keep this up until either I no longer have the information, IDs have been repeated (DoS attack vector), or the ID has been found. If the ID has been found, return the inverse length (long double, the statistical probability, will make more accurate later).

Then request information from the top socket and store that information in the network request data type. If it comes back negative, then send out to the next two, and if those turn back negative, keep doubling the number by itself.

This only works with datatypes that have linked lists, and types that would typically be received in forwards or backwards sequential order (audio, video, captions, etc).

It's pretty rough, but i'm hoping it can work. Since each socket can have its own thread (assuming locks are going to happen), and the overhead of looking up IDs is pretty small, i'm hoping that I can get some nice granularity from going far back (as opposed to stopping too early without getting any useful information).

What's the best multi core ARM server? I want to get one so I have some real power for encryption, compression, statistics, and networking.

>>58564938
>Nice implementation-defined behaviour, idiot
It is only implementation defined on a right shift, left shifts are defined as always being filled with zeroes
>>
>>58565379
oh, so you're even more of an animal? got it. i won't be flying out then.
>>
>>58565345
if you don't see significant differences between here and twitter then i don't know what to say
>>
>>58565388
>left shifts are defined as always being filled with zeroes
You're shifting into the sign bit, which I'm pretty sure is implementation defined.
>>
>>58565408
Maybe you use twitter like a self-centered prick, some people use it for discussion and instant broadcast of short information.

Don't blame the tools for your own shitty behavior.
>>
>>58565414
Wikipedia page (not perfect source, I know) only says that right logical shift is implementation defined.
>>
>>58565379
>i don't know european countries
You probably don't know US states either.
All hail the US education system.
>>
>>58565451
>not perfect source, I know
why did you cite it then you fucking retard?
>>
>>58565414
On what arches will a left shift's behavior change based on whether it's signed or not?
>>
>>58565399
>proud American
>animal
Insulting me, you insult the best country in the world.
May you burn in hell for such deeds, ultrafaggot.
>>
>>58565457
Because it is what I had up and I don't care about pleasing negative people
>>
>>58565465
you do realize that you're a disgrace to anyone involved in creating your country, right?
>>
>>58565428
you misunderstand -- twitter is great. i learn a lot from it
>>
>>58565472
Fuck off from this thread then, plebbitard.
>>
>>58562697
I love Java. I want to marry her
>>
>>58565504
even considering her lack of common sense when it comes to hygiene?
>>
>RAII without affine types
What a joke.
>>
>it's an esr pretends to be the world's greatest programmer episode
>>
>>58565515
I just want to cum in her face. How can I go about writing such method.
>>
>>58565463
0x40 = 128
0x40 << 1 == 0x80
Sign + Magnitude: -0
Ones Complement: -127
Twos Complement: -128

Although, thinking about it, I remembered that's actually not how left shifting is defined. It's actually just "* 2", which means you're overflowing the value and that it's actually undefined behaviour, which is even worse.
>>
>>58565545
You could write a program that downloads and installs Waifu Sex Simulator, assuming you own a Vive or Rift.
>>
>>58565545
do you speak hindi? that's the only way
>>
>>58564402
Do you even know what a prime number is?
Write a correct algorithm textually before going into implementation.

Tip: for the naive algorithm, it is sufficient to check for factors until √n included in order to prove that n is prime or not.

Next step is implementing Eratosthenes' sieve, it is more convenient when given an interval of integers.
>>
arent those programming practice sites that run code on their server super exploitable?
>>
>>58565591
Generally tight as fuck, pretty strict limitations.
>>
>>58565591
They're most likely run inside VMs or dockers, so the most harm you could do is crashing them without making much damage to the physical server.
>>
File: 1478959203261.png (164KB, 598x289px) Image search: [Google]
1478959203261.png
164KB, 598x289px
i have written a program that converts files into gray-scale images that are 4 times as big as the input file
that shit is quite trippy desu

and next i plan to rewrite it for Coloured pictures

pic related it's waifu ass
>>
File: hqdefault.jpg (23KB, 480x360px) Image search: [Google]
hqdefault.jpg
23KB, 480x360px
>A-anon-kun, p-please stop!! those are my private methods!
>>
>>58565630
>unzips
Reflection
>>
>>58565630
#define private public
>>
>>58565478
None of your business, ultrafaggot.
You dare to insult the greatest country in the world.
You have no right to speak the language of the United States of America from now.
>>
Is reactJs any good for making mobile games, specifically 2d rpg games?
>>
>>58565591
say you were a customer of a virtual hosting provider. what's the worst you could do to their machines? people have invested a lot of energy in securing that kind of thing
>>
File: gof_cover.jpg (93KB, 520x648px) Image search: [Google]
gof_cover.jpg
93KB, 520x648px
Is pic still worth reading these days? And if it is, is there an alternative that was actually written by people who have spoken to another person before?

Reading pic is unbelievably difficult, sample code isn't properly grouped together and stuff is poorly explained; after each chapter I usually have to go onto StackOverflow to make sense of what i just read.
>>
>>58565670
No! I'm in charge here!
>>
>>58565722
def generate(a):
l = 'abcdefghijklmnopqrstuvwxyz'
n = '123456789'
s = '!@#$%^&*()'

password = str()

for i in range(a):
x = random.randint(0, 15)
if x <= 5:
if x % 2 == 0:
password += random.choice(l).upper()
else:
password += random.choice(l)
elif x < 10:
password += random.choice(n)
else:
password += random.choice(s)
return password
>>
>>58565722
>Is pic still worth reading these days?
If you want to be able to understand shitty, overly OOP code written by people who also read the book and thought it was a list of recipes you should use, yes.
>>
>>58565722
"""Desgin Patterns""" are garbage, and are just a bunch of overcomplicated and overengineered shit to get around shortcomings in Java.
OOP at it's worst.
>>
>>58565730
#define private public
#define protected public
#define you mygf
#include "you"
>>
>>58565722
Nobody ever actually read that book. We all just pretend we read it and derive our opinion of it from the social value it provides to us at the time. When conforming, say it's great and you love to use design patterns like Observer and Twinkblaster; when iconoclasting say it's an outdated tome of shit unhealthy techniques.
>>
>>58565760
>We all just pretend we read it
lmao
no?
i don't read literal trash
>>
is mental fatigue actually a thing?
>>
>>58565786
Sure. Why wouldn't it be?
>>
>>58565786
if you're not chinese sure
>>
>>58565786
no
>>
>>58565781
Yes you do, look at all these ss+milf doujins on your hard disk drive (HDD)
>>
>>58565747
>>58565749
>>58565760
What should i read if I want to learn about how to design and structure programs better then?
>>
I'm about to start a web application project in Go.

Somebody redpill me about Go and why I shouldn't use it.
>>
>>58565804
>milf doujins
i don't read trash doujins though
>>
>>58565811
>redpill about
fuck off, plebbitor
>>
>>58565812
Trash taste senpai
>>
>>58565811
It's fine. A bit verbose with error handling boilerplate but otherwise fine. It's fine. It's not bad. It's fine.
>>
File: go board.jpg (155KB, 600x600px) Image search: [Google]
go board.jpg
155KB, 600x600px
>>58565811
Go
>near infinite amount of unique games
>insanely complicated
>AI just managed to beat people about a year ago
>can be played on multiple dimensions
>many different strategies
>fun
>can be played with any number of players (given enough unique types of tiles)
10/10 would buy again
>>
>>58565841
perhaps you thought this sounded okay but you just came off as extremely autistic
>>
why is everyone in the programming thread an elitist cunt?
>>
>>58565861

why are moths attracted by light?
>>
>>58565861
Because you're a literal pleb. now fuck off back to your subreddit.
>>
>>58565861
With elitism comes quality.
However, it doesn't seem to be working here. I think we need to be more elitist.
>>
>>58565852
>buy
>when he has internet and a printer
>>
>>58565861
insecurities
>>
>>58565168
What are you working on right now?

I'm fixing up Manjaro right now to run templeos and maybe gonna mess with making structs to manage a file system like a tile map.

And I know it sounds like I could try a Qt thing but I don't want anything based on that that's not giving me acecss to C code. C++ is nice but I don't wanna.
>>
>>58562779
it's roman not romanian
>>
Are there large differences between versions of Apache spark? My professor is making us use 1.1.0 while like version 2.3 exists online. Spark doesn't even let you download 1.1.0 anymore. How fucked am I if I am going to apply for jobs that use spark?
>>
>>58565856
That word has lost all meaning here. People like you who regard anything out of the norm as autistic have degenerated the term to the point where it bears no meaning other than "I don't like it" - nice pair of 5856s by the way
>>
>>58565880
I got it on sale,and I don't think you can get a 19x19 comfortably on an A4 piece of paper
>>
how does it all fit together? The client, the server, the network, the monies?
>>
>>58565927
autistic as in legitimately bad at communication and unable to pick up on social cues
>>
>>58565965
Thanks for the definition.
>>
>>58565911
well, not quite
https://archive.apache.org/dist/spark/spark-1.1.0/
in a space that moves this rapidly it seems dumb to stick with something from two years ago though
>>
>>58565977
yeah, your response is exactly what i was talking about
>>
>>58565953
i'm >>58565388
Clients and servers are the same thing, and they just grow by adoption
Network is a unstructured peer network with a major reliance on hit and miss statistics (what data was received)
Bitcoin wallets can be tied to TV channels and network peers for donations, although this isn't written in yet (will be later). Donations can be made either directly to the peer, to the creator's wallet, or a payment request can be made for both through a payment request (BIP-0070).
>>
File: hvv.jpg (87KB, 1600x818px) Image search: [Google]
hvv.jpg
87KB, 1600x818px
/g/ I'm working on a server backtrace to put into my client. How do I program it so that the computer screen acts as a gamma ray projector and radiates anyone who tries to hack into my server?
>>
>>58565991
Are you going to keep chastising me?
>>
>>58565991
>implying being nice on the internet is a bad thing
>>
>>58563928
If it's divisible by 400, it's automatically divisible by 100. By saying "if (year % 100 == 0) printf("This year is not a leap year.");" first, you're ruling out the years that are divisible by 400.

Here's how you do it, it's better to start with the larger factors for the aforementioned reason:

If y % 400 == 0 ---> leap year.
Else, if y % 4 == 0 and y % 100 != 0 ----> leap year.
Else ---> not a leap year.
>>
>>58566084
being nice just for the sake of being nice strips it of any actual meaning
>>
File: 1424116310569.png (512KB, 2958x1461px) Image search: [Google]
1424116310569.png
512KB, 2958x1461px
>>58566157
>implying being nice needs a meaning
That implies that being mean should be the default, right?
>>
>>58566175
Telling people their posts were autistic should be the default. Content be damned, we must police the tone and delivery vigorously.
>>
what is /dpt/'s code of conduct
>>
>>58566188
Only a fucking autist would care about unbeing nice woth people, they can't communicate a shit
>>
okay, but for real. What's gonna get me hired as a junior position software developer
>>
>>58566201
Everything is a nail
>>
>>58566175
if there are only two options, yes. but we both know that isn't the case
>>
>>58566205
>cant communicate
>unbeing nice woth people

haha
>>
>>58564283
Why reinvent the wheel? There is already a way to detect whether a year is a leap year using the DateTime class. Or is this a homework assignment?
>>
Is higher rank polymorphism ever useful above rank 2?
>>
>>58566215
and I'm the hammer!
*swings down at you*
>>
Trying to print out values that are stored in a struct as void pointers.
I declare them as ints but I get warning "Cast from pointer to integer of different size".
/* Type for keys in the table */
typedef void *KEY;
/* Type for values in the table */
typedef void *VALUE;

typedef struct TableElement{
KEY key;
VALUE value;
} TableElement;

int main()
{
//Create table
Table *table1=table_create(compareInt);
MyTable *t = table1;
//Insert Values
for(int i=0;i<100;i++)
{
table_insert(table1,&i, &i);
}
TableElement *i = (TableElement*)dlist_first(t->values);
int *keyPtr=i->key;
int *valuePtr=i->value;
printf("Key%d Value%d\n", (int)keyPtr, (int)valuePtr); //ERROR!

return 0;
}
>>
>>58566269
You're printf-ing (int)keyPtr which is type <int *> (8 bytes on 64 bits machine) to an %i (type <int>, 4 bytes on most valuable machines). If you want to print the pointer use %p. if you want to print its value use %i and dereference the pointer, e.g.:
printf("%i %i\n", *keyPtr, *valuePtr);
>>
>>58566329
Thanks!
>>
File: 1480824007300.jpg (332KB, 888x500px) Image search: [Google]
1480824007300.jpg
332KB, 888x500px
>>58562697
I've done some OpenGL in plain C and now I want to use OpenGL with C++, but I don't want the added dependency of a wrapper library since those don't seem to be in the repos for most distros anyway and I don't want people to have to manually install things just to use my shit.
Three choices:
1.) Use a wrapper anyway
2.) Wrap OpenGL myself
3.) Don't wrap it at all
What do?
>>
>>58565852
With that nice center framework starting to develop, it's clear that black > white
Black just needs a cap on the left and the game is over
>>
>>58566408
What wrapper are you even talking about? Just use OpenGL as if you were using it in C except you can use glm which is convenient as fuck
>>
>>58566408
If you don't use exceptions it doesn't really matter. If you do, well, get ready for a lot of catching, freeing, and rethrowing.
>>
File: 1483753218949.jpg (55KB, 600x600px) Image search: [Google]
1483753218949.jpg
55KB, 600x600px
>>58566201
When using threading libraries be careful what you search for. It's easy to hit the search button on a problem you've encountered and then realize you just googled "how to kill all children leaving parent alive."
>>
>>58566475
That's pretty easy though, it's harder to kill all the parents and still get to keep the children
>>
>>58566408
I've used C and OpenGL for a long time. If you want a wrapper for OOP support, don't. OpenGL is a state-machine most of the time and not an OO API (glNamedBuffer* is nice, but old hardware does not support it). Most real world examples (nVidia's papers, etc.) are written in plain C API, so an wrapper will not help you at all.
>>
File: debbuging on windows.png (5KB, 834x39px) Image search: [Google]
debbuging on windows.png
5KB, 834x39px
>there are people on this thread who doesn't program on Windows
How does it feel to be a pleb?
>>
>>58566440
This. GLM is a g*dsend.
Additionally, the RAII techniques in C++ make a fair bit of code cleaner and better guarantees.
>>
>>58566552
>There are persons in this thread who doesn't speaking American properly
Go home, Pajeet.
>>
>>58566602
>Additionally, the RAII techniques in C++ make a fair bit of code cleaner and better guarantees.
But you need to wrap everything for it to help.
>>
>>58565861
Have you seen the rest of /g/? Bring back /prog/, for fuck's sake.
>>
>>58562697
Where did the height and weight come from?
>>
>>58565861
>>
>>58566678
This.
Bunch of fucking weenies and redditors on this board.
>>
File: lena-oats.png (555KB, 512x512px) Image search: [Google]
lena-oats.png
555KB, 512x512px
Lena, please spare me some oats
>>
>>58566762
>tfw lenna will never haunt your pigsty
>>
>>58566652
It's not that bad in my experience. A barely 100 line wrapper header file saves more lines than it spends over the course of a non-trivial OpenGL application.
>>
can i learn javascript first and html later?
>>
>>58566901
Yes.
>>
>>58566901
sure. it's a programming language
i don't know why one would want to use it outside of the browser but it is done
>>
File: e_to_x.png (12KB, 490x360px) Image search: [Google]
e_to_x.png
12KB, 490x360px
What do you think of my code, /g/
>>
>>58566924
He didn't mention any programming languages in his post.
>>
File: Capture.png (249KB, 339x478px) Image search: [Google]
Capture.png
249KB, 339x478px
How useful is this book in regards to getting an internship?

What exactly is the first step towards getting an actual internship?
>>
>>58566999
>C++
It's complete garbage.
>>
>>58567007
;-;
>>
>>58566999
f 'e' = 'x'
f c = c

interact (unlines . map f . lines)
>>
Serious question.
Why would you want a function inside a function (i.e. closure)?
How do you pass a function? It's not some variable with data.
>>
>>58567026
>it's not some variable with data
that's where you're wrong kiddo
>>
>>58566999
how can i invest in this
>>
>>58567006
Apply for a bunch of related internships that you don't want and use the interview experience to get the one you want.
>>
>>58567033
Hire me when I graduate in two years.
>>
>>58567031
Please elaborate, mister
>>
>>58567054
functions are regular values just like anything else


at least that's what they are in real programming languages
>>
>>58567021
I think I follow your logic, but I have no idea what you're actually doing.
>>
>>58567026
>(i.e. closure)
Be careful with saying that. A closure isn't "just" a nested function. It captures the state of the surrounding function.
>How do you pass a function? It's not some variable with data.
In a language like C where functions cannot be nested, you just pass a pointer to the start of the executable code; a function pointer.
However, in many languages, you can consider functions to be data that can be generated at runtime and pass around like any other value.
>>
>>58567062
whoops, should be map (map f)
>>
>>58566999
This isn't portable. What if you want to port this program to a system without the so-called "ENTER" key?
>>
File: 1464632537832.png (6KB, 412x141px) Image search: [Google]
1464632537832.png
6KB, 412x141px
>>58567062
>>58567072
>>
>>58567076
I got ripped apart last time for using system("pause"), so I thought cin.get() would be a better alternative.
>>
>>58567021
Is the unlines/lines really neccesarry?
Why can't you just 'map f'?
>>
>>58567126
not really necessary
>>
>>58567122
The best thing is to do nothing at all.
There is absolutely no reason to pause the program at the end to wait for user input.
>>
Elm, Rust, Haskell, or Idris?
>>
>>58567148
Rust, unless you don't actually want to do anything useful.
>>
>>58567139
I'm running out of VS Express, so unless I output the data to a file, I wouldn't be able to view the results.
>>
>>58567157
I want to write a COBOL to JavaScript transpiler.
>>
>>58567164
That's retarded.
I'm sure you can configure your shitty IDE to leave the window open after the program has finished.
>>
>>58567168
But why
>>
>>58567148
Haskell until Idris is actually any good
>>
>>58567168
Then do it in assembler
>>
>>58567184
if they didn't waste their time writing junk like this, they would feel bad about doing nothing or, even worse, actually doing something important
>>
>>58567217
define "something important"
>>
>>58567220
working out, socializing, maybe reading a book that isn't programming related, going outside and getting some fresh air, etc.
>>
>>58567231
YOU JUST DONT UNDERSTAND, MOM
>>
>>58567231
programming is important to some people
>>
New thread:
>>58567241
>>58567241
>>58567241
>>
>>58567231
not programming related? like physics texts?
>>
>>58564176
Kill yourself.
>>
>>58567026
>How do you pass a function?
More or less like anything else. Details may vary.
>>
>>58566999
>void main()
>>
>>58565499
you're trying way too hard dude
>>
>>58565888

Mostly my master's research. Which is a pain in the ass because it's all in the Windows kernel, and it's hard to test shit.
>>
>>58567007
why? try to hold back your epic maymays and actually explain why.
>>
File: 1476867766698.png (202KB, 1000x1000px) Image search: [Google]
1476867766698.png
202KB, 1000x1000px
>>58562697
Rolling for Male(Pussy)
>>
>>58566924
>i don't know why one would want to use it outside of the browser
NodeJS mostly.
>>
>>58567252
yeah I do the same thing
>>
>>58567164
Running out of VS Express? Why don't you use VS Community 2015?
Thread posts: 327
Thread images: 35


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