[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: 326
Thread images: 47

old thread: >>52581294

https://paiza.jp/poh/ando
Why aren't you winning your qt android gf's affection through programming and earning outfits for her to wear?
>>
irrational numbers are silly
>>
>>52591285
GTK+ > Qt
>>
>>52591301
no they're not
>>
>page 4
There isn't a need for a new thread yet, stop being a malformed cunt.
>>
>>52591332
tbqh we should actually post threads at around 290 so we don't get trap threads because the trap poster plays dirty and posts them before 300
>>
>>52591345
The trap poster also sucks dick every night and swallows the semen.
Does that mean we should suck dick in the afternoon?
>>
>>52591332
previous thread is over bump limit

anybody else doing CS50X?

I'm taking in-person classes through LaunchCode.org. If I complete the class they'll help get me a job. pretty pumped about it.
>>
File: df.png (17KB, 900x900px) Image search: [Google]
df.png
17KB, 900x900px
>>52591323
Sorry, anon, but I'll never understand how a number that has an "infinite" number of non-repeating digits times itself can equal two.

I don't like them, there's something off about them.
>>
>>52591345
i'm the hime poster, i'm giving you guys a break
>>
>>52591354
it's more like

he rapes /dpt/

so we'll do the raping first

so he gets cockblocked because if he tries something it'll just get deleted by the mods
>>
>>52591285
>https://paiza.jp/poh/ando
https://www.ssllabs.com/ssltest/analyze.html?d=paiza.jp&hideResults=on&latest

>B
How am I supposed to get lovey dovey with my waifu when there's NSA sniffing our internet traffic? at least fix the encryption.
>>
>>52591382
It's like 0.9999... = 1.

Yes, you can prove it because 1/3 = 0.333..., 2/3 = 0.666..., and 1/3 + 2/3 = 0.999..., but there's something awfully disturbing about it.

Thankfully, we can just use fractions though, but then some arsehole discovered numbers that can't even be represented as fractions.
>>
File: c.png (84KB, 557x649px) Image search: [Google]
c.png
84KB, 557x649px
had this idea that I would write backslashes in line with each other, because this is going to get a bit fucking out of hand, but now I feel like it was a dumb idea
>>
>>52591454
dude just use void*
>>
>>52591454
Why would you do this?
>>
>>52591463
>sizeof(T)
can I really just use void*? almost all of those functions need to know about the type
>>52591468
why does anyone do anything?
>>
>>52591497
it's really simple if you only store void*
then you only have one data type
>>
>>52590648
i'm 15 mins into TTC - How Music And Mathematics Relate

it looks like it's gonna be really good

12 videos of 45-50 mins each
>>
>>52591382
You being too thick to understand it doesn't mean there's anything "off".

That is all.
>>
Irrational numbers are rational because after an infinite number of digits the pattern repeats.
>>
>>52591497
> can I really just use void*? almost all of those functions need to know about the type
The only thing they need to know about the type is its size.

But beyond that, doing this sort of shit with macros is a fairly big clue that it's time to stop using the feature-limited trial version of C++ and use the real thing instead.
>>
>>52591587
>after an infinite number
That's the problem.
>>
>Why aren't you winning your qt android gf's affection through programming and earning outfits for her to wear?

Can't impregnate an android. Not gonna have a girlfriend who is an android. Might have a gf who uses Android, however.

That said, I am programming right now... in Prolog. Have to use it to write a parser.
>>
>>52591285
If I could read Japanese, I'm sure that this is what I'd be doing right now.
>>
File: ssd.gif (1MB, 500x281px) Image search: [Google]
ssd.gif
1MB, 500x281px
>not wanting a 2D anime robot waifu who will inevitably go crazy unless you wipe all her memories before it happens

3D women can't give you those feels.
>>
>>52591661
just use google translate
>>
>>52591624
biological offspring will no longer be needed once we have androids
>>
>>52591686
It's just not the same.
>>
>>52591587
to infinity... and beyond!
>>
File: IMG_20151209_230220.jpg (35KB, 469x527px) Image search: [Google]
IMG_20151209_230220.jpg
35KB, 469x527px
Why do we hate C++ again?
>>
File: c.png (74KB, 783x327px) Image search: [Google]
c.png
74KB, 783x327px
Well that just werked
>>
>>52591739
This is called templates you flying retard.
Why gimp yourself on purpose instead of use C++?
>>
File: c.png (85KB, 549x628px) Image search: [Google]
c.png
85KB, 549x628px
>>52591757
C++ is just a meme anon

I think I've satisfactorily demonstrated that C does, in fact, have templates, and I am, in fact, using them

:^)
>>
>>52591705
Because nobody should define a variable beginning with a capital letter and I don't like the increment operator, it should be c = c + 1.
>>
>>52591775
>I am the autism
>>
>>52591775
Hmm, after looking at your picture I agree.
That looks way simpler than #include <vector >
>>
>>52591382
You're retarded.
>>
>>52591448
>but then some arsehole discovered numbers that can't even be represented as fractions.
Example?
>>
>>52591705
it's a bloody mess is what it is
>>
>>52591827
The square root of 2.
>>
>>52591809
You can still include this in a file called "vector.h"

Now you have vectors without all the C++ bloat
>>
http://pastebin.com/jRDqzi0y

