[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: 333
Thread images: 30

This is /dpt/, the best subreddit of /g/

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
Fuck off, stop posting new threads before the old one actually dies.
>>
File: qKC8hYk.webm (979KB, 720x404px) Image search: [Google]
qKC8hYk.webm
979KB, 720x404px
Ask your beloved programming literate anything.

>>52611684
Thank you for umaru.
>>
>>52611701
after the bump limit is ok

old discussions can finish off while the old thread still has a bit of life in it and new discussions can start in the new thread
>>
>>52611684
It's not funny anymore, anon.

You're just being insufferable.
>>
>>52611725
No, fuck you.
If the old thread is still on the catalog then you're throwing out what might be a quality thread off the board.

Your shitty attitude at an arbitrary posting limit immediately deprecating the old is exactly what's contributing to the decay of the board.
Look at the OP. You're letting this retarded shit happen.
>>
>>52611762
this only happened because some mod went and deleted the one with the pink haired girl
>>
>>52611701
is there a working version of sleepsort?
I mean
take list, take empty list, put object to according index in empty list
crunch list at the end so you don't have empty indices?
isn't that faster than most algorithms for simple shit?
what is it called?
>>
>>52611762
umaru + reddit + coc is still better than the trap shit
>>
>>52611776
forget the quote, that was a mistake
>>
>>52611770
This only happened because some autist decided that it's okay to shit up /g/ just to have his retarded slogan and OP image on the board.
>>52611780
Fuck you.
>>52611776
Network sort is the version of sleepsort used in hardware.
Whatever you're saying after that is complete nonsense and unrelated to sleepsort.
>>
>>52611795
i'm not even OP

you're the one shitting up the thread
>>
>>52611811
Your thread was garbage the moment it was made.
>>
>>52611795
>Whatever you're saying after that is complete nonsense and unrelated to sleepsort
either you don't know what sleepsort is, didn't read what I wrote at all or you are stupid as fuck

what I wrote there is sleepsort sorting a list in a list and not printing it out
you are retarded and that triggered me a little because I had to explain it to you eventhough it's very easy to understand
>>
File: hmm, yes.jpg (34KB, 396x303px) Image search: [Google]
hmm, yes.jpg
34KB, 396x303px
>>52611815
>>
>>52611811
>you're the one shitting up the thread
It is already a shitpile. This place is not reddit, and this place has no code of conduct. If you want to see that shit so much, go somewhere else. You do not have the power to add code of conduxt to a thread, and pretending to do only causes more shitposting. I definitely am going to post about jews the moment I see the opportunity now.
>>
>>52611822
You explain things like you're shitting in the streets.
You don't even know what sleepsort is.
You can't sort lists using sleepsort because they don't have objective numerical values. The only way you can provide one is to use a hashcode, and sorting a hashcode is meaningless.

How about you try and figure out what you actually want to do? Alternatively stop shitting in the streets.
>>
>>52611850
kill yourself

the OP doesn't mean much, not even if it's a trap thread

you're just making it worse and people sure as hell aren't going to stop posting threads around the bump limit just because you tell them to

go ahead and talk about jews if you want
>>
>>52611869
I will.
>>
>>52611869
The OP and posts immediately after it dictate the content of the thread, so go fuck yourself.
Enjoy having a thread full of armchair economists when some retard decides to post an OP involving "GPL".
>>
>Want to add a global clipboard listener to my application
>Every single example online is antiquated, incomplete and completely deprecated

Just fuck my shit up.
>>
>>52611887
GPL is communism in any sensible definition of the word. even if it doesn't fit your definition of the word communism, you should be able to get the gist of what is meant by people who call GPL communism.
>>
>>52611854
>shitting in the streets
you epic memer you
keep me posted on your memes please
>You can't sort lists using sleepsort because they don't have objective numerical values
wow
why do you even bother replying to me when you have absolutely no clue about sorting algorithms?
holy shit /g/
>>52611850
>getting trolled by OPs anime, reddit and coc shitposting so hard you have to shitpost until we reach 300 posts again and OP starts another thread you try to shit up from the start and so on

really
get some fresh air you sucker
>>
>>52611903
stop using Cshart you cuck
>>
>>52611914
this is one mad pooinloo
>>52611908
You fail to understand
https://rbt.asia/g/thread/S52044724#p52045304
>>
>>52611925
ok?
>>
>>52611914
>really
>get some fresh air you sucker
The solution is simple. Do not talk about programming in bait threads. Make a new proper thread and let idiots have their own reddit thread.
I was contributing to the previous one. I won't to this.
>>
>>52611925
Oh I remember that thread.
I made it.
/dpt/ was already talking about the feasablity of stealing GPL code for use in your proprietary software long before that thread got made
>>
>>52611925
>show how retarded you are, on /g/ of all places
>y-you are poo in l-loo!
you sure showed me
>>
>>52611921
Can you start using a trip so I can filter you? Thanks.


Anyone know how to get C# .NET45 to listen to the clipboard? Every example I've found so far doesn't seem to work, tries to override things that don't even exist and shit.
>>
>>52611948
>show how much you suck at basic English
>somehow expects to not be called a scumsucking indian
>>
>>52611684
I fucking hate umaru or whatever this abomination is called.
Bring back Yuki you soulless motherfuckers.
>>
>>52611958
Wir können das Gespräch auch einer in meiner Muttersprache führen
Wo habe ich denn größere Fehler gemacht?
>>
>>52611976
-einer :^)
>>
Writing a C compiler in a combination of Pascal and C.
>>
>>52611976
>>/krautchan/
>>
>>52611976
OK. Maybe they'll take your pedo ass over in Krautchan, I hear it's got a large following over there.
>>
>>52611984
A jew created pascal. Take a few moments to consider this before you proceed.
>>
>>52611996
That makes sense.
They have higher IQs.
>>
>>52611996
Ok I'll do it in C.
>>
>>52612008
Joke's on you, dumbass, it was a swiss dude.
>>
>>52612022
https://en.wikipedia.org/wiki/History_of_the_Jews_in_Switzerland
>>
>>52612025
It is a simple fact that he was not a jew.
>>
>>52612035
Simple facts are for simple minds
>>
>>52611954
lmfao
>>
>>52611954
>needing a safe space
inb4 "it's different for me"
>>
>>52612099
Got no problem with shit talk, he's just not very original, it's just irritating at this stage.
>>
>>52612129
keep on posting your Cshart issues keeps me entertained
>>
Aah
The fresh scent of drama in the morning!
>>
>>52612129
>it's just irritating
free speech doesn't mean annoying speech
>>
Shouldn't America already be asleep? Why is this thread so garbage?
>>
>>52612181
Umaru OP
>>
>>52612181
telling signs, anon
>>
>>52612181
Because Umaru
>>
Erk
>>
if (pattern->size.x - i < subpattern->size.x ||
pattern->size.y - j < subpattern->size.y) /* bounds checking */
break;


