[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: 323
Thread images: 28

File: le implying milipede.jpg (208KB, 1036x765px) Image search: [Google]
le implying milipede.jpg
208KB, 1036x765px
Old thread: >>57919912

What are you working on, /g/?
>>
first for Rust (C/C++ replacement language)
>>
Second for making it shorter in Haskell.
>>
File: i've had you up to here randlet.jpg (76KB, 480x320px) Image search: [Google]
i've had you up to here randlet.jpg
76KB, 480x320px
>>57925024
SHORT
>>
>not being a Ruby on Rails Ninjaneer

https://stackoverflow.com/jobs/130607/ruby-on-rails-ninjaneer-agilityfeat
>>
third for lisp ain't that amazing
>>
>>57925018
Rust (SJW mind-control algorithm language)
>>
File: ruby irl.png (266KB, 339x589px) Image search: [Google]
ruby irl.png
266KB, 339x589px
>>57925029
>ninjaneer
>>
>>57925030
You're like fifth, bra.

>>57925029
I'd rather be a quim ninja.
>>
>>57925030
>tfw GC pause makes u miss 3rd GET
>>
>>57925012
For a better career, yeah. It's the future anyway. What sort of company do you work for?
>>
I have to do work but i keep trying to learn F#.

Help.
>>
File: 1476713479124.jpg (204KB, 1920x1080px) Image search: [Google]
1476713479124.jpg
204KB, 1920x1080px
I'm so sick of this aoc day 9 puzzle, my answer is still off by the entire length of the input + 13 characters that I can't even track down.

size_t decompress_v2(char *arr, size_t len)
{
size_t length = 0;
char save = arr[len];
arr[len] = '\0'; /* prevent runaways */
unsigned i, j;
for (i = 0; i < len;)
{
/* find length up to first marker */
char *next = strstr(&arr[i], "(");
i = (!next) ? len : (size_t) (next - arr);
if (!arr[i])
{
length += i;
break;
}

/* estimate size of next expansion */
unsigned dist, iters;
sscanf(&arr[i], "(%ux%u)", &dist, &iters);
for (j = 0; arr[i + j] != ')'; j++); j += 1;
length += decompress_v2(&arr[i + j], dist) * iters;
i += j + dist;
}
arr[len] = save;
return length;
}
>>
>>57925083
learn f# until it is certain that you need to get the work done otherwise, you can't finished
>>
>>57925040
Fuck off back to /pol/
>>
>>57924293
(some list)
>>
DAILY PROGRAMMING CHALLENGE

Implement Conway's game in your choice of language.
Bonus points for using something I haven't heard of, but only if it's actually correct.

>>57925100
People need to start posting the problems and input data. Most of us are too lazy to actually sign up for AoC.
>>
>>57925083
F# is the worst functional language out there. Even worse than SML.
>>
>>57925100
>hmm that sounds interesting
>google it
>To play, please identify yourself via one of these services:
>[GitHub] [Google] [Twitter] [Reddit]
Well so much for that.
>>
are there non-free OR not open-source programming laguanges?
>>
>>57925121
>most of us
speak for yourself, you autist

you don't at least have a github, why do you even come here?
>>
File: Poltards are Despised.jpg (174KB, 500x600px) Image search: [Google]
Poltards are Despised.jpg
174KB, 500x600px
>>57925040
> MUH SJW boogeyman
Go cry to mommy, stormtard. We don't need your whining in here. We have allotted you a containment board for that, simply out of kindness, but you still don't comply and keep infesting because you're just that despicable.
>>
>>57925105
you first
>>
>>57925171
I don't think I'm alone, for example: >>57925155
>>
>>57925172
>everyone who disagrees with me is /pol/, just because I said so

fuck off, rust admin
>>
>>57925172
>implying there isn't SJW subterfuge underway on all boards

Nice try you commie fuckstain. The anticommunists and antiantifa fighters will once again retake Europe and the Americas.
>>
File: programming-alcohol-chart.jpg (20KB, 578x287px) Image search: [Google]
programming-alcohol-chart.jpg
20KB, 578x287px
A few questions.
Is it possible to get drunk by inhaling vaporized alcohol?
Would there be a good way to keep the dosage consistent or is the human body a system that doesn't stream alcohol out of the blood at a consistent rate?

Any experiments that have been done on this topic?
>>
>>57925214
better ask /dpt/
>>
>>57925214
Yes, you can get completely fucked up doing that. Be careful.
>>
File: butthurt shoah.jpg (83KB, 700x700px) Image search: [Google]
butthurt shoah.jpg
83KB, 700x700px
>>57925172
>rustcuck supremely butthurt
kek
>>
there should be a special symbol that when typed in with a number next to it lisp souce codes, denotes "hey, complete n open parenthesis"
>>
>>57925230
May be done with reader macros.
>>
>>57925100
Haven't really investigated but your shit is pretty fucked. I tried it on a few test inputs and it's giving all sorts of bizarre answers. My favorite is "a(2x1)bc", which gives 2.
>>
>>57925214
Alcohol literally shrinks your brain regardless of the amount you ingest. You'd be a potato in a month
>>
/g/ people are this weird hybrid of Nazis and SJWs, 90% of the people here whine about Trump and "muh soggy knees", and exclusively support SJW orgs like Rust and Node.JS, and yet they're the same people who five seconds later will turn around and scream "GENOCIDE ALL THE INDIANS AND WOMEN REEEEEEE"

I'd be hard pressed to find people more autistic, more schizoid, more completely fucking brain-fried and fucked in the head than the faggots on /g/

WHY did it have to be like this
WHY
>>
>>57925250
The length is simply: Length of input characters (excluding parenthesized expressions) + (a x b-1) for every parenthesized expression.
>>
>>57925188
that was clearly you
>>
>>57925276
There are multiple people on this board.
>>
>>57925285
pull the IP logs and prove it
>>
>>57925275
>literally shrinks your brain
Source?
Why would XKCD encourage such reckless behavior?
>>
File: me.png (16KB, 486x192px) Image search: [Google]
me.png
16KB, 486x192px
>>57925285
No, that was me
>>
>>57925276
The SJWs come from plebbit tho
fucking cancer
>>
>>57925242
If macros are so great then why is Lisp so unpopular?
>>
>>57925298
because drinking alcohol is literally the oldest meme in existence
>>
>>57925298
Because he's a jew trying to get your job.
>>
>>57925282
(a x (b-1)), if not clear from spacing

>>57925285
See image.
>>
File: le friendly alcohol.jpg (140KB, 1279x960px) Image search: [Google]
le friendly alcohol.jpg
140KB, 1279x960px
>>57925309
>>
>>57925292
yes, and my point is that by far the vast majority of them are hyper-schizoidal, aspergoidal, completely fucking brain-scrambled freaks who exhibit the worst traits of both Nazis and SJWs simultaneously
>>
1. Designing and implementing a compression algorithm that does NOT make i.i.d. stochastic assumptions (gzip, for example, works off of this assumption) (I'm basically trying to build an encoder that functions outside of the scope of the Shannon source coding theorem). The goal is to be able to potentially compress random strings by a reasonable amount.

2. Modifying the OpenSSL library to create an open interface for steganographic channels.
>>
>>57925308
because most people are plens
>>
>>57925282
Yes I understand the problem. But try running shit through your function and you will see it produces all kinds of garbage. Even the first nontrivial test case is wrong, it says A(1x5)BC decompresses to length 13 (it's actually 7).
>>
File: 2016-04-18-224722_598x724_scrot.png (586KB, 598x724px) Image search: [Google]
2016-04-18-224722_598x724_scrot.png
586KB, 598x724px
>>57925029
>tfw i work for them
>>
>>57925250
I wrote it the straightforward way by decompressing it iteratively, but following part 2's rules, it would take 10GB to compute the length.

the output is correct, at least.
>>
>>57925347
A(1x5)BC

Length of non-parenthesized input characters = 3
(a x (b-1)) = (1 x 4) = 4
3 + 4 = 7
>>
>>57925362
Yes, again, I understand the problem. As you show, the correct answer is 7. The AOC page says the same thing. But your function returns 13.

Having looked briefly at the code, I see two problems. First, (..) markers inside a repeated section should be ignored. But it looks like you are making a recursive call to process them. Second, it looks like you are adding the length of the marker (`j`) into the output somehow, when it should also be ignored.
>>
Why are the closing parentheses necessary at the end of lisp input?
>>
>>57925396
Oh right. I didn't write that function, I'm telling the guy who wrote the function how to solve the problem.

I didn't even read his function, I just assumed it was rubbish.
>>
>>57925399
>why are the closing brackets in C or C++ necessary?
>>
>>57925411
Because #include copies and pastes raw files
>>
>>57925399
They *don't exist* goy.
>>
>>57925403
Oh sorry, wasn't paying attention

>>57925358
>following part 2's rules, it would take 10GB to compute the length
What do you mean by "part 2's rules"? Is there more to the problem that's only visible if you log in, or something?
>>
>>57925420
It's because whitespace is insignificant.
>>
>>57925342

s-s-somebody express interest in my work, please :(
>>
>>57925411
>>57925420
But if you think about it, if you know that nobody is going to #include your file, then you should be able to omit the last braces, i.e.

int main(int,char**) {
doStuff();
if (!cond)
return 0;
else {
differentStuff();
return doMoreStuff();
>>
>>57925436
*glomps you*
>>
>>57925432
you get part 2 once you solve the first part.
part 2 for day 9 simply says don't skip over decompressed sections, if a marker was duplicated n times, you have to expand every single one
>>
>>57925449

I thank you for the glomp.
>>
File: 1407267887115.gif (3MB, 300x273px) Image search: [Google]
1407267887115.gif
3MB, 300x273px
>>57925336
>Vast majority of them are hyper-schizoidal, aspergoidal, completely fucking brain-scrambled freaks who exhibit the worst traits of both Nazis and SJWs simultaneously

Funny enough your line perfectly describes Linux users and most people idolized in this board like Stallman or Terry Davis

Call me what you want, but you literally can't prove me wrong on this
>>
What's the fastest way to implement the dijkstra's algorithm? Is it using a priority queue?
>>
>>57925437
You're retarded. Whitespace isn't significant.
int main(void) {
if (!cond)
thing();
else {
thing1();
thing2() // ??????????????????????????
>>
>>57925519
I didn't say whitespace was significant
>>
>>57925437
You never #include function bodies, especially main(), moron.
>>
>>57925516

Fastest as in time to implement from scratch? The original way: just use an array and iterate through it every time you need to find the minimal element.

Fastest with respect to performance: use a Fibonacci heap.
>>
>>57925459
Think I fixed it. Your handling of non-repeated characters was pretty messed up.
>>
>>57925535
in C++ you do

but regardless there's structs
>>
>>57925532
Then thing2() is inside the else block, when it isn't intended.
>>
>>57925485
no one actually idolizes terry you fuckin reprobate how new are you
>>
>>57925535
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/false.c;h=bc9c703a56da58393674a02d1a54616fc5e609ef;hb=HEAD
>>
>>57925550
... no, it is intended.
the implication is that if you don't terminate a brace, the compiler puts it at the end of the file.
>>
File: 4925.gif (3MB, 320x240px) Image search: [Google]
4925.gif
3MB, 320x240px
>>57925548
you do not include a file with main in it in C++ lmfao
>>
>>57925546
what do you mean?
>>
>>57925559
So you're saying if you ever open an else block, you can't close it? Or that the closing is optional if it's at the end of the file? Because that's pretty retarded.

>>57925558
>GNU
>>
File: 2016-12-09-225407_913x118_scrot.png (19KB, 913x118px) Image search: [Google]
2016-12-09-225407_913x118_scrot.png
19KB, 913x118px
can somebody post a shorter solution?
preferably in haskell
codeFight n = map f [1..n] 
where f n = case (mod n 5, mod n 7) of
(0,0) -> "CodeFight"
(0,_) -> "Code"
(_,0) -> "Fight"
_ -> show n
>>
>>57925574
I didn't say main
>>
>>57925100
I did it like that. Works for my input.
#include <stdio.h>
#include <inttypes.h>

uint64_t getCompressedSectionSize(uint64_t characterLimit)
{
char c;
char buffer[16];
uint64_t size = 0;
while(characterLimit)
{
scanf("%c", &c);
if(c == '(')
{
uint64_t count, limit, headerLength;
scanf("%lu%c%lu", &limit, &c, &count);
headerLength = sprintf((char *)&buffer, "(%lu%c%lu)", limit, c, count);
scanf("%c", &c);
uint64_t sectionSize = getCompressedSectionSize(limit);
size += sectionSize * count;
characterLimit -= headerLength + limit;
}
else
{
++size;
--characterLimit;
}
}
return size;
}

int main()
{
char c;
uint64_t sum = 0;
while(scanf("%c", &c) != EOF && c != '\n')
{
if(c == '(')
{
uint64_t numOfCharactersToRepeat, repeatCount;
scanf("%lu%c%lu", &numOfCharactersToRepeat, &c, &repeatCount);
scanf("%c", &c);
sum += repeatCount * getCompressedSectionSize(numOfCharactersToRepeat);
}
else
{
sum += 1;
}
}
printf("decompressed length: %lu\n", sum);
return 0;
}
>>
>>57925558
The intention is pretty obvious there. They've made two nearly identical programs and modified one's behavior in a ""clever"" way. This isn't typical.
>>
>>57925591
>closing is optional if it's at the end of the file
Yes, this is exactly what was stated in the reply chain.
The point was I was saying terminating braces at the end of a file could arguably be permissible (obviously not by the standard) in some cases in C/C++, and how because of #include it might not be the same, but the original conversation was about Lisp.

In Lisp, why is terminating parentheses at the end necessary?
Apparently because of whitespace


>>57925592
That's pretty much the shortest you'll get
>>
>>57925592
You could shave off a line by flipping map and using a lambda for the case statement. Otherwise, that's pretty optimal (assuming an 80char limit).
>>
Loops are always better and faster than recursion. Anyone that uses recursion is a brainlet cuck.
>>
>>57925010
I love programming microcontrollers. So much so that I'd do a lot of it in my free time if I had the money to blow on sensors, actuators, and casing required to do anything with them. I was taught BASIC and Mitsubishi PLC but logic is logic from what I figure. Learning a new language should be easy enough.

I guess what I'm asking for is a programming language which I can work with entirely on the computer. Something for game design or something along those lines. Definitely object oriented as I'm used to hardware triggering hardware. I played around with ActionScript before and was OK with it, but a lot of times it seemed needlessly complicated. Like the syntax was made irritating for the sake of being irritating.

Any recommendations?
>>
>>57925654
aren't a lot of old axioms like recursion actually worse these days?
Like some sorts that were deemed "bad" are not actually bad anymore since we have such big caches? And our most limiting speed bump is cache misses
>>
>>57925614

Can you prove that it's optimal? Questions relating to Kolmogorov complexity are undecidable.
>>
What's the key to embedded engineering?
>>
File: 1479491334102.jpg (67KB, 625x626px) Image search: [Google]
1479491334102.jpg
67KB, 625x626px
>>57925685
No, but I can prove that it's 'pretty optimal'.
>>
Are singletons allowed for logging?
>>
>>57925679
if your algorithm relies on the compiler quietly turning your recursive shit into an iterative loop to prevent a stack overflow, it's shit

what do you think tail call optimization is?
>>
>>57925716
Use the writer monad
>>
>>57925654

>go to one of the top CS programs in the countries for undergraduate and graduate programs
>experts in the field explaining ground-breaking (recursive) approaches to open problems that they solved
>anon on /g/: "recursion is for brainlet cucks"

Sure.
>>
>>57925722
no memelangs pls
>>
>>57925610
#include <stdio.h>

int main(int argc, char **argv) {
int count = 0;
FILE *in = fopen(argv[1], "r");
FILE *out = fopen(argv[2], "w");
char ch;

ch = fgetc(in);
while (!feof(in)) {
fputc(ch, out);
if (ch == '{') count++;
else if (ch == '}') count--;
ch = fgetc(in);
}

fclose(in);

for (ch = 0; ch < count; ch++) {
fputc('}', out);
}
fclose(out);
return 0;
}


$ gcc addbraces.c -o ab
$ cat hello.no
#include <stdio.h>

int main(void) {
if (2 > 3)
return 1;
else {
puts("hello");
return 0;
$ ./ab hello.no hello.c && gcc hello.c -o hello && ./hello
hello

I encourage you to use this utility when you work on projects with others
>>
>>57925735
I don't do it, nor am I recommending it for C
I wish at least some of you would read the reply chain

I'm saying for Lisp
>>
>>57925670
Look up PICO-8. You program it with Lua but it's designed to mimic the restrictions of ~NES-era game consoles.
>>
It's a "C niggers complain about parentheses in lisp" episode

AGAIN
>>
>>57925594
the code you posted is a main loop
>>
>>57925753
It's a "pythonbabbies complain about braces in C" episode actually
>>
>>57925724
I think the point he makes, poorly, is that recursion is an inefficient solution.

In the worst case your own implementation of the stack is equal. Usually it's better.
>>
>>57925758
Yes. The implication is that it's the last part of the source code, and so it couldn't possibly be a problem semantics wise.
>>
>>57925556
fuck off cia nigger
>>
do people still actually use lisp today?
>>
>>57925776
no
>>
>>57925724
Which open problems, and what were these "ground-breaking approaches"?

Because, just to be clear, I think you're full of shit. Actual cutting-edge research is usually presented at a very high level of abstraction. Usually they don't even specify what data structures to use, much less whether to use recursion or iteration.
>>
>It's a "haskell babbies complaint about no pattern matching or partial application in other languages" epsiode
>>
>>57925753
My favourite episodes are the ones where Lisp programmers complain about the readability of Haskell
>>
Is common lisp dead?
>>
>>57925799
No, but garage rock is.
>>
>>57925767

Sure. This point is acceptable.

Recursion names an entire body of approaches; saying "recursion is for brainlet cucks" is basically just a surefire way of signaling to others that you have no idea what you're talking about.
>>
>>57925788
i haven't done this yet, can i do this?

why the fuck are there languages without discriminated unions and pattern matching?
>>
>>57925795
or the one where they call haskell "puzzle oriented"
>>
>>57925788
>>>>complaining about languages not having bad features
>>
>>57925745
>$14.99
If I don't want to spend $15 on hardware why do you think I wanna spend $15 on software?
I'm looking for free shit here.
>>
>>57925795
Except Lisp is objectively more readable than Haskell. Lisp is the most unambiguous syntax possible. It's so readable that even Lisp can read Lisp.

>>57925788
Scheme has both.
>>
>>57925819
fucking cheap ass faggot, just mug a grandma
>>
>>57925823
Machine code is objectively more readable than Lisp.

To machines.
>>
>>57925824
Or I can just use free shit like a normal human being.
>>
>>57925827
Right. Lisp is completely unambiguous to human beings as well as being braindead-simple for machines to parse. It's the perfect balance.
>>
>>57925823
yeah, whats the equivalent of
f = foldl (+) 
h = map f [0..10]
j = map (\t -> t [ [a..b] | a <- [1..100], b <- [100..200]]) h
>>
How many LOC did you wrote today /dpt/?
>>
>>57925819
Sucks to be you then. Godot is garbage, Game Maker costs money. Unity and Unreal are free but also unbelievably complicated. I suppose you could do NES homebrew and run it in an emulator but that would require learning 6502 assembly.
>>
>>57925856
>>57925735 is it
I need project ideas to get into good company
>>
>>57925849
fuck
*
j (x:xs) = map (\t -> t xs) h
>>
>>57925863
Well shit. Looks like I'm going back to AS3 then. Too bad flash is a dying art. :(
>>
>>57925784

There are many examples. One of which is essentially the entirety of formal verification, specifically the entire body of symbolic model checking (including the construction of data structures such as binary decision diagrams (BDDs) and other DAG-variant representations of Boolean functions). If we were restricted to iterative approaches, we would be stuck with bounded symbolic model checking, which greatly restricts both the types of logics we can check over largely asynchronous systems and decreases performance in the case of large traces.

Another example would be essentially any form of research in the area of graph theory concerned with classes of graphs which portray recursive structural properties.

In the real world of modern research, especially in the realm of theoretical computer science, the gritty details of data structures and algorithms are extremely relevant. By ruling out anybody who gives credence to recursion as a 'brainlet cuck,' all you do is reveal how ignorant you are to the history and state of progress in computer science.
>>
>>57925849
Scheme has partial application through closures. It doesn't have currying baked into its syntax.

But that's not what you asked for.

And it's primarily a cosmetic concern. But Haskell niggers thrive on the smugness they derive from "elegant" trivial case solutions to CS 101 problems
>>
>>57925892
Just use C or C++ with SDL or SFML you twat.
>>
>>57925121
step cs = filter shouldLive $ nub $ concatMap cellAndNs cs where
shouldLive c = ns == 3 || (ns == 2 && elem c cs) where ns = numLiveNs c
numLiveNs c = length $ filter (`elem` cs) $ filter (/= c) $ cellAndNs c
cellAndNs (x, y) = [(x+x', y+y') | x' <- [-1..1], y' <- [-1..1]]

main = loop [(0,0), (0,1), (0,2)]
where loop s = print s >> loop (step s)
>>
>>57925906
can you give examples?
>>
>>57925856
>0
>0
>0
>0

And i need to write aprox 600~ by sunday
>>
>>57925836
>unambiguous
>readable
these are not one and the same
>>
>>57925933
Please see my four-line game of life for a perfect example of unambiguous readability: >>57925912
>>
>>57925856
Maybe 30. I wrote a bash script and some minor fixes to a program.
>>
>>57925912
Somebody should post the APL one-liner.
>>
>>57925912
>concatMap
use >>=
or possibly even do notation

I would split up those declarations too.
And don't use $ so much, use . s until you need to use $

if you have data.ix
you can do
range((0,0), (0, 2))
>>
>>57925955
None of those suggestions change the semantics or brevity.
>>
>>57925899
>If we were restricted to iterative approaches
What on earth are you talking about? You do know how to turn a recursive algorithm into an iterative one, right?
>>
>>57925962
Neither does identing your code.
>>
>>57925926
You would just wrap each of the steps in your Haskell code in lambdas with a free variable, then apply it to the next step. Manual currying.

>but that's stupid

In your specific case it definitely is.

The list pattern matching of x:xs can be specified in a syntax-rules case of (_ x xs ...)

Like I said: the differences are mainly cosmetic
>>
>>57925976
Identing?
>>
>>57925962
>>57925976
in whitespace insensitive languages, i mean
>>
>>57925987
wut
>>
>>57925856
Maybe 200 lines of Coq. Trying to get rid of a bit of the boilerplate around proofs by mutual induction, but Ltac is just so unbelievably shitty sometimes.
>>
>>57925933
by objective metrics disambuguity is the closest thing to readability

anything else is just subjective taste, or more likely: baby duck syndrome
>>
>>57926000
>everything else is just subjective taste
Readability is subjective
>>
itt, post one liners
(+ 1 2 3 4 5 8)
>>
>>57926008
Fucking this. If somebody can write me a game of life in Haskell in <= 80 chars, I'll be very happy.
>>
>>57925994
Are you a researcher in a university?
>>
>>57925994
>someone is actually using Coq
What does a lysergic acid enema feel like?
>>
>>57926008
impressive, usually, you need a + in between all the numbers
what lang is this?
>>
>>57925972

I am aware that you may use your own implementation of a stack to increase performance, yes. You do know the definition of "recursion" within computer science, correct?
>>
File: 2016-12-09-234551_452x73_scrot.png (8KB, 452x73px) Image search: [Google]
2016-12-09-234551_452x73_scrot.png
8KB, 452x73px
I should get a job, lol.
>>
@57926040
Impressive.
>>
>57926040
Impressive.
>>
>>57926032
Lisp dialect, most likely. Uses reverse polish notation.
>>
By the time I've finished work (6pm), done a session at the gym (7:30pm), got home (8:15pm), cooked and eaten dinner and cleaned up afterward (9:30pm), done my daily Spanish studies (10pm), there's almost no time left for me to do any hobby programming before I have to start getting ready for bed. What do?
>>
>>57926076
you mean regular polish notation?
>>
[0...100]


What's this called?
>>
File: I'mABadProgrammer.png (37KB, 1127x685px) Image search: [Google]
I'mABadProgrammer.png
37KB, 1127x685px
How do I stop dreading debugging? Every time I'm faced with debugging my gargantuan code there's a certain unshakable fear that comes along with it.
>>
>>57926081
Yes actually, I got confused.
>>
>>57926086
ellipsis
>>
>>57926096
those have 3 dumbass
>>
>>57926086
a syntax error
>>
>>57926039

To illustrate my point: implement an algorithm to return the length of the total Shannon decomposition on a given Boolean expression without in any way replicating the behavior of the call stack during a sequence of recursive function calls. Your algorithm must terminate correctly in time O(t), where t is the total number of '+' symbols present in the decomposition.
>>
>>57926090
Why are you afraid of debugging? Which part(s) in particular?
>>
>>57925908
Looking into it, seems decent.
Thanks
>>
>>57926080
Do hobby programming on work breaks
>>
>>57926103
There are three in his post.
>>
>>57926090
stop writing shit code and get into the habit of testing every new addition you're not 100% sure about.
I simply printf debug things to make sure they run the way I expected.
>>
>>57926111
No problem, good luck and have fun.

>>57926119
>>?
>>
>>57926104
>>57926096

:^)
What's this called?

[0 .. 100]
>>
>>57926112
The only work break I get is an hour for lunch, and I normally go out to eat with coworkers for the full hour.
>>
>>57926108
I'm always scared that my code is completely wrong or I implemented an algorithm completely wrong and I need to start over from scratch. That frightens me so much.
>>
>>57926126
enumFromTo
>>
>>57926132
Why is that scary, exactly?
>>
>>57926126
You want a specific name for it, or you can't figure out what it does? It should be straightforward no?
>>
>>57926144
he doesn't want to have to do any work to fix it
>>
>>57926132
This sounds like OCD more than anything else.
get help
>>
>>57926126
A list?
>>
>>57926145
I know how it works, just don't know the name for it.
>>
>>57926154
He's going to have to get over that, and fast.
>>
Know your programming language genders:

>en C++
>ei C
>et Rust

>en Scala
>ei Clojure
>et Java

>en Idris
>ei Haskell
>ei OCaml

>et F#
>et C#
>>
File: yuki.gif (2MB, 450x258px) Image search: [Google]
yuki.gif
2MB, 450x258px
Just finished up a Java assignment for happynumbers, tried to improve performance with floats. For 1 mil {1 .. N} I got ~ 250ms with integers, and floats seem to cut it down to ~ 174ms. Just curious is this accurate or is Java doing some kind of caching shit in the background. I ran them as separate processes so I presume not.

Function<Float, Float> fastSqr = x -> x * x;


      Predicate<Integer> fastHappy = x -> {
float sum; float digit;
while(x != 1 && x != 4 && x != 89){
sum = 0;
while(x > 0){
digit = x % 10;
sum += fastSqr.apply(digit); // ~ extra 1ms cost vs digit * digit
x = x / 10;
}
x = (int) sum;
}
return (x == 1);
};
>>
>>57925849
Eh, I'll bite
(define f
(curry foldl +))

(define h
(map f (range 11))

(define j
(for/list ([t (in-list h)])
(t (for/list ([a (in-range 1 101)]
[b (in-range 100 201)])
(range a (+ b 1))))))
>>
>>57926230
What happens if I do (f h j)
>>
>>57926237
with FlexibleContexts, f h j is fine in Haskell
>>
>>57926259
I mean what happens in clojure/lisp/scheme/whatever that was.
>>
>>57926269
It probably doesn't compile if it's clojure/scheme/lisp+types
>>
>>57926237
>>57926230
Yeah, for me both the lisp and the haskell breaks cause there's no Num a => Num [a]. Did you mean to be adding lists together with (+) ?
Your example "elegant" haskell functions clearly don't do anything actually useful...
>>
File: omg.jpg (48KB, 848x480px) Image search: [Google]
omg.jpg
48KB, 848x480px
>day 10 AoC

I'm not sure what they're asking me to do.
>>
>>57926275
I didn't specify the typed variants of those languages.
>>
>>57926276
You probably want (<>), not (+)
>>
>>57926281
what does it say
>>
>>57926284
lisp isn't so much a language as a family of languages and clojure/scheme have types, which is what i meant by lisp+types
>>
>>57926294
go there yourself im not gonna spoonfeed you every single day until christmas
>>
>>57926309
I'm not going to make another one off account just to help you
>>
>>57926314
i never asked you to help me
>>
>>57926325
i never asked for this reply
>>
How can I use my programming ability to either get a gf, or stop tfwnogf?

There's got to be some application for this skill that reduces loneliness.

>inb4 make money
>>
>>57926345
it is a lonely pursuit.
>>
Hey /dpt/ how do i become a HIGH ENERGY programmer?

I always feel tired.
>>
>>57926354
Eat healthily and work out regularly
>>
This thread and the previous thread have been fucking shit.

It's cancer hour.

How do we fix this and get back on topic?
More importantly, what have you been working on /g/?
>>
>>57926354
Drink monster
>>
>>57926363
Been playing with HLists and singleton types in Scala
>>
File: RainTokyo.jpg (1MB, 2048x1362px) Image search: [Google]
RainTokyo.jpg
1MB, 2048x1362px
>tfw iwn live out my dream as a freelance programmer in Tokyo
>>
>>57926363
I'm working on your mum.
>>
>>57926349
I don't know why I am predisposed to enjoy exclusively beta-male-only subjects.
>Maths, physics, electronics, computing.
Even the physical/normie activities that I do have zero females
>Skateboarding, cycling, treehouse building, camping, psychadellics

Why couldn't I enjoy literature, media, art and photography?
>>
>>57926370
HLists are pretty cool.
You should try playing with other indexed types, like make an indexed state monad, or a type-safe state machine.
>>
>>57926372
Shame the Japanese are so racist.
>>
>>57926389

How do you think they became so successful? Nationalism saved Japan.
>>
Newbie in programming here. I know this is a long shot, but I gonna see if anyone here know what this shit is about.

Some time ago I simply pasted the code below into my c# WPF project to make my application's window immune to 'Windows + D' and 'Show Desktop shortcut' (both commands send the program's window to the back of the Z-order instead of actually minimizing the window), which basically pins my app to the desktop like a gadget.

While it does work 99% of the time, there's a bug that very rarely occurs in which this code stops working and I need to restart my machine for it to work again.
What I'm trying to understand is what the fuck is this "Program Manager" and does making my window one of its childs make it invulnerable to 'Windows + D' and 'Show Desktop shortcut'?

        [DllImport("user32.dll", SetLastError = true)]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpWindowClass, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);

const int GWL_HWNDPARENT = -8;


private void mainWindow_Loaded(object sender, RoutedEventArgs e)
{
IntPtr hprog = FindWindowEx(
FindWindowEx(
FindWindow("Progman", "Program Manager"),
IntPtr.Zero, "SHELLDLL_DefView", ""
),
IntPtr.Zero, "SysListView32", "FolderView"
);

SetWindowLong(new WindowInteropHelper(this).Handle, GWL_HWNDPARENT, hprog);
}
>>
>>57926389
Not anymore racist than anyone else, you retarded nigger loving kike.
>>
>>57926397
Hello austin

It's sam who asked a bunch of questions about liquidfun last month

we're friends, right?
pls say yes
>>
>>57926399
it's public void not private void
>>
>>57926402

Whatever you want, boss.
>>
someone say something nice to me before i go to bed please
>>
>>57926427
You're good at what you do and mean well.
>>
>>57926427

You're probably way better than a normie code-monkey even if you're not a great programmer.
>>
>>57926427
You return true
>>
>>57926455
>You return true
Be careful saying that willynilly:
isAFaggot[OP] = true;
>>
>>57926399
I'm not 100% sure what you're asking so a general overview:
The DllImport's are for importing windows API functions.
The SetWindowLong( call with the GWL_HWNDPARENT flag sets the parent of your window (that your program uses) to whatever FindWindowEx finds.
FindWindowEx looks for the shell essentially. (see https://www.codeproject.com/articles/856020/draw-behind-desktop-icons-in-windows)

So the summary would be:
You import functions from the C winapi. On load you find the shell window (normally not seen, ever) in windows. You set your program to be a child of that instead of being a child of the desktop window.
That way (apparently) the windows key+D doesn't minimize your window because it's not a child window of desktop (as windows normally are).

I'm not sure why you'd have issues with it not working. I'd picture that somehow your window isn't being made a child of program manager anymore.
I'd open up Microsoft Spy++ and look at how things are when you get one of those situations occurring.
>>
>transformation matrix suggested by webgl2fundamentals doesn't make sense but it works with their demos, doesn't work in my testing
>figure it's because their matrix multiplier is wrong
>can't find anything else that explains as well how to create a transformation matrix, webgl2fundamentals was close enough that I could adapt their broken 2D transformation matrix into a working one, but I'm too shit at math to adapt a 3D transformation matrix
what do
>>
>>57926487
Tumblr teach me that gay = happy, so what's the problem?
>>
>>57926504
https://www.youtube.com/watch?v=OG_6CopW9GQ
>>
>>57926510
>singing along
>"oh yeahhh," in my deepest voice
>hear shouting from across the house for me to shut up as it's 5am
>>
File: big disgust 4u.png (102KB, 242x259px) Image search: [Google]
big disgust 4u.png
102KB, 242x259px
>>57925556
>cia nigger can't write a compiler in three days
>thinks he's better than terry
>>
>>57926545
>5 am
Go to bed senpai
>>
>>57926495
>Microsoft Spy++
Oh yeah, I completely forgot about it, I'm gonna try to replicate this bug and monitor it with the spy++.
Also, thanks for the explanation, senpai
>>
>>57926504
The problem is you have down syndrome. Kill yourself, retard.
>>
>>57926554
I just woke up; get on my level, faggot.
>>
>>57926580
'no' sir.
I make 75k a year.
>>
>success is easier!
>10k a month!
>google is my friend!
>I write Rust!
fuck off

real success is
doing work that you can actually take pride in
working towards something that you actually support and believe in
knowing that your work makes the world a better place to live in, for you, for your family, for your community, and for all people in the world, even if this work puts you at a material disadvantage


when you continue to do work that you are not proud of, for another dime in your pocket, you are compromising your standards for the sake of material gain, you are enslaved by a desire for wealth, and this prevents you from achieving real success for yourself.
when you work for something that you do not support, or do not believe in, you are compromising your values, your morals, and your beliefs for the sake of material gain, you are enslaved by the meme of money, and this will prevent you from truly succeeding.
when you do work that you know is making the world a worse place to live in, for people around the world, for people in your community, for the people closest to you, and even for yourself, all for the sake of material gain, you are a slave, and you will never truly succeed

so, by all means, if you are OKAY with being a SLAVE to the google paycheck you will rely on for the rest of your life, if you are OKAY with NEVER being able to move beyond that system and become independent from it, if you are OKAY with NEVER SUCCEEDING EVER, then go ahead and take your slave job for your memetic-myth-object money, but don't ever come to me on /g/ or anywhere else, saying "success is easier"

fuck off
>>
>>57926619
[
fuck off] [/fuck off]
>>
I was helping my brother with some JavaScript assignments he has for a programming course in HS, and we read some comments from the teacher on what I had him do last night.

I've given his teacher the wrong impression, lel. He didn't even learn switch() statements yet, and I had him use switches and ternary operators. Teacher is all impressed that he's using ? : to solve things. Probably thinks he's like super into this or a genius, lmao
>>
>>57926636
Sadly, he's not as into it as I had hoped he'd become.
He doesn't actually plan to continue it after HS. =/
>>
>>57926619
Your portable, open source, one liner FizzBuzz won't help anybody, wake up sheep.

Stallman lied to you so he wouldn't have competition and sponge all that money himself.
>>
>>57926554
o-okay

>>57926593
you're not very good at impersonating me, i don't have the literary confidence to use a semicolon.
>>
>>57926665
>=/
what is this operator
>>
>>57926665
=/ means equals divided

>He doesn't actually plan to continue it after HS. =/
translates to:
>He doesn't actually plan to continue it after HS, and my emotions are divided on this.
>>
>>57926715
>>57926703
linked the wrong anon
>>
>>57926500
Learn linear alg

>>57926376
Because reading shit isnt as fun as making shit and art isnt as fun as math :-/

>>57926619
who are you even talking to and whats this have to do with Rust
>>
>>57926703
the ternary operator is this thing ? :
(condition to test) ? [what to do if true] : [what to do if false]


so, something like:
alert((userInput > 0) ? "Greater than 0" : "0 or less");


can even nest them, you know, to make it even harder to read:
alert((userInput == 0) ? "It's 0" : ((userInput > 0) ? "Greater than 0" : "Less than 0"));


>>57926715
True
>>
Wasn't sure whether to ask this in /sqt/ or here. What is a good, lightweight, free as in freedom IDE for a beginner learning C in Ubuntu?
>>
>>57926779
Code::Blocks is good.
IDK what you consider lightweight, though. And I only use Code::Blocks for C/++

Code::Blocks is cross-plat
>>
>>57926748
I know linear algebra, but can't figure out what's wrong.
Largely because I'm too lazy to look at all the calculations.
>>
Tekken 7 SFM when
>>
>>57926801
Thanks I'll check it out.

I only mean lightweight as in something that doesn't have an overwhelming set of features since I'm just a beginner trying to grasp the basics.
>>
Would you hire a tranny coder?
>>
>>57926836
You should probably just use emacs with a terminal open, typing "gcc XYZ.c -o PROGRAM" to compile and "./PROGRAM" to run. You're gonna have to learn that eventually, the tricky part is makefiles and flags for e.g. external libraries, but for doing beginner things the simple above commands are definitely sufficient.
>>
>>57926856
no
>>
>>57926836
In that case, you probably won't like Codeblocks.
It's lightweight in that it's only tens of megabytes, but it's beyond complicated; it's a disordered mess.

>>57926872
No one has to learn that eventually, unless they're recompiling someone else's ridiculous code that requires a very specific means of compiling.
>>
>>57925100
You adding whole length of the original chunk and only when you hit the end of it. And you should only add lengths of parts that are not covered by markers.
>>
>>57926903
Whats the point in learning C if youre not even going to go low enough into knowing how to issue commands to gcc yourself? If you want a good high level language for beginners go for lisp&htdp, if you want an IDE learn java but if only learn C if the point is to get dirty
>>
>>57926923
The point of C isn't to get dirty; the point is that C, competently used, can be very efficient.
Also C doesn't have a culture of overusing libraries, which is another nice thing.
>>
>>57926923
>lisp
>java
>>
>>57926945
Efficient? What for?

>forcing yourself into a trash languages because itll make your for loops faster
>>
>>57926836
>>57926903
It's not really that complicated at all... at least I don't think so.

It does have a lot of features, yes, but you can organize them how you like and save the profile.

>>57926945
It also has excellent syntax and lots of control over your program.
I always compile it as C++ in case I need a little extra, but I try to keep it written as closely to straight C as possible.
>>
>>57926972
Name one interesting application of programming where performance isn't key.

>>57927019
Still, being 90% features that almost no one needs makes it hard to learn the ropes, especially if you don't yet know which features you do and don't need.
>>
>>57927036
Fair enough.
Even I only actually USE the main part of the ribbon and the compiler part.
>>
Freetards should be rounded up and sent to FEMA camps.
>>
>>57927108
Hey, dawg, how about NOT shitposting like this on the /dpt/ thread.

Go on /fglt/ or something
(ironically looks like "faglet")
>>
>>57927130
Thank (((You))) for destroying programming.

fucking freetards
>>
What's the best way to print a linked list, /g/?

void printList(Link* head)
{
Link *temp = head;
while(temp != NULL)
{
std::cout << "Now at: " << temp->t_Name << std::endl;
temp = temp -> next_Link;
}
}


or
void printList(Link* head)
{
Link *temp = head;
std::cout << "temp->t_Name << std::endl;
while(temp->next != NULL)
{
std::cout << "Now at: " << temp->t_Name << std::endl;
temp = temp -> next_Link;
}
}
>>
>>57927155
for (auto temp = head; temp; temp = temp->next_Link)
printf("Now at: %s\n", temp->t_Name);
>>
>>57927153
I don't like GPL, faggit.
I knew you were too busy trolling to notice how I wrote that.

If you're gonna go free, go BSD.
Otherwise, I have absolutely no problems with proprietary code.

(You) are a retard
>>
Is javascript bad?
>>
>>57927178
It is, but it is currently necessary.

Until Web Assembly, oh please God bring that day
>>
File: Glad.png (19KB, 336x333px) Image search: [Google]
Glad.png
19KB, 336x333px
>>57927164
Holy shit that's actually pretty good. Thanks anon!
>>
File: 213.png (14KB, 679x190px) Image search: [Google]
213.png
14KB, 679x190px
How do I reconstruct this huffman tree with the code? The first line of each pair is the char value and the second line is the path. This shit is killing me
>>
>>57927193
Should I just go full php if I'm making forms?
>>
>>57927195
it's C++ so you can turn the list into an iterator and then just

for (auto& x : list)

for that you need

=
begin
!=
++
end
>>
>>57927178
It's not terrible, it's surprisingly efficient for such a high level language.
You can add together a hundred million Math.random() values in just a second

Where Javascript's inefficiencies lie is mainly in the browser, it's a lot slower wherever it interacts with anything to do with the browser.
>>
>>57927170
Here's a ((((((((You)))))))) you jew false flagging cunt.
>>
File: 1474363000057.png (211KB, 2672x1984px) Image search: [Google]
1474363000057.png
211KB, 2672x1984px
>>57927242
> MUH everyone that triggers me is an evil joo conspiracy

Welp, into the >>>/pol you go my stormtarded friend.
>>
>>57927272
>>>/out/
>>
File: 1464763565326.png (56KB, 782x790px) Image search: [Google]
1464763565326.png
56KB, 782x790px
>>57927227
efficiency is only one of many flaws of js


>>57927272
please don't insult Christianity
>>
>>57927215
The purpose of JavaScript, more than anything else (at least as I use it), is to allow asynchronicity in processing.

If you DON'T use JS, you CAN'T make the site async load pages.

If it's a simple site, sure. Pages WILL reload on the client end, however.
If it's something like a message board or a social network, NOT using JS will result in a LOT of lost customers, and unnecessary loading of extra information, which will hog bandwidth and cost you more.

If you want to add any HTML5 games, you will also need JavaScript.

>>57927227
The syntax is also dogshit, and it sucks megadick to debug.

It's almost completely unbearable without jQuery, and even then, only because it handles the non-abstracted work for me.

The syntax and typing should be much stricter and more in line with C/++.

>>57927242
Me? False-flagging?
Surely not.
I just wanted you to GTFO of the /dpt/ thread and let the Big Boys talk.

This thread is in no way directly related to Linux or other commie-tier shit, so go troll elsewhere.
>>
>>57927272
kill yourself rust admin
>>
>>57927302
>C/++
why?
>>
>>57927302
>everyone who disagrees with me is trolling, because I said so

t. Rust admin
>>
>>57927302
>The syntax is also dogshit, and it sucks megadick to debug.
I kind of know that feel, I've had to deobfuscate some JS malware at work, and it's made all that much harder by the weird shit it allows people to do.
>>
>>57927316
Because the syntax is cleaner.

Or were you asking why I wrote it like that?
Because to save just a little bit of typing time on C/C++
Those 8 fucking bits, man, lodged in my long-ass posts.
>lazy

>>57927317
Did I even respond to the Rust Guy?
I don't know Rust, myself.

>>57927333
oh God, that's another part... the malware.
JavaScript is excellent to make malware in, and it's fucking annoying as hell...
>>
>Guy at work opens up a .doc file at work from an email.
>It was a virus.

:^)))))))))) memes
>>
>>57927390
>not making sure it was from a reliable source first
>enabling macros
I bet it was someone from Marketing or Sales
>>
>>57927355
C++ has awful syntax
>>
F# is the best
>>
>>57925326
>can I abandon a friend
a hearty kek
>>
>>57927440
>Brogrammer detected.
You learn it one day don't worry.
>>
scheme was a joke, just a prank bro.
>>
>>57927440
Eh, depends on the programmer really. If you try to stick with C-style as much as possible, it can look very clean.

That is to say, C-with-Classes, as opposed to straight C++. If you do straight C++, but you don't suck, you can make it look relatively nice. But it does have a lot of extra syntax...

Basically, C-syntax is pristine easy to work with and understand, and can be written beautifully.
C++ has a few ugly extras, but if you use them only as necessary, it's hardly noticeable.
>>
Dumb question... How the hell do I operator overload in C++? I'm doing an array-based class and want to add array-like access.
Here's what I have, but it's giving me an error:

/**** IN HEADER FILE *********/
friend int & operator[](int k);
//ERROR: OVERLOADED OPERATOR[] MUST HAVE AT LEAST ONE PARAMETER OF CLASS OR ENUM TYPE
/***** Implementation *******/
friend int & operator[](int k);
>>
>>57927447
I like it too, anon
>>
>>57927525
If you overload the operators in a friend function, you have to include the object as the first argument to the function. Either delete the friend or add the array into the arguments.
>>
>>57926027
Coq's nice. So is lysergic acid, I guess but idk about that enema part.
>>
Literally can't live without infinite lists.
>>
>>57927739
i'm pretty sure you can
>>
What are your favorite programming talks?
You do watch programming talks on your spare time right anon?
>>
>>57927760
you should be programming instead of watching meme talks about the latest meme framework
>>
>>57927760
I don't know at this point
Simon always does good talks
https://www.youtube.com/watch?v=06x8Wf2r2Mc
>>
>>57927766
Well you're assuming I'm watching talks that are about frameworks and not the practice of programming.
My favorites are the ones that pertain to usage of a language.
>>
>>57925856
Absolutely none
>>
https://dlang.org/phobos/std_digest_hmac.html

This looks so nice after struggling with OpenSSL in C++
>>
Why people say Java is bad?
>>
>>57927945
OOP only was a mistake
>>
>>57927945
That's a bit general anon.
Here's a general answer:
http://tech.jonathangardner.net/wiki/Why_Java_Sucks
>>
>>57925010

** NEW THREAD SENPAI **
>>57927950
>>57927950
>>57927950
>>
>>57927973
>senpai
Why you just don't go and fuck yourself?
>>
>>57928008
Got filtered from f a m senpai
>>
>>57928013
>Next OP
Why you just don't go and fuck yourself?
>>
>>57927968
Tl;dr
>>
>>57928031
Behead those who insult Andrei
>>
>>57928065
>your java program
tl;dr
>>
File: mugi-chawn.jpg (42KB, 500x546px) Image search: [Google]
mugi-chawn.jpg
42KB, 500x546px
Do you like my multiple levels of indirection?

to[bot[i].send[j].addr].store[to[bot[i].send[j].addr].idx++] = (j == LOW) ? low : high;
>>
>>57928221
I like the image
>>
File: finnish memes.jpg (156KB, 780x773px) Image search: [Google]
finnish memes.jpg
156KB, 780x773px
hey /dpt/
tell me what you love most about RISC
Thread posts: 323
Thread images: 28


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