Masculine hello world coming through
>>
>>52591843
I don't believe it can't be represented as a fraction.
Prove it.
>>
>>52591858
It's refreshing seeing this after a week of feminine code
>>
File: y.png (63KB, 858x155px) Image search: [Google]
y.png
63KB, 858x155px
why do I get an accesss violation reading location on this line? it's not even a pointer, it's a reference which is fucking initialized in an initializer list
>>
>>52591863
https://www.khanacademy.org/math/algebra/rational-and-irrational-numbers/proofs-concerning-irrational-numbers/v/proof-that-square-root-of-2-is-irrational
>>
>>52591897
C++
not even once
>>
>>52591858
  int i = 0;
char c;

while ((c = "Hello world!\0"[i++]) != '\0')
{
vec_app(char)(&hello, c);
}
>>
>>52591931
this thread is getting too masculine
>>
>>52591863
Basically, if you assume the square root of 2 is rational you can work out that it is 1/1, which is obviously wrong, or something like that.
>>
>>52591914
FUCK

i dont have a single raw pointer in my code other than the code where i create my smart pointers

if im not pointing to an address anywhere how the fuck do i have an access violation
>>
>>52591897
A reference is a fancy pointer
>>
>>52592011
If you assume it's rational, then you can prove that both the numerator and denominator must have 2^infinity as factors.
>>
File: aren.jpg (172KB, 1291x603px) Image search: [Google]
aren.jpg
172KB, 1291x603px
Decided to make Sokoban for my next chip eight game (which is what I originally wanted), and then make a real game for the Zelda jam using C+SDL to practice using both. From top to bottom, you have the sprites: goal spot for boxes, You, wall sprite and box sprite
>>
>>52592770

Zelda Jam?
>>
>>52592770
oh just this themed monthly competition to make a game. Next month is zelda-themed
>>
>>52592956

Something like Ludum Dare? I'm not very familiar with the game dev scene, sadly.
>>
>>52591454
Whats with the double hashes?
>>
>>52593015
something like that yeah

and me neither, but a friend recommended I try a chip-8 zelda, but I wasn't creative enough for doing it on restricting architecture
>>
>>52593037
Preprocessor concatenation
>>
>>52593050

Meh. If you want to do game dev on a restrictive architecture, it's best to do it on an existing classical game console, which at least has some documentation floating around for how to do hard tasks. Or, since many of them were done in assembly anyways, can be disassembled.

Doing shit the C and SDL way though, is probably more satisfying.
>>
At what point can I start calling my collection of scripts a "software package" /dpt/?

I'm at 4555 lines at the moment.
>>
>>52593132

When people start downloading it through their package managers, obviously.
>>
>>52593132
Is it all functionality that deals with a similar subject and can work together?
>>
>>52593037
C is what's with it
>>
dasdasda
>>
>>52591454
Just use C++ you retard
>>
>>52593201
>using meme languages
>>
>>52593201
And yet another tripfag has appeared.
>>
>>52593214
Using C for non embedded work is a meme now
>>
>>52593201
>use C++
>it's a tripfag
[discardment intensifies]
>>
>>52593228
Using C++ for any work is the longest-running meme
>>
>>52593243
using C++ at all is the longest running meme
>>
File: 1402192670496.gif (844KB, 800x786px) Image search: [Google]
1402192670496.gif
844KB, 800x786px
>>52593201
>Just use C++ you retard
>>
I think we can all agree that taking your programming advice from /dpt/ is the biggest and most harmful meme
>>
just mentioning the language is a meme
>>
Memes considered harmful
>>
>>52591775
>vector
worst naming ever.

http://neetco.de/CodeArtisan/cdptlib/src/master/source/arraylist.h
>>
File: file.png (75KB, 244x273px) Image search: [Google]
file.png
75KB, 244x273px
>>52593251
As you're someone who watches this cheap drawn crap, your opinion is worthless.
>>
What you're referring to as meme, in in fact, GNU/meme, or as I've recently taken to calling it, GNU plus meme.
>>
>>52593201
>Just use C++
But then he would have TWO problems.
>>
>>52593293
I was going to call it a dynamic_array_capable_of_resizing_when_required but that was too long
>>
Why are makefiles so gay?
>>
>>52593336
feminine syntax
>>
>>52591285
a decentralized content aggregator
>inb4 kek
>>
In C is it better for initialization routines to take a pointer to a struct or to return one?

struct foo *f = makefoo(bar);

vs
struct foo f;
makefoo(&f, bar);

vs
struct foo *f = malloc(sizeof (struct foo));
makefoo(f, bar);
>>
File: 1413762937354.gif (3MB, 445x247px) Image search: [Google]
1413762937354.gif
3MB, 445x247px
>>52593299
>>
>>52591285
>https://paiza.jp/poh/ando


wait

is somebody actually going to manually rate the code
>>
>>52593393
#2 is objectively the best
>>
>>52591448
i disagree with cheap tricks like that. what this really means is that addition is poorly defined for number with uncountable decimal places.
>>
>>52593461
What if struct foo has a const pointer in it?
>>
How does software like Plex work?
I mean, most downloaded movies/series have no content embedded. How does it determine the episode number, season name and serie name?
>>
>>52593494
s/content/metadata
>>
>>52593494
>How does it determine the episode number, season name and series name

Regex on the filename probably. If you rename the file something inane I doubt it would correctly identify it.
>>
File: cringe.webm (3MB, 1280x720px) Image search: [Google]
cringe.webm
3MB, 1280x720px
>>52591285
I don't know moonrunes. Is there any way I can participate?
>>
sweet
>>
Am I the only one who likes writing regex?
>>
File: 1444502959547.jpg (20KB, 420x418px) Image search: [Google]
1444502959547.jpg
20KB, 420x418px
So lads, give me something to make as an app. Not anything for billions of dollars or whatever, just something I can put on my resume and on the Play store for future employers.
>>
>>52593642
oh god