is there a better way to write this?
>>
>>52612224
fold((||), zip((<), zip((-), pattern->size, {i,j}), subpattern->size), true)
>>
>>52612252
Unreadable sheit
>>
finally got around to start logging what users are doing when they try to login/reset password and fail
jesus christ these people are stupid

i also saw someone trying to change his password to "cocainemonkey1337", made me kek
>>
File: that means you.jpg (196KB, 396x598px) Image search: [Google]
that means you.jpg
196KB, 396x598px
>>52612280
>>
>>52612289
my passwords are also inherently stupid
pretty good passwords tbqhwy
>>
File: just2.png (1MB, 861x646px) Image search: [Google]
just2.png
1MB, 861x646px
>>52611954
JUST
>>
>>52612316
Good.
>>
Why is clojure growing in popularity?
Looks fucking horrible.
(defn square-mat
[n e & {:keys [implementation]
:or {implementation :persistent-vector}}]
(let [repeater #(repeat n %)]
(matrix implementation (-> e repeater repeater))))


If you want lisp and jvm there is kawa scheme which seems way better than clojure.
>>
>>52612252
*false
>>
>>52612373
Pleb
>>
>>52612350
clojure is designed for concurrent and distributed programming (async, stm, ...)
>>
File: sqrt2.jpg (50KB, 861x653px) Image search: [Google]
sqrt2.jpg
50KB, 861x653px
>>
>>52612423
better off going with f#
>>
>>52612469
why ?
>>
>>52612336
554.37Hz
>>
>>52612479
async { }, Parallel, .NET, agent systems

non-shitty syntax
>>
File: 2000px-Groovy-logo.svg.png (152KB, 2000x990px) Image search: [Google]
2000px-Groovy-logo.svg.png
152KB, 2000x990px
Does anyone even use the Groovy programming language?
>>
How is Scheme for working with textual data?
>>
>>52612617
No
>object oriented scripting
And we should be bloody thankful for that
>>
File: feardisgust.gif (2MB, 380x285px) Image search: [Google]
feardisgust.gif
2MB, 380x285px
>>52612617
>groovy

Haskell GHC:                    0.454930841 seconds time elapsed
OCaml: 0.747779583 seconds time elapsed
Java OpenJDK: 1.189619693 seconds time elapsed
Groovy: 19.214711418 seconds time elapsed
>>
>>52612722
Where do you get those meme benchmarks?
>>
File: trans crab.png (49KB, 1200x800px) Image search: [Google]
trans crab.png
49KB, 1200x800px
So, despite the sjw and communism memes, what is wrong with Rust and why don't you want to use the language of 21 century?
>>
>>52612793
i dont know shit about it actually
what does it do better than existing languages and why is it worth abandoning larger libraries, better tools, better compilers and all the other meta stuff already assosciated with popular languages?
>>
>>52612937
It's C done right with a lot of FP features.
>>
>>52612793
I tried writing a simple compiler in it, but after many iterations I just couldn't stop wrestling with the language for doing basic things.
>>
>>52612980
Not C, but C++, desu.
>>
>>52613012
Yeah, you need at least a month of practice so you won't have problems with the borrow checker and other things. But after that it should be ok.
>>
>>52613015
Rust isn't really OOP in the sense that C++ is. It's more comparable to C with safety and FP features.
>>
File: c4VZPIA.jpg (388KB, 1280x960px) Image search: [Google]
c4VZPIA.jpg
388KB, 1280x960px
>>52612793
i have already moved to ark
http://ark-lang.org/
>>
>>52612793
I've heard it has insanely poor compile times
>>
>>52613097
Wtf is this meme language. What have they changed in their version of C, except syntax?
http://nim-lang.org/
>>
>>52612793
the syntax looks dumb
>>
>>52613050
It's not the borrow checker I was having trouble with, just the syntax in general.

Compare my first attempt to my final iteration before giving up:
struct Parser<'a> {
source: &'a str
}

macro_rules! parse_or {
( $parser:ident, $( $f:ident ),+ ) => {
{
$(
if let Some(x) = $parser.$f() {
return Some(x);
}
)*

None
}
};
}

impl<'a> Parser<'a> {
fn new(source: &str) -> Parser {
Parser { source: source }
}

fn skip_whitespace(&mut self) {
for (i,c) in self.source.chars().enumerate() {
if !is_whitespace(c) {
self.source = &self.source[i..];
break;
}
}
}

fn parse_atom(&mut self) -> Option<Token<'a>> {
self.skip_whitespace();

for (i,c) in self.source.chars().enumerate() {
if is_whitespace(c) {
let ret = Token::Atom(&self.source[..i]);

self.source = &self.source[i..];

return Some(ret);
}
}

/* end of file */
let ret = Token::Atom(&self.source);

self.source = "";

Some(ret)
}

fn parse(&mut self) -> Option<Token<'a>> {
self.skip_whitespace();

if let Some(x) = parse_or!(self, parse_atom) {
return Some(x);
}

None
}
}
>>
>>52613261
Last attempt:
use Result::*;

