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

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

Thread replies: 255
Thread images: 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 (17 KB, 900x900) Image search: [Google]
df.png
17 KB, 900x900
>>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 (84 KB, 557x649) Image search: [Google]
c.png
84 KB, 557x649
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 (1 MB, 500x281) Image search: [Google]
ssd.gif
1 MB, 500x281
>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 (35 KB, 469x527) Image search: [Google]
IMG_20151209_230220.jpg
35 KB, 469x527
Why do we hate C++ again?
>>
File: c.png (74 KB, 783x327) Image search: [Google]
c.png
74 KB, 783x327
Well that just werked
>>
>>52591739
This is called templates you flying retard.
Why gimp yourself on purpose instead of use C++?
>>
File: c.png (85 KB, 549x628) Image search: [Google]
c.png
85 KB, 549x628
>>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 (63 KB, 858x155) Image search: [Google]
y.png
63 KB, 858x155
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 (172 KB, 1291x603) Image search: [Google]
aren.jpg
172 KB, 1291x603
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 (844 KB, 800x786) Image search: [Google]
1402192670496.gif
844 KB, 800x786
>>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 (75 KB, 244x273) Image search: [Google]
file.png
75 KB, 244x273
>>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 (3 MB, 445x247) Image search: [Google]
1413762937354.gif
3 MB, 445x247
>>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 (3 MB, 1280x720) Image search: [Google]
cringe.webm
3 MB, 1280x720
>>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 (20 KB, 420x418) Image search: [Google]
1444502959547.jpg
20 KB, 420x418
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 (788 KB, 900x1619) Image search: [Google]
1440190278446.jpg
788 KB, 900x1619
>>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 (25 KB, 323x454) Image search: [Google]
saedfg.jpg
25 KB, 323x454
>>52594163
>native programming
>>
File: 200_s.gif (25 KB, 247x200) Image search: [Google]
200_s.gif
25 KB, 247x200
>>52590648
>>
Will how I program in imperative languages change after learning functional programming?
>>
File: 20141024_170337.jpg (1023 KB, 3264x1836) Image search: [Google]
20141024_170337.jpg
1023 KB, 3264x1836
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 (752 KB, 1920x1080) Image search: [Google]
challenges_big.jpg
752 KB, 1920x1080
>>52595007
take a pick
>>
File: John-Carmack-profile[1].jpg (96 KB, 1067x788) Image search: [Google]
John-Carmack-profile[1].jpg
96 KB, 1067x788
>>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 (550 KB, 300x468) Image search: [Google]
1364055187344.png
550 KB, 300x468
>>52595042
roll
>>
File: whyamIsosuprised.jpg (93 KB, 1200x676) Image search: [Google]
whyamIsosuprised.jpg
93 KB, 1200x676
>>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 (13 KB, 834x177) Image search: [Google]
KDnpwKi.png
13 KB, 834x177
>>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 (75 KB, 214x298) Image search: [Google]
Oh yess.png
75 KB, 214x298
>>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 (10 KB, 100x100) Image search: [Google]
FunkyWave.gif
10 KB, 100x100
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 (37 KB, 638x399) Image search: [Google]
1435018143235.png
37 KB, 638x399
Ask your much beloved programming literate anything.

>>52595058
>>
>>52595042
schreisse
>>
>>52595414
Carmac has become the meme language king.
>>
File: pic.jpg (284 KB, 688x699) Image search: [Google]
pic.jpg
284 KB, 688x699
>>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 (46 KB, 627x404) Image search: [Google]
super special programmer.png
46 KB, 627x404
>>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 (346 KB, 962x617) Image search: [Google]
Selection.png
346 KB, 962x617
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 (108 KB, 898x648) Image search: [Google]
Selection.png
108 KB, 898x648
>>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 (1 MB, 640x360) Image search: [Google]
umaruic.webm
1 MB, 640x360
>>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 (474 KB, 1680x1023) Image search: [Google]
snapshot1.png
474 KB, 1680x1023
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 (481 KB, 1280x1024) Image search: [Google]
snapshot2.png
481 KB, 1280x1024
FF7 map obligatory wireframe
>>
File: vbN4JjM.png (345 KB, 2144x1800) Image search: [Google]
vbN4JjM.png
345 KB, 2144x1800
>>52596334
protocol-oriented programmingâ„¢
>>
File: snapshot3.png (540 KB, 1280x1024) Image search: [Google]
snapshot3.png
540 KB, 1280x1024
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 (32 KB, 997x241) Image search: [Google]
Selection.png
32 KB, 997x241
>>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 (491 KB, 500x220) Image search: [Google]
ahue.gif
491 KB, 500x220
>>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 (206 KB, 914x953) Image search: [Google]
pic.png
206 KB, 914x953
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
Thread replies: 255
Thread images: 47

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

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