the cringe is real

>anonpaiza-kun is good at programming, and he's kind... what a lovely man


>>52593693
if you plan to actually sell it you need to register a business
>>
>>52593669
nigga adventofcode made you parse text through regex almost every day
>>
>>52593693
>Play store

Fart app
>>
File: 1440190278446.jpg (788KB, 900x1619px) Image search: [Google]
1440190278446.jpg
788KB, 900x1619px
>>52593701
I don't want to sell it or anything, can people not just put their finished apps on the google store? I don't want it to be a for profit thing, literally just as something for my resume and future employers.
>>
http://sarabander.github.io/sicp/html/index.xhtml
>>
>>52593535
I don't know how, but it's even worse without sound.
>>
>>52593693
Orgasm soundboard.
>>
Does /dpt/ like muh regex?
^\[\w+\]([a-zA-Z0-9\-]|(\ [^\-]))+\ -\ ([a-zA-Z0-9\-]|(\ [^\-]))+\ -\ \d{2,}.+(mkv|mp4){1}$
[HorribleSubs] Mobile Suit Gundam - Iron-Blooded Orphans - 16 [1080p].mp4
>>
>>52591306
Tk >>> *
>>
>>52593858
Now write a parser.
>>
>>52593437
No
>>
>>52594001
That's super easy senpai. Just split at the ' - ' token.
>>
Help out a guy with a PL recommendation.
>>52593764
>>
>>52594163
>a PL recommendation
Reg Parks 5x5 >>> Starting Strength
>>
File: saedfg.jpg (25KB, 323x454px) Image search: [Google]
saedfg.jpg
25KB, 323x454px
>>52594163
>native programming
>>
File: 200_s.gif (25KB, 247x200px) Image search: [Google]
200_s.gif
25KB, 247x200px
>>52590648
>>
Will how I program in imperative languages change after learning functional programming?
>>
File: 20141024_170337.jpg (1023KB, 3264x1836px) Image search: [Google]
20141024_170337.jpg
1023KB, 3264x1836px
Are the 'ricains sleeping or what? France and its neighbours taking over!
Poast Ocaml, coq and Scala code!
>>
>>52594797
By using one of the many imperative language that support functional constructs
>>
>>52593535
kids got the moves, and that slut is hot. would bang
>>
made a selection sort, now trying to make an merge sort
>>
>>52594910
>>>/b/
>>
>>52594984
>>>/reddit/
>>
I finished bothering with my IRC bot that could search chan board catalogs about a week ago, need something new and interesting to work on, because I'm starting to become bored of working on the same old shit.
>>
>>52595007
A bot that indexes /jp/ona posts by common brandnames / product names + simple website to search through indexed posts
>>
>>52595007
Is #dpt kill?
>>
File: challenges_big.jpg (752KB, 1920x1080px) Image search: [Google]
challenges_big.jpg
752KB, 1920x1080px
>>52595007
take a pick
>>
File: John-Carmack-profile[1].jpg (96KB, 1067x788px) Image search: [Google]
John-Carmack-profile[1].jpg
96KB, 1067x788px
>>52593243
>Using C++ for any work is the longest-running meme
>>
>>52593858
>a-zA-Z0-9

Use \w.
>>
>>52595058
John Carmack said himself he despises C++.
>>
File: 1364055187344.png (550KB, 300x468px) Image search: [Google]
1364055187344.png
550KB, 300x468px
>>52595042
roll
>>
File: whyamIsosuprised.jpg (93KB, 1200x676px) Image search: [Google]
whyamIsosuprised.jpg
93KB, 1200x676px
>>52591285
>Mfw i'm trying to patch what looks like a simple CSS bug in my favorite open source project.
>Mfw it's a bug where the effect LOOKS a simple CSS bug but it's actually a much deeper problem with how the box is drawn.
>Mfw the bug is so minor that any programmer with enough experience in the code base will never touch it because they have "better things to do"

This is never going to get fixed.
>>
>>52595081
As if i'm going to take shit from a guy who sucks zuckerburg cock.
>>
File: KDnpwKi.png (13KB, 834x177px) Image search: [Google]
KDnpwKi.png
13KB, 834x177px
>>52595036
I just jumped on to check, seems that way.
Shame really, I rather enjoyed it.

>>52595024
>/jp/ona
>webdev

>>52595042
>Just pick the easiest one because I'm naturally lazy as all fuck
>>
>>52591285
I really want an excuse to brush up on my Rails/Django, but I can't think of a fucking website I really want to build. Hello World only gets you so far.
>>
>>52595121
Did you get the multi chan search thing to work?
>>
Not sure if editing xul file is programming, but does anyone have installed ublock with button in the navigation bar? Can you show me your xulstore.json with every ublock reference?
>>
>>52595136
Yeah, I set it up with 8ch and 4chan, but when I tried adding Lainchan I ran into HTTPS issues that I was in no mood to try and fix.

As long as the board doesn't force HTTPS and it uses the standard vichan API then it's doable.
>>
>>52595160
Too bad I'll never be able to test it out ;_;
>>
>>52595187
Jump on #dpt
I'll boot it up and you can give it a go.
>>
>>52595087
As if some open source projects don't have bugs that have been sitting in their bugtracker confirmed and untouched for the better part of a decade.
>>
>>52595203
no one is talking about OSS at all. This is shit that happens in every large code base.
>>
>>52595042
rolly polly
>>
>>52595240
>Ze doesn't work in San Fran
>Xe doesn't know the feeling of having to rewrite your entire code base in the latest fad language every other year
>>
>>52595121

