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

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

Thread replies: 255
Thread images: 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 (979 KB, 720x404) Image search: [Google]
qKC8hYk.webm
979 KB, 720x404
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 (34 KB, 396x303) Image search: [Google]
hmm, yes.jpg
34 KB, 396x303
>>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 (196 KB, 396x598) Image search: [Google]
that means you.jpg
196 KB, 396x598
>>52612280
>>
>>52612289
my passwords are also inherently stupid
pretty good passwords tbqhwy
>>
File: just2.png (1 MB, 861x646) Image search: [Google]
just2.png
1 MB, 861x646
>>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 (50 KB, 861x653) Image search: [Google]
sqrt2.jpg
50 KB, 861x653
>>
>>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 (152 KB, 2000x990) Image search: [Google]
2000px-Groovy-logo.svg.png
152 KB, 2000x990
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 (2 MB, 380x285) Image search: [Google]
feardisgust.gif
2 MB, 380x285
>>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 (49 KB, 1200x800) Image search: [Google]
trans crab.png
49 KB, 1200x800
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 (388 KB, 1280x960) Image search: [Google]
c4VZPIA.jpg
388 KB, 1280x960
>>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 (65 KB, 480x640) Image search: [Google]
1452154219311.jpg
65 KB, 480x640
>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 (24 KB, 400x530) Image search: [Google]
pepe-ball.jpg
24 KB, 400x530
>>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 (233 KB, 599x431) Image search: [Google]
yalta.jpg
233 KB, 599x431
>>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 (212 KB, 580x871) Image search: [Google]
qzqupqczkz6vqko.jpg
212 KB, 580x871
>>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 (101 KB, 666x476) Image search: [Google]
1452389244118.jpg
101 KB, 666x476
>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 (699 KB, 957x1069) Image search: [Google]
hello rato.png
699 KB, 957x1069
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 (484 KB, 1280x800) Image search: [Google]
S01E05P062_Louis.png
484 KB, 1280x800
>>52615156
That rat looks eerily like Louis Litt from suits.
>>
>>52614904
Dicks, obviously.
>>
File: albanian virus.jpg (13 KB, 480x209) Image search: [Google]
albanian virus.jpg
13 KB, 480x209
>>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 (40 KB, 346x340) Image search: [Google]
bitch no.jpg
40 KB, 346x340
>>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 (149 KB, 500x400) Image search: [Google]
ka.gif
149 KB, 500x400
>>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 (12 KB, 442x436) Image search: [Google]
2016-01-25_13-03-31.png
12 KB, 442x436
>>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 (260 KB, 563x542) Image search: [Google]
1453694583117.png
260 KB, 563x542
>>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 (1 MB, 320x200) Image search: [Google]
1453695267087.gif
1 MB, 320x200
>>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 (35 KB, 469x527) Image search: [Google]
IMG_20151209_230220.jpg
35 KB, 469x527
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 (33 KB, 438x189) Image search: [Google]
1446250682308.jpg
33 KB, 438x189
>>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
Thread replies: 255
Thread images: 30

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.