enum Result<'a, T> {
Done(Stream<'a>, T),
Fail(Stream<'a>)
}

enum Token<'a> {
Atom(&'a [u8]),
}

impl<'a, T> Result<'a, T> {
fn map<U, F>(self, f: F) -> Result<'a, U>
where F: FnOnce(T) -> U
{
match self {
Done(s, x) => Done(s, f(x)),
Fail(s) => Fail(s)
}
}
}

struct Stream<'a> {
data: &'a [u8],
pos: usize,
fail: bool
}

impl<'a> Stream<'a> {
fn advance(self, n: usize) -> Stream<'a> {
Stream { pos: self.pos + n, ..self }
}

fn collect(self) -> Result<'a, &'a [u8]> {
if !self.fail {
let (res, new) = self.data.split_at(self.pos);
Done(Stream { data: new, pos: 0, ..self }, res)
} else {
Fail(self)
}
}

fn satisfy<P>(self, pred: P) -> Stream<'a>
where P: FnOnce(&u8) -> bool
{
if !self.fail {
match self.data.get(self.pos) {
Some(c) if pred(c) => self.advance(1),
_ => self.fail()
}
} else {
self
}
}

fn many<P>(mut self, pred: P) -> Stream<'a>
where P: Fn(&u8) -> bool
{
if !self.fail {
while self.pos < self.data.len() &&
pred(&self.data[self.pos])
{
self.pos += 1;
}
self
} else {
self
}
}

fn fail(self) -> Stream<'a> {
Stream { fail: true, ..self }
}

fn mark(self) -> Stream<'a> {
Stream { data: &self.data[self.pos..], pos: 0, ..self }
}
}

// parses "ello"
let x = Stream { data: "Hello, world!".as_bytes(), pos: 0, fail: false };
let y = x
.satisfy(is_letter)
.mark()
.many(is_letter)
.collect()
.map(Token::Atom);
>>
>>52613232
ownership
pattern matching
generics
operator overloading
modules
references
interfaces
better type system (fuck typedef)
>>
>>52613261>>52613278
I am just autist, the syntax is ok for me, tьh : ^ )
>>
File: 1452154219311.jpg (65KB, 480x640px) Image search: [Google]
1452154219311.jpg
65KB, 480x640px
>tfw scared as fuck of growing old and becoming a shit programmer because brain starts functioning worse
programming is all i have right now, dont take it away from me
>>
>>52613366
yeah, but this c-like memory allocation. why?
>>
File: pepe-ball.jpg (24KB, 400x530px) Image search: [Google]
pepe-ball.jpg
24KB, 400x530px
>>52613416
I know that feel
>>
>>52613422
because it is simple and people knows how to work with it?
>>
>>52613261
>>52613278