Console.Write(Console.ReadLine().Reverse().FromCharArr());
>>
Are you a bad enough dude to make a new thread at 143 posts?
>>
File: Oh yess.png (75KB, 214x298px) Image search: [Google]
Oh yess.png
75KB, 214x298px
>>52595240
>>Mfw i'm trying to patch what looks like a simple CSS bug in my favorite open source project.
>my favorite open source project

What is it like to need a helmet everywhere you go?
>>
>>52595270
>FromCharArr
m8...
>>
>>52595298
fuck
>>
>>52595306

What m8?
>>
Here, this is better.

Console.Write(Console.ReadLine().Reverse().CharacterIEnumerableToString());
>>
>>52595328
not a real method in .NET
>>
>>52595337
>CharacterIEnumerableToString
Enterprise coding (tm)
>>
>>52595341

It's an extension method, and therefore real enough. It's not my fault that ToString on a character collection turns into "System.Char[]" or similar.

>>52595367

woo hoo
>>
File: FunkyWave.gif (10KB, 100x100px) Image search: [Google]
FunkyWave.gif
10KB, 100x100px
Currently working on 1d heatmaps and failing with basic math. Pic related is the result of adding two data points into an empty heatmap. A datapoint is added by raising the surrounding heatmap points with less intensity for increasing distance.

When combining two datapoints like pic related I get a very unsmooth value intersection (note the horizontal line when both pyramids collide).

Y value is calculated by
 heatmap1D.data[j] += intensity * value; 
.
>>
>>52595388
>It's an extension method, and therefore real enough.
Not part of .NET though.
>>
File: 1435018143235.png (37KB, 638x399px) Image search: [Google]
1435018143235.png
37KB, 638x399px
Ask your much beloved programming literate anything.

>>52595058
>>
>>52595042
schreisse
>>
>>52595414
Carmac has become the meme language king.
>>
File: pic.jpg (284KB, 688x699px) Image search: [Google]
pic.jpg
284KB, 688x699px
>>52595460
>>
>>52591371
I'm doing cs50
Good luck anon
>>
>>52595500
>const nazi
my african friend
>>
>>52595409

Meh..

>>52595460

What I don't get about Carmack is that he's pretty god damned smart, but he seems insistent on meming out over programming languages.

Maybe C and C++ don't satisfy him anymore.
>>
>He doesn't post his projects for others to use like a good samaritan.
>>
>>52595500
that actually all sounds reasonable
>>
>>52595548
If I had open sourced my work during the first year I'm pretty sure I wouldn't be a millionaire.

It's open source now though.
>>
>>52595529
Carmack is smart enough to realize that C/C++ isn't the way to go for all programs.
>>
>>52595135
>I can't think of a fucking website I really want to build
Your own startpage?
>>
>>52595529
I don't fault him for wanting to mess with haskell and racket. But seriously claiming he thinks ID should start making games in haskell, and pushing racket as the standard language for VR UI is pants on head retarded.

Maybe he was always a autistic programmer who always prefered looking at clean organised code rather than making products people like, but in the past he had people around him who would be pushing for good results more. Or maybe he just got stupid as he got older.
>>
>>52595600
>not manually moving bits in your HDD to create assembler code
>>
>>52595620
Or maybe you're trash-talking something you only understand on a conceptual level and have never actually tried doing similar and seeing the advantages and pitfalls of both choices
>>
>>52595642
I've listening to him justify his choices, and his reasoning is retarded. So yeah. He sounds as smart as your typical /dpt/ language memer.
>>
File: super special programmer.png (46KB, 627x404px) Image search: [Google]
super special programmer.png
46KB, 627x404px
>>52595414
I've already got a far better programming literate than you, pig.
>>
>>52595676
What specific part of his reasoning is retarded to you?
>>
>>52591382
>/g/ - Middle School Dropouts
>>
>>52595684
The world would be a bland place to live in without people like Brianna Wu
>>
>>52595684
Assuming Gamergater is a non-zero value this program will never execute the second if condition.
This is very bad optimization.
>>
>>52595270
main = getLine >>= putStrLn.reverse
>>
>>52591563
>Spergging out this hard

Off is subjective, you retard. He's saying that idea hasn't been turned "on" in his mind...I really hope we're in for a war some time soon so your kind can die in fire.

>>52591382
Also to the anon that can't understand it. If there is an infinite anything to a number, it has defined a domain all to itself. A domain all to itself is called a realm and of a realm that is self-referential throughout is an identity, often cited as the number 1. This can also be regarded as a single dimension. Multiplying this number by itself creates a "squared" area and introduces the idea of a second dimension commencing beyond this numbers realm, which is essentially the start of the second dimension presented as 2 in a mostly abstract and unfettered sense.

So to be more clear, it does not equal 2, it represents 1 in a sequence that has reached the limits of its identity. So a 2. Maybe.

>inb4
>sperg rage
>omgwahthellyousaybuotmebish
>math is philosophy
>b-b-but muh misrepresented explanations
>my non-conforming desire to be smarr
>>
>>52595690
He once said that Haskel should be great for games, and garbage collection pauses should not be a problem since you can just call the GC on every frame. Like... GC events still have significant overhead. That shit wouldn't be feasible for any kind of AAA title. Not to mention all the other obvious reasons not to use haskell for games.

Went on about racket a lot and how powerful it is. But fuck all developers know it. It would be a 10x better at least just to use a language that developers know like C++, Java, C# or even JS for UI. Why make them learn and entirely new language with a different paradigm to what most people know just for a UI library? If VR really takes off, chances are Carmacs work here will be hardly ever used and people will just use some shitty open source UI lib written in python or some shit that everyone can figure out how to use in 2 minutes.

There's a reason most successful development platforms don't indulge in meme languages. They use what their target developers market knows.
>>
>>52595684
>2 Nov 2014
Was it really that long ago?
>>
I have not had a desire to code for a while now. It's strange. I haven't seriously coded anything in a week. Have been making a top down rpg game instead. I am not even making the design. Literally just ripped it from a youtube vid.
>>
>>52595042
>2 separate languages send strings to each other
Task says nothing about having to be two separate programs

import Foundation
class MyClass : NSObject {
static func sendStringToC() -> String {
return "Hello, Objective-C!"
}
}

print(String(CString: send_string_to_swift(), encoding: NSUTF8StringEncoding)!)


#include "Testing.h"
#include "testing-Swift.h"
#include <stdlib.h>

void print_swift_string(void)
{
NSLog([MyClass sendStringToC]);
}

char* send_string_to_swift(void)
{
print_swift_string();
return "Hello, Swift";
}
>>
>>52593437
Did this code actually work?
>>
File: Selection.png (346KB, 962x617px) Image search: [Google]
Selection.png
346KB, 962x617px
import re
num = raw_input()
res = 1
for i in xrange(1, int(num)+1):
res = res * i
print re.search('([0-9]{0,9})0*$', str(res)).group(1)

What am I doing wrong?
>>
>>52596004
nigga i can't read chinese
>>
>>52595524

thanks anon

am i barking up the wrong tree in /dpt/? you'd think more than one other person on 4chan would be working on CS50
>>
>>52596004
>Hit control+G
>Instead of a psychological evaluation, all it gives me is the manual for a shitty text editor
>>
>>52596004
num = raw_input()
...
...int(num)


Why do this to yourself? input() exec's the code inputted so you're better off doing:
for i in xrange(1, input()+1):
>>
>>52596210
>>52596004
I realize you're doing a factorial as well, which a reduce function can do more easily

res = reduce(lambda x,y:x*y, [i+1 for i in range(input())])
>>
Guys I have panel class with buttons, text fields and stuff.
Button has action listener which starts tetris game.
I'm working with java awt/swing. Is this possible to update tetris playground view which has to be printed in A class (buttons, textfields etc), when new threads is running in B class (playground, blocks, game stats etc).
How to do it right way?
When I'm using add(B-object) in A class and run paintComponent/repaint method in B class it's not working...
Anyone?
>>
What's the alternative to OOP?
>>
>>52596334
functional
>>
>>52596334
depends on what you need OOP for
>>
>>52596334
no OOP
>>
File: Selection.png (108KB, 898x648px) Image search: [Google]
Selection.png
108KB, 898x648px
>>52596047
Went to take a screenshot of pic related and noticed that my code didn't handle 10! and 38! correctly
import re
res = 1
for i in xrange(1, input()+1):
res = res * i
res = re.search('([0-9]{0,9})0*$', str(res)).group(1)
res = re.sub('0*$','',str(res))
res = re.sub('^0*','',str(res))
print res


>>52596210
Didn't know that, thanks
I wonder why I was never bothered by the 'raw' in raw_input()

>>52596244
I never got used to lambda, they seem a little complex
>>
File: umaruic.webm (1MB, 640x360px) Image search: [Google]
umaruic.webm
1MB, 640x360px
>>52596334
True alternatives ? (adt + modules) or (adt + type classes).

>>52596378
(o__O ?)
>>
>>52596004
Get Help.
>>
>>52596531
>tfw 3 (You)s in one post
calm down lad

>I never got used to lambda, they seem a little complex
Not at all m8, I'm fairly used to them myself. A lambda expression is just a function that describes how to do something. Reduce takes a function with 2 arguments and a list, executes the function on the first 2 items and with the result, repeats with the next item. So for factorial, if you use reduce and a function x*y on a list containing 1, 2, 3, 4, 5 (if num is 5), it will do
list is [1, 2, 3, 4, 5], use first 2 items for function
1 * 2 = 2
list is [3, 3, 4, 5] continue
2 * 3 = 6
list is [6, 4, 5] continue
6 * 4 = 24
list is [24, 5] continue
24 * 5 = 120
list is [120] only 1 result so finish and return it


Except I'm pretty sure it doesn't actually add the item to the beginning of the list, it just passes it to the function again, but it's done like this here to help illustrate
>>
>>52591775
what color scheme is dat?
>>
>>52596697
Looks like the visual studio dark scheme
>>
>>52596695
>I'm fairly used to them myself.
I mean I'm fairly new to them
>>
>>52596334
Non-classical OOP, like the compositional and prototypical varieties.
>>
Best way to parse a file line by line in C?
>>
>>52596803
Depends on how big it is.
>>
>>52596837
The biggest one I need to parse is 12GB.
>>
>>52596874
Use Java or Python if you value your time
>>
>>52596803
Roll your own readline function
>>
>>52596803
>year of the muslim invasion
>parsing files in C
>>
>>52596695
Isn't memory complexity of O(n) a bit high for something as simple as a factorial?
Or does the Python interpreter clean this up so there are no disadvantages to the loop mehtod?
>>
>>52596792
>What's the alternative to OOP?
>OOP
lel, k tard.
>>
>>52596897
No one should need to do this nonsense by hand
>>
>>52596905
I'm suggesting it to him because he's doing little script challenges online and it's the easy way. I understand the important of memory complexity m8, but hopefully he's smart enough to start taking it into consideration once he's actually doing something serious. If not, hopefully he's reading this
>>
>>52596531
Searched through the site and found http://paiza.jp/poh/ec_campaign_language
>Python2 time limit: 15s
Did they really just mark my code as 'wrong' because a fucking factorial function doesn't finish within 15 seconds?
>>
>>52596888
No.