I selected Rust to do a PL project on. Wish me luck. :^(
>>
File: yalta.jpg (233KB, 599x431px) Image search: [Google]
yalta.jpg
233KB, 599x431px
>>52613500
> because it is simple and people knows how to work with it?
I thought they want to solve C's problems.
>>52613509
Good luck, anon.
>>
>>52613416
>>52613451
As long as you keep up even moderately with the progress of technology you will outdo your younger peers 9/10 times.

Experience >> youth.

A 50 year old greybeard might output less LoC per day but will always output the right LoC, contrary to the fresh college grad who wants to try "this awesome idea I just had" only to find out later that it was not so great and that the same idea is actually 40 years old and was rejected for very solid reasons back then.
>>
>>52608260
You need to use a bigdecimal class.
This is why everyone thinks calculators are shit easy, actually try to implement decimal entry properly and find out that even double precision is useless.
>>
>>52611720
>no sound

At least you tried
>>
>>52611762
you need a pause
>>
>>52612722
>ocaml slower than haskell
Fake/10
>>
>>52613097
So do you use anarky or the official ark branch?
>>
File: qzqupqczkz6vqko.jpg (212KB, 580x871px) Image search: [Google]
qzqupqczkz6vqko.jpg
212KB, 580x871px
>>52614243
GHC is considered to be one of the most advanced compilers if not the state of art one.
>>
>>52614327
In the sense that it's complex. OCaml is widely known for being ridiculously fast, significantly faster than haskell in most benchmarks.
>>
>>52614368
probably for trivial crap like fizzbuzz.
Same as those benchmarks that claim that JIT compiled Java is faster than C.
>>
>>52614471
Haklelfags are always so funny with their delusions.
>>
>>52614771
Not as funny as you with your orthography.
>>
How do I install OCaml packages on Windows? Specifically core.
>>
>>52614809
With opam.
>>
File: 1452389244118.jpg (101KB, 666x476px) Image search: [Google]
1452389244118.jpg
101KB, 666x476px
>no racism no insult no sexual harassment no gender discrimination
Go suck a trannydick you fucking retarded gay nigger
>>
>Decide to work on webcrawler for a friend
>Open up the site he needs crawled
>Jump into the source
>It's absolutely pig fucking disgusting

Who /regret/ here?
>>
I'm gonna make my own 2d OpenGL engine. I made a 3d one in java, I want to do this in C++. I only know how to program in C, do I need an IDE for C++? I am running Xubuntu
>>
>>52611684

what does umaru smell like
>>
>>52614893
vim
>>
>>52614813
I tried compiling opam for Windows but it doesn't work.
>>
>>52614941
It does. Stop being inbred.
>>
File: hello rato.png (699KB, 957x1069px) Image search: [Google]
hello rato.png
699KB, 957x1069px
Question about Python
I have a program, it works like this:
inside function 1 it generates a random nr, then it proceeds to function 2 which takes that number and searches for a line inside a textfile which matches that random number.(using a for cycle and an if cycle inside of it)
Then the line from the file is given and program returns to function 1, where again a new random number is produced. The new random number then proceeds to function 2, but it seems that in the function 2, the linecounter has stopped at the position of the first random number, meaning that only values higher than the first random number work and in case of lower value the program doesn't work anymore. Any help?
code in function 2 is basically looking like this:

for line in file:
line.strip
line.split
if randomnr in line[0:2]:
print nr
function1()
>>
>>52615156
hello rato
>>
>>52615156
hello rato
>>
>>52614904
potato chips, cola, and autism
>>
>>52615156
hello rato
>>
File: S01E05P062_Louis.png (484KB, 1280x800px) Image search: [Google]
S01E05P062_Louis.png
484KB, 1280x800px
>>52615156
That rat looks eerily like Louis Litt from suits.
>>
>>52614904
Dicks, obviously.
>>
File: albanian virus.jpg (13KB, 480x209px) Image search: [Google]
albanian virus.jpg
13KB, 480x209px
>>52615156
any help would be nice aswell
>>
>>52615052
No it doesn't, it relies on a lot of UNIX tools not available on Windows. Trying to compile spits out a million error messages to that effect.
>>
I need to build a website by 12 midnight. I'm learning dreamweaver as I go. Any HTML competent anonimes here?
>>
>>52615727
what kind of website. Heavy on CSS?
>>
Hey guys, am I a faggot for writing my loops using the prefix operators, e.g.

for (int i = 0; i < MAX; ++i) {
// code
}


I generally always use the prefix operators, where appropriate. I always assumed it was more efficient since a copy of the old value does not have to be created.
>>
File: bitch no.jpg (40KB, 346x340px) Image search: [Google]
bitch no.jpg
40KB, 346x340px
>>52615727
<p>
<marquee Bgcolor="yellow" color="red">don't</marquee> learn <blink>proprietary software</blink>
</p>
>>
>>52615765
No, you're a faggot for a variety of other reasons.
>>
>>52615765
first,
i<MAX
my eyes...

and no. Prefix operators are encouraged.
>>
>>52615765
You're a faggot if you use postincrement since semantically you mean preincrement.
>>
alexanderdwyer.co.uk is the site address

i've copied to source code, managed to put my logo in place (dreamweaver is quite intuitive with split-view), struggling to change the moving header images and change colours.

>>52615791

>nice_proprietary_software_faggot.png
>>
>>52615818

meant for

>>52615754

Essentially, I want to keep 95% of it the same, just change a few bits and pieces like button colours, images, logos, etc. I can change text myself.
>>
>>52615697
I'm sorry that you're retarded because it means one more person on Earth whose sole use is to waste my time.
>>
>>52615793
Probably so. Thanks, man!

>>52615795
Yeah, sorry, I'm a faggot, so I do that kind of stuff.
>>
>>52615870
Stop talking shit. If you didn't want to help you shouldn't have said anything instead of trying to act tough on the internet.

https://github.com/ocaml/opam/issues?utf8=%E2%9C%93&q=is%3Aissue+windows

Without using cygwin and jumping through considerable hoops, opam does NOT work on Windows. Even if you can get a binary to compile half the packages are broken on Windows and won't install.
>>
>>52615926
It's too bad you're clinically retarded. Maybe one day there will be another cure for the likes of you than heavy use of helium or cyanide.
>>
Alright /g/ I don't understand the question posed here: http://codingbat.com/prob/p196409

>We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order.
>For example, the largest mirror section in {1, 2, 3, 8, 9, 3, 2, 1} is length 3 (the {1, 2, 3} part).
> Return the size of the largest mirror section found in the given array.
>maxMirror({1, 2, 3, 8, 9, 3, 2, 1}) → 3
>maxMirror({1, 2, 1, 4}) → 3
>maxMirror({7, 1, 2, 9, 7, 2, 1}) → 2


>maxMirror({1, 2, 1, 4}) → 3
Can someone explain why this example is 3?
>>
>>52615156
There should be a function to rewind the file to the beginning. But a better method would be to generate a list of numbers to search for and only go through the file once.
>>
>>52616130
My guess is because it goes
1 to 2 back to 1 and thus making +1 +1 -1
>>
>>52616130
1, 2, 1 is a palindrome (same in reverse).
>>
>>52613366
What language are you talking about?
>>
>>52616196
That is what I meant with.
>>52616187
But I lack the vocabulary.
>>
File: ka.gif (149KB, 500x400px) Image search: [Google]
ka.gif
149KB, 500x400px
>>52616213

>>52613097
>>
>>52616291
And what language was he talking about?>>52613232
>>
Hey /dpt/, I'm pretty new to Java programming. I'm making an android app and I'm trying to make it save files that you make and display them in a display page. My IDE isn't showing any errors, but when I run my app it's not displaying what I want it to. Here's what I have so far:
        String filename = "myfile";
FileOutputStream outputStream;
try {
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(MyActivity.EXTRA_MESSAGE.getBytes());
outputStream.write(MyActivity.EXTRA_DATE.getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}

try{
FileInputStream line = openFileInput(filename);
TextView savedText =(TextView)findViewById(R.id.savedText);
//line.read();
int input = line.read();
savedText.setTextSize(20);
savedText.setText(input);
line.close();
} catch (Exception e){
e.printStackTrace();
}

Can anyone tell me what I'm doing wrong? I spent several hours on this already, any help is appreciated.
>>
>>52616130
import Data.List

maxMirror list = maximum . map length $ filter mirror subsequences
where
subsequences = concatMap inits (tails list)
mirror list = any (== reverse list) subsequences


Incredibly naive approach, how did I do?
>>
>>52615156
hello rato
>>
>>52614893
Code Blocks is based
>>
>>52615156
hello rato
>>
I'm trying to generate a datagrid dynamically (which I've managed just fine)

However I've got an "ObservableCollection<List<string>>" that I want to bind to it

Each List<string> should represent one row (each string representing a column).

I'm not sure how in the hell I'm meant to bind each individual column to each individual index - I'm not sure how to access a collection within a collection to even try.
>>
Is there a language worth learning for someone who has nothing in mind with what they'd do with the knowledge?
>>
>>52615156
try .seek()
>>
>>52617138
Go.
>>
>>52611684
>being a hamsterposter
>calling threads subreddits
>>
>>52617173
>being a newfag
>2016
>>
>>52617138
C++, Python, C#, or Java.

Only because when you finally decide:
>I WANT TO DO THING
there will be a StackOverflow post or article:
>HERE'S HOW YOU DO THING
>>
>>52617138
OCaml. It's very high-level, yet extremely fast. It's used a lot in industry, including at facebook and bloomberg, and it has many high-quality libraries.
>>
What's the recommended book for learning machine learning.
>>
>>52612793
::


>2016
>Still using siamese twins
>>
It's possible to get complete minimalism in a language

you just interpret the number of inputs in a language into other commands, you can translate it into brainfuck and then anything else

. is +
.. is -
... is [
.... is ]
etc.

neat idea, i think. Apparently chicken does this exact thing
>>
>>52616196
>palindrome
What's a palindrom?
>>
>>52617327
Runs like ass on Windows, though.
>>
>>52617640
Not if you compile natively like you should.
>>
>>52611684

Nigger fuck you lets fuck you useless woman
>>
>>52617659
Pretty much the only way to get it running properly is through Cygwin.
>>
>>52617327
>used a lot in industry
LOL, don't be delusional.
>>
>>52617714
No it's not. There's a windows release on the opam sitte.
>>
>>52617753
Those are just binaries and doesn't actually include opam. To compile opam and use 99% of the packages you need to run it in a Cygwin environment.
>>
we should rename these threads daily programming shitposting fest


are operator overloadings considered idioms?
I don't get the definition of idioms entirely
>>
>>52617796
No.
>>
>>52617618
kek
>>
void bad(int **out)
{
int on_stack[32];
*out = (int *)on_stack;
return;
}


This code is massively simplified but is this the sort of bug that a compiler can catch in the general case or does aliasing completely break things? Had a friend come to me confused and wanting help debugging his code because he had an array initialized on the stack in a function that returned so parts of the array got overwritten by proceeding function calls.
It seems to me like it could be protected against pretty easily since you would end up with out pointing to something on the stack, past the stack pointer but not in the heap.

>>52617615
Check out Unary and Golunar. They take idea this just about as far as you can take it.
https://esolangs.org/wiki/Unary
https://esolangs.org/wiki/Golunar
>>
>>52617824
Show me your working opam install on Windows without Cygwin, then.
>>
>>52616130
my guess is it's just measuring the length of {1, 2, 1}
>>
>>52617896
http://opam.ocamlpro.com/
>>
>>52617737
https://ocaml.org/learn/companies.html
>>
>>52617869
can you explain to complete idiot what does
 **out 
do?
>>
>>52618002
Pass a 2D integer array by reference.
>>
>>52617869
In C++, RAII is the default. The compiler can't catch this error because it assumes you know what you're doing. The reason your friend had so much trouble is because he doesn't understand the RAII idiom.
If he understood it to the point that it would be second nature, he wouldn't have this problem.

It may be possible for a static analyzer to realize that something is wrong, but I wouldn't leave it up to a tool to figure out anything other than that people are properly following guidelines.
>>
>>52618002
>>52618015
It's a pointer to a pointer to an int. It can be used for a 2D array, but doesn't have to be (and isn't in this case).
>>
>>52618002
It's a pointer to a pointer to an integer. You'd have something like this elsewhere:
int *arr;
bad(&arr);
. You call bad, passing in a pointer to the thing you want it to do stuff with and it does stuff to it. >>52618015
Just a 1D array
>>
>>52618069
>pointer to a pointer

how much pointers to pointers can you do?
>>
>>52618090
As many as you need.
Logically speaking there's no limit to indirection.
>>
>>52617201
>defends calling threads subreddits
>calls others newfags
Kek
>>
>>52618110
>being buttblasted that someone ironically called something here a reddit
>>
>>52618090
Like >>52618103 said, as many as you want, I'm not aware of any limit. In practice it's rare to go more than 2 levels deep.
>>
>>52618140
>waah that was ironical
Sure thing m8
>>
>>52618209
Not him, but it was ironical

Basic memeing 101
>>
Making a prime spiral generator. So far I've got a boolean function to determine if a number is prime, and the basic setup for a Swing window. Next up is drawing a square spiral.
>>
>>52617958
That's not a lot
>>
>>52618518
that's enough for me.
>>
>>52618541
but not enough to legitimately claim:
>used a lot in industry
>>
>>52618556
It is though.
>>
>>52618448
>Swing
we got a pajeet in here lads
>>
>>52618751
then COBOL is also used a lot in industry.
>>
>>52618777
YOU'RE a pajeet jerk stupid
>>
>>52617948
What's the point of that link? I asked you to show me your working opam install on Windows without Cygwin.
>>
What graphics driver do I need on linux for my 980 ti senpai?
>>
>>52618777
shut up pajeet i fuck your mother fucker like camel
>>
>>52618777
We've known that for awhile, just mention C and he'll make himself known
>>
Dicking around with pygame atm.

Not even sure why- just want to learn some python that isn't fucking manipulating excel.

I'm barely a hobby coder, but fuck me I'd prefer to be a developer than an analyst
>>
Done.
>>
>>52619064
For what purpose? I love python as a quick production tool, but you'll spend more time on pygame on game programming patterns where you will be less focused on python's strong points.

Though I won't argue it'll be a fantastic experience trying a unique workflow, considering the language is vastly different than usual gamdev languages
>>
>>52619092
What is it?
>>
>>52619108
Prime spiral. It's a square spiral, starting from the center. Black dots are prime numbers.
>>
>>52619120
The center is 2?
>>
>>52611854
Calm down
>>
>>52619092
Can you plot and windmill of friendship and tolerance out of prime numbers?
>>
File: 2016-01-25_13-03-31.png (12KB, 442x436px) Image search: [Google]
2016-01-25_13-03-31.png
12KB, 442x436px
>>52619131
At the very center should be a white dot for 1 if I understand my own code properly
>>
>>52619179
>>52619092
pajeets are back lads
>>
>>52618778
In the same sense as C: only in legacy software, not in current-day software - unlike the likes of ocaml.
>>
>>52619199
Oops, it looks like the 1 might be accidentally skipped. Must amend code.
>>
>>52619235
>>
Does anyone know if there is an optimized leaderboard ranking algorithm? I've been given the task of inserting a score into a leaderboard and having all the rankings for that leaderboard updated and ready to display a few seconds later. On my own, I've come up with a 3root(N)/2 solution, which I think will suffice, but I'm curious if there's an O(log(N)) solution.
>>
>>52619543
Ranking based on what?
>>
>>52619570
y'mum
>>
>>52619570
Score. For simplicity, just consider one list of a million scores, ordered highest to lowest. I want to be able to put a new score in there and then, two seconds later, be able to accurately tell you the position of any given score in that list. Linear time has already been rejected.
>>
>>52619691
Binary search trees? Make the key the score and the value a list of player ids. Pick one that specializes in insertions.
>>
Has anyone worked with boost spirit? It seemed easier to use than flex/bison for my current project because of extensive c++ use.
>>
File: 1453694583117.png (260KB, 563x542px) Image search: [Google]
1453694583117.png
260KB, 563x542px
>>52619866
>boost
>C++
>>
>>52619716
This is going in a database, not in memory. Though maybe the same concept could be applied - I'll think about it. The problem as I've been presented it is a little more complicated than the one I've presented, but I think you may be onto something.
>>
>>52619885
And?
Different languages are better at different goals. If you have a better solution for a build system with script parsing than C/C++ I'd love to hear it. Seriously.
>>
>>52619885
Wow, great contribution man. Keep up the great work. Looking forward to seeing your resume.
>>
File: 1453695267087.gif (1MB, 320x200px) Image search: [Google]
1453695267087.gif
1MB, 320x200px
>>52619920
>putting glorious C next to shitty C++
>using either for script parsing
>>
>>52619948
Quit frog posting and be useful for once. What would you use for script parsing?
>>
>>52619907
I don't think there are any options to pick from when using a database. Just optimize your query and/or tune the engine.
>>
>>52619985
*there are _no_ options
>>
>>52619985
Well, testing my options brought me from N time to root(N) time, so I'm hesitant to stop looking for a log(N) solution. But, I'm inclined to agree - all the good logarithmic algorithms for this are in-memory operations.
>>
>>52619948
>C
>glorious
>bashing C++ at the same time
Oh the irony. I bet you don't know shit about C anyway. I bet you think C can do r-value references and move operations.
>>
Wait, a BST/b-tree actually solves nothing about this leaderboard problem. You can't derive accurate rank information from it any faster than linear time. Welp, I'm more sold on my own solution then.
>>
Will learning maths change the way I think about programming?
>>
File: IMG_20151209_230220.jpg (35KB, 469x527px) Image search: [Google]
IMG_20151209_230220.jpg
35KB, 469x527px
Can you find me a problem that is easier to solve imperatively than functionally?
>>
programming is the last refuge of the free man
>>
File: 1446250682308.jpg (33KB, 438x189px) Image search: [Google]
1446250682308.jpg
33KB, 438x189px
>>52620805
*the second amendment
>>
>>52620589
A*
>>
>>52621019
Literally recursive by design so no.
>>
I'm a complete noob faggot and I'm learning python. Is there an elegant one-liner way to stop the current iteration of a while loop (and repeat it from the start) without breaking it completely?
>>
>>52621031
To do it efficiently in pure FP you need complex data structures.
>>
>>52621044
if it's like, while i < 100, just make i = 0 on your condition to restart?
>>
>>52618777
What's the white man's way of doing graphics?
>>
>>52621085
It's important that i stays the way it is however, and I'd hate to wrap it in another while loop, it feels too much like a messy way to do it.
>>
>>52621116
Add another condition check in your while with &&?
while (i whatever && j whatever)
>>
>>52621086
not Java
>>
People still use Swing? It's been deprecated for years.
>>
>>52621068
Quite the contrary.
>>
>>52621134
I don't think that'd be of any benefit here. What I'm at is
while i < 100:
if blahblah: break #kills the whole thing
elif blahblah: #break loop and start again
else: #do lotsa stuff (involving i)

I want something simple for the elif command. Is there a built-in command like "break" that only kills one iteration of the cycle?
>>
>>52621148
It's easy and comfortable
>>
>>52621044
>>52621116

Repeat what from the start? Like start the entire loop over, or just start the current iteration over?

If start the loop over, then why does i need to stay the same? If restart the current iteration, then do something like:
for(int i=0; i<whatever; i++) {
...
if( condition ) {
i--;
continue;
}
...
}
>>
>>52621178
Show me an efficient A* implementation in a pure FP language of your choice which is significantly simpler than in an imperative language.
>>
>>52621218
>>52621231

Now it sounds like you want to not restart the current iteration, but skip the current iteration. If that's the case, then just
continue;
>>
>>52621218
initiali = i
while i < 100:
if blahblah: break #kills the whole thing
elif blahblah: i = initiali#break loop and start again
else: #do lotsa stuff (involving i)


???
>>
>>52621218
>>52621272
you niggas never heard of continue? that's not even programming 101, that's like programming 99

rethink your lives
>>
>>52621231
>start the entire loop over, or just start the current iteration over?
Within this particular script it doesn't really matter, but I'd prefer to know the latter, for future reference.
>>52621255
Yeah this will work well for the script, thanks, but I'd still like to know how to restart.
>>52621272
Uh, this doesn't stop the current iteration at all, just resets the i value.
>>52621328
Told you I'm a complete beginner.
>>
>>52621328
>2016
>goto
>>
Do you get copy elision or RVO when using plain C rather than C++ on the major compilers?
>>
>>52621350
>$(date +%Y)
>Being a retard
>>
>>52621365
No. The C standard doesn't allow compilers to change the observable behaviour of a program, and that optimisation doesn't really make sense for C anyway.
>>
>>52621404
>using continue, goto ever
>using finally in Java ever
Yes how is first semester CS treating you?
>>
File: 1450118084668.jpg (29KB, 500x374px) Image search: [Google]
1450118084668.jpg
29KB, 500x374px
Hi,knowledgeable persons. What IDE shoud I use mostly for Python?
I am on GNOO/Leenux.
I just found out bout Geany and it shocked me that it has only ~10MiB. How come that this IDE is so smaller than , say, VS? Is it a really IDE? Quick guidance please.
>>
>>52621452
.t
>>
>>52621465
> How come that this IDE is so smaller than , say, VS
VS is very robust and feature rich(Mainly SDK's that take up space). I imagine Geany is very minimal, enough to cover basic functionality.
>>
>>52621465
Geany is a text editor.

>What IDE shoud I use mostly for Python?
Emacs.
>>
>>52621452
>>using continue, goto ever
>Excluding break from your list
What a fucking hypocrite. You can write much cleaner code with those statements.
How is second year CS treating you? I bet you're that fucking fag who always interrupts the lecturer because you always think you're right and try to correct them.
>>
>>52621452
>continue is goto
pajeets everyone
>>
>>52621448
Doesn't it?
struct Foo some_func(void){
struct Foo x = {/*whatever*/};
return x;
}
/* ... */
struct MyFoo = some_func();

My understanding is c++ will optimize out copying the return value and it will be faster than passing a pointer into the function to initialize. Just wondering if the same is true for C..
>>
>>52621545
You are retarded. I was just listing things that you shouldn't use ever.
>>
Babby tier intro to Verilog module.

anyone care to see?
>>
Someone just recommended I learn SQLAlchemy in python for database stuff, Is this actually good?
Has anyone used it?
What would you people recommend?
>>
>>52621596
What's wrong with continue?
>>
>>52621596
t. programmer of 1 year
>>
>>52621575
I suppose inlining would remove that, but I'm not aware of any C compiler that would optimise that into a pointer.
>>
>>52621545
Continue just expands to goto.
>>
>>52621670
if statements just expand to goto.
Your stupid fear of goto is just irrational.
>>
>>52621682
But Anon! They are harmful!
>>
>>52621637
>>52621637
It just makes code harder to read for other people, especially if you have some strange or complicated loop iterations or loop end conditions. No other reason really.
>>
>>52621813
No it doesn't, you're just entry-level so you don't know the usual applications of common useful functionality
>>
>>52621625
Go for it dude. Better than the usual shitposting these faggots do.
>>
>>52621248
https://github.com/sterlingm/haskell/blob/master/astar-sean.hs
>>
File: dpt fails again.png (37KB, 743x610px) Image search: [Google]
dpt fails again.png
37KB, 743x610px
>daily programming thread is now once per day rather than twice per day

Where did it all go wrong?
>>
>>52621813

While goto is sinful (in most circumstances, don't get angry now), break and continue are considerably less so. The risk of control being transferred to... anywhere... is simply not there.
>>
>>52621997
Goto is only condemned by retards

If you oppose goto you have no right to support any of the following constructs:

- Function calls
- For loops
- While loops
- Types
- Exceptions
- Higher order functions
- Templates
>>
>>52621991
/g/ is a major board and anons compete to who posts the next thread first.
>>
>>52622038

Who condemned it? It's not harmful alone, but like other things, it's harmful when inappropriately wielded. Excessive use makes it hard to reason about the flow of control in a program.

It's a lot like heroin in that people just cannot stop using it once they start.
>>
Having an issue that I know is a simple fix I just can't see it. Dealing with pipes between parent and child processes and whenever I print the final result I'm getting an extra newline when I print the final result with a newline, and no newline when I don't. Here's the code, feel free to tell me if I did anything else wrong.

http://pastebin.com/UX51d3zC
>>
>>52622080
>inappropriately wielded
Catch all phrase for attacking it when you want and avoiding criticism

>hard to reason about the flow of control
Bullshit you could say this about any programming construct that saves lines of code
>>
What should I use to make a program with a gui in Linux? Qt?
>>
>>52622149
>Catch all phrase for attacking it when you want and avoiding criticism

No, it's not. I can think that a scalpel is a useful tool, but still not want the hospital janitor to use it on me.
>>
>>52622183
Oh great, more platitudes.
Explain here and now when goto is and isn't appropriate.
>>
>>52621985
Not as efficient (in average case) or simple as an imperative equivalent.
>>
>>52622232

I'm talking you. You are the janitor.
>>
>>52622263
ocaml/f# master race
>>
>>52622296

talking about**, rather
>>
>>52621465
PyCharm
>>
>>52622296
I wouldn't want you using a for loop either
For loops are dangerous
>>
>>52622334

But really, though, there are certain cases where it's nice. The classic C example of cleaning up on some error condition (you know, the one that Apple messed up) is pretty common, and not that big of an issue. Using goto in the place of more robust flow control constructs.. why would you do that?

Seriously, give me a compelling reason. Something that would be much harder to achieve without it.
>>
File: haskelltan.png (514KB, 810x698px) Image search: [Google]
haskelltan.png
514KB, 810x698px
>tfw fell for the Haskell-meme so hard
Such a comfy language desu and ghc is a fucking masterpiece
>>
>>52622263
Literally equal. If you're unable to comprehend even basic concepts, you're allowed to shut the fuck up.
>>
>>52622378
Whats the TLDR on what makes haskell so great? Not saying you're wrong I'm just curious because I've never used it.
>>
>>52622378
ebin
>>
New thread, migrate whenever
>>52622420
>>
>>52622389
Muh purity, muh typeclasses, muh monads, muh compiler. The whole thing is designed to make programming just work.
>>
>>52612793
I'm using D
>>
>>52622378
>tfw also fell for it
>Spent months blogging about how productive I was and other stupid shit
>Forced back to Java for a weekend
>Realized It was all a lie and in actuality I was way less productive
>>
>>52622366
"More robust flow control constructs" are uses of goto
>>
>>52622482

Internally, but not to the user.
>>
>>52622389
It's not, it's a shitty failed experiment. It wishes it could be even 1/3rd as good as ocaml.
>>
>>52622516
The user should be able to write their own flow control constructs
>>
>>52622378
are you a cute trap?
>>
>>52622038

Having done a little bit of kernel programming for a class in a language without goto, I have found a couple of use cases where I had wished I had goto, namely with regards to areas where a function needs to just cleanup and leave because something went wrong.

The basic pattern of it all was:

1. Get a resource x
2. If some failure condition, release x and return
3. Get a resource y
4. If some failure condition, release x and y, and return.
5. Get a resource z
6. If some failure condition, release x, y, and z, and return.
7. Do something with x, y, and z
8. Release x, y, and z
9. Return.

What I would have liked would be:

1. Get a resource x
2. If some failure condition, set error condition and goto A
3. Get a resource y
4. If some failure condition, set error condition and goto 9
5. Get a resource z
6. If some failure condition, set error condition and goto 8
7. Do something with x, y, and z
8. Release z
9. Release y
A. Release x
B. Return

Would have reduced the length of a few if statements, and not really made the code any less readable.

Of course, if the language had RAII and allowed me to declare variables in the middle of code (as C++ or Rust), I could have just returned an error and let the destructors take care of it.
>>
>>52622558

And they can, because most languages still let you use goto. It's not a law, it's just a suggestion.

Well, except for Java. Gosling took it away.
>>
>>52622591
>namely with regards to areas where a function needs to just cleanup and leave because something went wrong.

That's one of the exceptions I noted here: >>52622366

It seems fine to me.
>>
>>52622602
>Well, except for Java
I need to make a list of all the features Java got rid of, as well as common defenses by Java fags for getting rid of them
>>
>>52611684
What would you call a binary tree that only uses one child node instead of two?
>>
>>52622642
Unary?
>>
>>52612793
It's pointless
>>
>>52622591
>>52622617

This is why all languages need macros.
>>
>>52621902
simple 'one position' detector.
module find_first1(datain,first1,allzero);
input [15:0] datain;
output [3:0] first1;
output allzero;

assign first1 = (datain&16'h8000) ? 4'b1111: //position 15
(datain&16'h4000) ? 4'b1110: //position 14
(datain&16'h2000) ? 4'b1101: //position 13
(datain&16'h1000) ? 4'b1100: //position 12
(datain&16'h0800) ? 4'b1011: //position 11
(datain&16'h0400) ? 4'b1010: //position 10
(datain&16'h0200) ? 4'b1001: //position 9
(datain&16'h0100) ? 4'b1000: //position 8
(datain&16'h0080) ? 4'b0111: //position 7
(datain&16'h0040) ? 4'b0110: //position 6
(datain&16'h0020) ? 4'b0101: //position 5
(datain&16'h0010) ? 4'b0100: //position 4
(datain&16'h0008) ? 4'b0011: //position 3
(datain&16'h0004) ? 4'b0010: //position 2
(datain&16'h0002) ? 4'b0001: //position 1
(datain&16'h0001) ? 4'b0000: //position 0
4'b0000;

assign allzero = (datain&16'hFFFF) ? 1'b0 : 1'b1;

endmodule
>>
>>52622664

I don't feel like there were any areas I needed macros in that series of assignments... but RAII and/or some more flexible control flow would have been helpful.
>>
>>52621813
>continue is bad
That's the most dumbest thing I heard
>>
>>52622664
How do you use macros for that?
>>
>>52622653
Just found what it is called, it's a degenerate/pathological tree. there's like zero tuts on the net though...
>>
>>52622642
a linked list
>>
>>52622719
>>52622766

To add what the language doesn't have
>>
I'm starting to work with C++ coming from Java background, but can't fully wrap my head around how initializing class fields works in C++.

Say I have a class A:

 
class A{

private:
B b;

}


I noticed that I don't have to explicitly initialize b (with b = new B()) in the constructor for it to be created, but why is that? Is b created on the stack of A and lives as long as A remains on the heap?
>>
>>52622839
well you've fucked up quite badly if you intend to use a binary tree but end up only end up only using one child node
>>
>>52622875
All I need is a reference to
be able to access the structure holds a unique object struct inside of that
typedef enum
{
HandleTypeUnknown = 0,
HandleTypePort = 1,
HandleTypeSession = 2,
HandleTypeEvent = 3,
HandleTypeMutex = 4,
HandleTypeSharedMemory = 5,
HandleTypeRedirection = 6,
HandleTypeThread = 7,
HandleTypeProcess = 8,
HandleTypeAddressArbiter = 9,
HandleTypeSemaphore = 10,
HandleTypeTimer = 11,
HandleTypeResourceLimit = 12,
HandleTypeCodeSet = 13,
} HandleType;

typedef struct
{
struct wait_object *wait_object;
struct event *event;
struct mutex *mutex;
struct thread *thread;
struct process *process;
} ObjectData;

typedef struct object
{
bool (*IsWaitable)(struct object *);
HandleType handle_type;
u32 ref_count;
u32 object_id;
u32 next_object_id;
ObjectData *object_data;
} Object;

typedef struct wait_object
{
bool (*ShouldWait)(struct wait_object *);

/// Acquire/lock the object if it is available
void (*Acquire)(struct wait_object *);

/**
* Add a thread to wait on this object
* @param thread Pointer to thread to add
*/
void (*AddWaitingThread)(struct wait_object *, struct thread *);

/**
* Removes a thread from waiting on this object (e.g. if it was resumed already)
* @param thread Pointer to thread to remove
*/
void (*RemoveWaitingThread)(struct wait_object *, struct thread *);

/// Wake up all threads waiting on this object
void (*WakeupAllWaitingThreads)(struct wait_object *);

Object *object;
Stack *waiting_threads;
} WaitObject;
>>
>>52622690
Sorry about the wait. I know nothing about verilog and it looks like there's probably a better way to do this, but good on you for making it work.
>>
>>52622690
That probably about as refined as you can get it really.
Although encoders are straight forward to think about, there's a fuckload of hardware involved for something that seems like it should be very basic.
FPGAs might be able to do something clever, but otherwise there's gonna be (16 + 8) NAND/NOR gates in there.
>>
>>52623181
>>52623721
The assignment specified we were to use dataflow only, it would probably synthesize into something more efficient with an always block.

Either way the class I'm currently in is about optimization, speed vs area vs power so I should learn about optimal configurations in coming months
Thread posts: 333
Thread images: 30


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