>>52596897
What's the best way of doing that, though? Growable array and getc?
>>
I bought this book (Automate the Boring Stuff with Python: Practical Programming for Total Beginners - Al Sweigart ) nd it arrived today I didn't think to read any reviews or anything, did I fuck up?
>>
>>52596989
Shouldn't be using the snake meme boy.
>>
>>52596888
But they're right.
Thing is, I/O is already slow as shit so using java or python is hardly going to be any slower compared to C.

Maybe if your parsing is extremely complicated then lower level would have it's advantages, but in most cases not.
>>
>>5259504>>52595042
Rollerino
>>
>>52597082
>Maybe if your parsing is extremely complicated then lower level would have it's advantages

Not even
>>
File: snapshot1.png (474KB, 1680x1023px) Image search: [Google]
snapshot1.png
474KB, 1680x1023px
I've been working on a map viewer for Final Fantasy 7 in js/webgl. Looks ok so far.
>>
What does /g/ think of functional programming in C++?

std::vector<std::function<int(int)>> vec;
vec.push_back([](int a){ return a * a; });
vec.push_back([](int a){ return a + 2; });

for (auto x : vec)
{
std::cout << x(8) << std::endl;
}

Results:
64
10
>>
File: snapshot2.png (481KB, 1280x1024px) Image search: [Google]
snapshot2.png
481KB, 1280x1024px
FF7 map obligatory wireframe
>>
File: vbN4JjM.png (345KB, 2144x1800px) Image search: [Google]
vbN4JjM.png
345KB, 2144x1800px
>>52596334
protocol-oriented programming™
>>
File: snapshot3.png (540KB, 1280x1024px) Image search: [Google]
snapshot3.png
540KB, 1280x1024px
Last one, some unknown bits on the FF7 map
>>
>>52597154
Useful and powerful
>>
>>52597172
It's shit
>>
>>52597172

>autism
>>
>>52597192
What other functional programming stuff can you do in C++?

Is partial application possible?
>>
>>52595802
it's 2016 now, my friend.
1998 kids are now 18 year olds.

Like what the fuck
>>
>>52596989
By definition algorithm needs to stop in finite time.
If your factorial takes more than 15 seconds it's fair to assume it's never going to finish.
>>
>>52597247
>1998 kids are now 18 year olds.
Worse than the Shoah
No wonder why the quality in every thread is lower.
>>
>>52597172

Guy said alternative, not last fucking resort
>>
>>52597172
You have to marry her before fucking her you dirty rapist degenerate.
>>
>>52596989
Let's see your factorial buddy
>>
>>52597247
>tfw 1997 kid
>>
>>52591382
Think of them as fractions.
>>
>>52597317
I am sorry, I will never get used to this.
When I see 'kids' online with usernames like "faggot97", I am like "how comes he can even play with this game?", or "why do kids find these sites interesting anyway", etc.

Then I realize they are not so young.
>>
>>52595042
Rolling on a river
>>
>>52597317
iktf
>>
File: Selection.png (32KB, 997x241px) Image search: [Google]
Selection.png
32KB, 997x241px
>>52597312
see >>52596531
how inefficient is it?
>>
>>52597235
I couldn't tell you. But there's one upcoming thing about standardizing calling a function with a tuple.
http://en.cppreference.com/w/cpp/experimental/apply
>>
>>52597372
I appreciate your sense of humor
>>
>>52597312
def factorial(n):
math.gamma(n+1)
>>
>>52595042
I hope it's short
>>
>>52597372
Did they measure the JVM load into Java or what?
Also what the fuck is up with Ruby?

I smell bullshit.
>>
File: ahue.gif (491KB, 500x220px) Image search: [Google]
ahue.gif
491KB, 500x220px
>>52597372
>PHP almost twice as "fast" as Java
The memes are too real
>>
>>52595087
So just fix the css. That's kind of the beauty of css, targeting the the elements independently makes it pretty easy to fix
>>
File: pic.png (206KB, 914x953px) Image search: [Google]
pic.png
206KB, 914x953px
Why do you guys jerk off about language features rather than build things? What's the point?
>>
>>52597513
Why build things though?
There is no new market for stuff.
>>
>>52597513
Because everyone in this thread is an autistic faggot.
>>
>>52597531
le autism memeword
>>
>>52597513
>No line numbers displayed
>Tab width: 8
>Inconsistently putting opening { on new lines
>Using whitespace to align things that don't even align

200% triggered
>>
>>52597513
Comment WHY, not WHAT

Fucking beginner
>>
>>52597635
Let's see what you're working on
>>
>>52597235
There is
std::bind

http://en.cppreference.com/w/cpp/utility/functional/bind

It's a bit clumsy tho, in most cases you could just use a lambda to achieve the same thing in a more pleasant way.

Afterthought: Is composition a thing? I'll look it up right now
>>
how much of a meme

https://stallman.org/to-4chan.html
>>
>>52597356
This, I have a little brother who was born in 1995 which makes it worse, whenever I see anyone born in 1995 I think of them as a little kid

>They're 21
>My brother is married and has kids
>>
>>52597586
>le meme memeword
>>
does every file have an EOF character?

 for (i = 0; (x[i] = getchar(fp)) != EOF; i++); 


this is throwing a segfault and i can't understand why input works as intended up to the end of the file, where it tries to go beyond and gets stuffed by the compiler.
>>
>>52597720
Make sure the type of 'i' is int, not char
>>
>>52597770

fuck you.
>>
>>52597720
>>52597770
Er, the type of x[] is not char i guess. EOF doesn't fit into char, is what i'm getting at
>>
File: nope.png (79KB, 971x882px) Image search: [Google]
nope.png
79KB, 971x882px
>>52597657
>inb4 why are your identifiers so long
It's not my component that I'm using, this is just the fucking port map to someone else's clusterfuck

I actually have to vary the alignment because otherwise I'd have more spaces than text on most lines.
>>
>>52597793

sweet defs
>>
>>52597790

fuck me. wouldn't that throw a different error though? the problem is the program trying to access protected memory and failing, not trying to stuff too much data into a char and failing.
>>
>>52597720
EOF isnt a character, it is a special return value of getchar. Thus, there is no way to craft a file on which getchar wouldnt do the right thing.

As for your segfault, assuming x is a char [...], I think the assignment inside the parenthesis forcefully converts the return value of getchar from int to char, and then evaluates to the value it effectively assigned to x [i], which is not EOF anymore. Please try assigning to a temporary int variable in the for(), which you then assign to x[i] in the body.
>>
>>52597807

or, maybe the EOF is getting truncated and thus not setting off the for loop's conditional? does that sound right?
>>
>>52597807
assigning EOF to a char doesn't give an error, it just typecasts and probably truncates. it becomes != EOF at that point
>>
>>52591285
Is there a way to write the output of
urandom(length) 
to a file and then later read that file to get the data back? The problem is that urandom can output non-printable characters as well. So encoding with Unicode is not a viable solution. I was thinking about encoding the output in hex or base64 for example, then store the data as such, then retrieve it and decode, to get the original data back but it is not working either. I'm pretty much running out of ideas. I'm using Python 2.7.
>>
>>52597807
> C
> throwing an error
>>
File: 1453523075848.jpg (32KB, 500x500px) Image search: [Google]
1453523075848.jpg
32KB, 500x500px
>Bug Priorities
>UI: High
>Memory Leaks: Low
>>
File: 1450356503040.jpg (106KB, 749x826px) Image search: [Google]
1450356503040.jpg
106KB, 749x826px
>Tfw the project you want to contribute a fix to isn't on Github but some other shitty source control site
>>
>>52597845
>4chan
>pedant
>>52597837
>>52597827
>>52597790
thanks /dpt/
>>
>>52597840
Unless you operating system is old as shit, it should probably support binary files. But right, they are architecture dependent and whatnot. Base64 is a very good solution, the only thing I can ask you is: in what way didn't it work?
>>
>>52597886

isn't this how white people smile at everyone? i'm white and that's how i smile at all strangers, not just black people
>>
>>52597920
Why the fuck do you smile at strangers?
>>
>>52597907
I'm developping on Windows, but the same error occurs on Linux too.
>in what way didn't it work?
The encoding part works (I tried encoding with base64) but when I try to decode it doesn't do anything. printing the variable returns the encoded base64 even tho I decoded it prior printing it. That's weird.
>>
>>52597928

it's hardly a smile, it's more of a grimace. which actually pretty well encapsulates my reaction when you make accidental eye contact with a stranger
>>
>>52597928
In America it's the norm to smile and talk to people you don't know
>>
>>52597793
>post what your working on
>posts something somebody else worked on god knows how long ago

well done, dumbass.
>>
>>52597513

Whatcha doing here?
>>
>>52597949
What gives? What should the decoding process produce, and how does that compare to what it actually produce? Show some code, since the basic idea is right, the problem probably lies in the implementation. What happens if you try
 base64 -d your_file 
, assuming that you are writing the encoded data into a file?
>>
>>52597995
>it is categorically impossible to work on something someone else has worked on before
where do you work again?
>>
>>52597995
>>52598002
this is part of a n64 gameshark-alike that i was working on. basically it works as a bootloader that generates a blob of code that runs occasionally with the game.

i stopped working on it a couple months ago, but i'm revisiting it this weekend. it works.
>>
>>52598036

Neat. Did you look at any docs on the functionality of the actual gameshark or did you kind-of just go at it?
>>
>>52597974
>Americans smile a great deal, even at strangers. They like to have their smiles returned.
http://www.ediplomat.com/np/cultural_etiquette/ce_us.htm
>>
>>52597995
Do you think hardware just connects together like magic?
>>
>>52598055
>Did you look at any docs on the functionality of the actual gameshark
I looked up what some of the special codetypes are for. That was interesting but mostly I just winged it.

The screenshot I posted shows how the "push GS button for X" codes are done. It uses the secret button found on the inside of the 64drive.
>>
>>52598080
>>52598036

>what are you working on
>posts code from Linux Kernel
>gets called out

>HURRR DURRR DOO YU DINK I CAN RUN MUH FIZZBUZZ WIDOUD LEENUCKS ????

retards.
>>
>>52598081

Pretty neat, m8.
>>
>>52598102
and yes, i know it's not code from linux kernel, dumbasses...
>>
self dox

https://www.youtube.com/watch?v=2cg7yS9b1EY
>>
>>52598121
>>52598102
Are you 12 or what? You post like a child. Grow up.
>>
>>52595042
I'll just roll for this
>>
>>52598025
Basically the decoded data should be exactly identical to the encoded data. That's the hard part. Unless I'm being pretty retarded. Take a look:
data = raw_input('Enter data to be encrypted: ')
print('data:', data)

key = genkey(len(data))
print(key.encode("base64"), file = keyfile)

cipher = xor(data, key)
print(cipher.encode("base64"), file = cipherfile)
print('decrypted:', xor(cipher, key))

cipherfile.close()
keyfile.close()

# verify
cipherfile = open("Cipher.xor", "r")
x = cipherfile.read()

keyfile = open("Key.xor", "r")
y = keyfile.read()

x.decode("base64")
y.decode("base64")

print(x)
print(y)

The
genkey()
function simply uses urandom.
The Key.xor and Cipher.xor files are opened as write only earlier in the program, that's why I closed them before I open them as read only. (Yeah I know this part could be better implemented, but right now this isn't a priority). Finally, the xor() function XORs the data + randomly generated data together to created a Ciphertext that is then encoded to Base64 and put in a Cipher.xor file. Same thing for the key. Now, I need to retrieve both the Cipher and Key in order to decrypt them. To do so I simply read the files and retrieve the base64 output. Then I need to decode it (non-working part) so I can throw the result to the XOR function to decrypt the data.
>>
>>52595042
REEEEEEEEEEEEEEEEEEEEEEEEE
POST THE GODDAMN WEBSITE
https://better-dpt-roll.github.io
>>
>>52598121
I'm using a modified FSM to control my SAYEH processor.

In VHDL you don't just clamp things together and it just werks™, you have to actually understand the details.
The actual processor parts are all piss easy, anyone can XOR some bits.
The tricky part is hooking everything up, watching for overflow flags, making sure temp registers are the right size depending on the operation.

Nothing is implied, all casts are explicit. Please tell me more about how modifying a keymapper in a highlevel language is so difficult.
>>
>there are people who still don't use ocaml for everything
What is this, 1945?
>>
>>52594112
Nice.

[HorribleSubs] Mobile Suit Gundam
Iron
Blooded Orphans
16 [1080p].mp4
>>
>>52598250
nvm fixed it. I was just being dumb.
>>
>>52598271
Do you like vhdl? Did you try other HDL's?
>>
>>52597264
How do you know?
//...
sleep(15);
return fac(n);
//...
>>
>>52598485
OK. As for me, I can't even run your code ^^. What is with that?
raw_input
only exists in Python2, then encode only recognises
"base64"
in Python2, but you are using print in the strictly Python3 way, WTF? Also where do the xor and genkey functions come from? You should be precise with code examples man.

You and I can both learn from the answers to these questions so please tell me. Other than that, have a wonderful day.
>>
>>52595042
rolla molla
>>
>>52598652
heh, good luck with that m8
>>
>>52598610
such is the way of the meme snake
>>
>>52591285
Hi
>>
>>52598610
Yeah I only posted some pieces of the code. To all of it. And for the print, I used the dirty
from __future__ import print_function
trick to make Python2 behave as Python3. I needed the Python3 print to decode.
I'd gladly show you the full source code, but not on here.
>>
>>52598710
>5 lines of code
>hard
OK kid
>>
/!\ A L E R T /!\

New thread
>>52598743
>>52598743
>>52598743

/!\ A L E R T /!\
>>
>>52598735
Not all of it*
Jesus I'm tired.
>>
File: 256.jpg (29KB, 367x451px) Image search: [Google]
256.jpg
29KB, 367x451px
>>52598735
>
from __future__ import print_function
>>
>>52598739
yeah nah import text_editor doesn't count as making a text editor
>>
>>52598739
import qt5

app = qt5.QGuiApplication()
in = qt5.QTextField()
in.show()
app.exec()
with open("whatever.txt", "w") as f: f.write(in.text())


This doesn't count as one, anon (I know it probably doesn't work, I've written it in the captcha)
>>
>>52598793
How doesn't it?
It allows you to edit text and it even saves it. It practically has all of notepad's features.
>>
>>52598507
Eh, it gets the job done I guess.
Haven't tried other HDLs but one is more than enough for anyone to deal with.

I'm probably biased but I actually like that VHDL syntax looks nothing like C and its derivatives, helps me to remember that shit is concurrent.
Verilog looks nice and compact though.

>downto
Every. Fucking. Time. Bigger mistakes have been made, but this is one of the most annoying.
>>
>>52598819
kill yourself
>>
>>52598849
lmao butthurt
>>
>>52598765
What's wrong with __future__?
>>
>>52598570
>Let's keep waiting after 60 billion CPU cycles have past, it might still finish!

If the task you're solving is simple enough, they're already being quite generous to give you 15 seconds.
>>
>>52598869
the joke's on you python babby

>>52598871
it's just a bit ridiculous, like everything that has to do with python
>>
>>52598894
>all that hate over python
>>
>>52596989
lmfao if your """"""""program"""""""" takes multiple seconds to do a simple task it sure as hell is fucking useless garbage
>>
>>52596531
>regex
kill yourself
>>
>>52598727
Hello
Thread posts: 326
Thread images: 47


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