[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: 345
Thread images: 36

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

Umaru-chan edition, the best of all editions.

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

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

wat r u working on, anon-chan ?
>>
First for Java

and fuck anime
>>
What is Inversion of control in a nutshell?
>>
If recursion is so frowned upon then why is PHP called PHP:hypertext protocol?

Check mate atheists
>>
>>52865510
>faggy animu
this is gonna be another shit thread
>>
File: Bt8NEveIcAEsTqH.png (150KB, 600x990px) Image search: [Google]
Bt8NEveIcAEsTqH.png
150KB, 600x990px
>>52865525
>>
>>52865510
Fuck off you faggot nigger, I'll rape you until you die.
https://www.youtube.com/watch?v=u8i_a6F_K0I
>>
Is R really used that much in that industry or am I fine if I know Python and Java?
>>
File: We will spare nobody!.jpg (111KB, 920x468px) Image search: [Google]
We will spare nobody!.jpg
111KB, 920x468px
http://strawpoll.me/6762043
>>
File: SCR_1454948312.png (13KB, 286x293px) Image search: [Google]
SCR_1454948312.png
13KB, 286x293px
I'm trying to make my "hello world" GUI in PyQt5.
I have a simple layout made in Qt Designer of a ListWidget, LineEdit, and a PushButton.
What I want to happen is when the button is pressed it would add a new item to the list with the text from the line.
I sort of understand how signals work, but I don't know how to pass arguments to the slot.

Example (from the pyuic generated file):
self.pushButton.pressed.connect(self.listWidget.addItem)

addItem obviously needs a text argument, where do I put it (specifically
self.lineEdit.text()
)?
>>
>>52865681
https://strawpoll.me/6762107
>>
File: perfectly-looped-aime-chips.gif (593KB, 370x335px) Image search: [Google]
perfectly-looped-aime-chips.gif
593KB, 370x335px
>>52865510
Implementing Conway's Game of Life in Unity because I need to learn Unity.

Any tips on optimising the following?

            foreach (Tile t in world.GetTiles()) {
t.calculateNumNeighbours ();
}

foreach (Tile t in world.GetTiles()) {
t.calculateLivingState ();
}


calculateNumNeighbours() is a block of if statements to check the surrounding tiles (2d array), and check you're not out of bounds.
>>
>>52865882
can you put them both into the same for loop? or do the neighbors need to be calculated for every tile before you can calculate the living state
>>
>>52865706
You need to define your own method that calls `self.listWidget.addItem(self.lineEdit.text())` and connect pushButton.pressed to it yourself.
>>
>>52866062
seeing as the living state depends on the amount of neighbors, probably a no
>>
>>52866094
Wow, that's an embarrassingly simple solution. Thanks, you blew my mind.
>>
>>52865510
PSA:
REMINDER to ignore TROLL posts that contain:
> gcc compiles this wrong code!!! (posts some retarded shit, compiles with g++)
> java can't compare these Integers with ==
> average of two ints in C
> fizzbuzz
> go has no generics
> haskell is useless
> lisp brackets are unreadable
> GC is shit, use a real language
> programming literate
> anime ops
> non-anime ops
> posting new thread to early
> anime is gay
> trap ops
> non-trap ops
> osgtp anarchy politics
> osgtp black women
> tripfags in general

also, don't forget to post this in the next thread.
thanks.
>>
Daily reminder that /g/ can't average two ints, that Go has no generics, that GC is shit, and that Haskell is useless.
>>
>>52866143
Simple connections that you can make entirely in Qt Designer generally work only for very basic things, like connecting QPushButton.clicked to QDialog.accept. Most other signals need to be connected to a method on a controller object that can have the needed logic.

Signals are allowed to pass arguments to their slots, but the slots don't need to take them. For example, QAbstractButton.clicked will pass a `checked` argument (only relevant for checkboxes and toggle buttons), but you can connect it to a method that doesn't take any arguments and it will silently drop the argument.

Also, one benefit of working with Qt in Python is that you don't need to declare slots. Any and every Python method is automatically a slot.
>>
>>52866201
>/g/ can't average two ints
is this true, gee? ishyggy
>>
>>52865510
>>>/REDDIT/
Kys faggot
>>
>>52865520
fuck you too
>>
>>52866344
are you anime
>>
>>52866062
Yes, the state has to be calculated for every tile before the new state is applied - otherwise a tiles state will be altered before later tiles have a chance to asses their own state.
>>
>>52866378
animuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
>>
I'm getting an R4DS and now I'm looking into DS programming if such a thing is possible for me. Anybody here ever programmed for the DS before?
>>
File: 2364548.gif (154KB, 206x350px) Image search: [Google]
2364548.gif
154KB, 206x350px
Can anyone recommend me some good books/resources on search engine optimization?
>>
>>52866485
>not programming/10
fuck off, go to /wdg/
>>
>>52866485
>search engine optimization
>muh buzzwords
>>
>>52866539
SEO is far from a buzzword. Maybe try getting a job that doesn't involve spatulas and you'd know this.
>>
>>52866588
>2^5 * 3^2 * 7
>not programming spatulas
>>
>>52866588
>SEO is far from a buzzword
bwahahahahaha, webcucks actually believe this
>>
>>52866800
I don't do anything in regards to web development. Stop being so insecure, you're actually trying to impress anonymous people while providing nothing but >muh's and laughing like a child. Go look up the difference between a business who uses SEO vs one who doesn't.
>>
Finally started working on muh anime manager. It'll be a client server architecture. The server will be written in Go and the client will be a web app in vanilla-js.
First up is writing a log package that writes to stdout and stores it in the database.
>>
>>52866862
> It'll be a client server architecture. The server will be written in Go and the client will be a web app in vanilla-js.
Are you going to use mongodb? I've heard it's webscale.
>>
>>52866890
Nah senpai. I've heard bad stories about MongoDB and I'm not sold on the whole NoSQL thing. I'll be using SQLite because it's lightweight and KISS. I want the server to run on some chink raspberry pi.
>>
>>52866539
>>muh buzzwords
can we add this to >>52866173 ?
>>
can anyone answer my question?
>>52865510
>>
boost::asio::io_service service;
boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 80);
boost::asio::ip::tcp::socket sock(service);

try {
sock.connect(ep);
}
catch (boost::system::system_error e) {
std::cout << e.code() << std::endl;
}
return 0;


I'm brand new to network programming, trying to learn boost::asio. Could someone explain why this sample bit returns error code "system:10061".
>>
>>52867249
use auto for the love of god
>>
>>52867249
10061 is "connection refused". Either there's nothing listening on that port, or the firewall is blocking it.
>>
File: dpt bingo.png (550KB, 1500x1800px) Image search: [Google]
dpt bingo.png
550KB, 1500x1800px
>>52866173
>>
C++ help plz. Trying to get it to display the sum in blue, but it doesn't calculate the sum. It just lets me input two integers (both in green) and blank space is then printed after hitting enter.
#include <iostream>
#include <Windows.h>
using namespace std;

int main()
{

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
cout << "red text" << endl;
SetConsoleTextAttribute(h, FOREGROUND_GREEN |FOREGROUND_INTENSITY);
int b = 0;
int max = 0;
cout << "Enter max value: " << endl;
cin >> max;
for (int i = 0; i < max; i+=2)
{
int input;
cin >> input;
b += input;
}
SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout << b << endl;
system("pause");
return 0;
}
>>
>>52867544
>console application
>windows
>>
>>52867544
I was able to fix this by removing the endl; after "enter max value: " and just end it with a semi colon instead. Does anyone know why that is? Now I'm trying to get that result to print to blue.
>>
>>52867544
Assuming you're using Visual Studio, simply set a breakpoint in your code by clicking in the left margin. Then, check the values of your variables as you step through the code line-by-line with F11.
>>
>>52867646
so it looks like
cout << "Enter max value: ";
cin >> max;


now
>>
http://pastebin.com/XSRSkbhW

How exactly do I create a new generic object and move it its x/y values and return it?
>>
File: VacantTartCardinal.webm (2MB, 1760x634px) Image search: [Google]
VacantTartCardinal.webm
2MB, 1760x634px
>>52867544
>C++
Horrifying.

I'd like to see this written in C++, I want some more ammunition for my "C++ is a steaming hunk of shit" gun.
>>
File: WorksOnMyMachine.png (53KB, 1366x768px) Image search: [Google]
WorksOnMyMachine.png
53KB, 1366x768px
>>52865677

If you do a lot of statistics, you might want to learn R. Also...

>am I fine if I know Python and Java?
Whether or not your job only requires Python and/or Java, you should always be learning new technologies, whether they be programming languages, libraries, algorithms, etc... It is not possible to know "enough".

>>52867544

>system("pause");
First of all, delete this line from your program, and never use it in any of your future programs. Your program should terminate immediately after the last cout statement, and return to the shell you called it from.

Also, is this what your program is supposed to look like? Because it works as is on my box.
>>
>>52867664
cout << "Enter max value: " << flush;

to ensure flushing
>>
>>52867763
Yeah it's supposed to look like that. I got it, after removing the endl; as stated
>>52867664

When I remove the system("pause") it closes in VS before I can get the result. How do I return it to the shell? Any tips for C++ senpai I'm just starting out but have done a little prog before like javascript and front end.
>>
>>52867698
foreach (var name in Enum.GetNames...

Why not?
foreach (var e in ConsoleColor.getValues ())
>>
>>52867818
What is flushing? that made "function call missing argument" appear in my error list, though it was still able to build.
>>
>>52867864
>that made "function call missing argument" appear in my error list
Paste your code because it werks on my machine.
>>
>>52867698
>I'd like to see this written in C++
It would look pretty much the same.
>>
>>52867839
Yeah just keep the system("pause") or a cin or something to pause execution, that's completely fine for developing inside visual studio.
You'll see later when you start making programs that get called by other programs, that things like using stdout and stderr correctly as well as making sure the program is easily runnable from a command line becomes more important.

>Yeah it's supposed to look like that. I got it, after removing the endl; as stated
I'm pretty sure it just works by coincidence and you can't rely on it in its current state.
Like someone else you need to make sure to flush the buffers, it's the only way to guarantee that the values get properly store from cin and printed with cout.
>>
>>52867849
I have no idea, I wasn't really paying attention when I wrote it, was probably just recycling something I did elsewhere
>>
>>52867864
http://www.cplusplus.com/reference/ostream/flush-free/

When you call certain print functions, the thing you want to write is buffered internally. For example

cout << "a";
// nothing has been printed yet
cout << "b"
// nothing here either
flush();
// finally both "a" and "b" are printed at the same time.

This is for performance reasons, because print calls are actually relatively expensive. Forgive me if the details aren't 100% correct since I haven't used C++ in years but that's the gist of it
>>
Unixfags, why isn't this working for me?
notify-send "$(tail -n 1 text | sed 's/^.*\]//')"


The output of the shit in brackets does what I want but when I add notify-send in front, it doesn't
>>
File: colors.png (73KB, 876x488px) Image search: [Google]
colors.png
73KB, 876x488px
>>52867698
>>
>>52867839

>When I remove the system("pause") it closes in VS before I can get the result.
It's a console program, Anon. You run it from a console. If you run it in other ways, then what happens is Windows creates a console window for the duration of the program, and kills it afterwards. You ever use an installer on Windows that might pop up a command prompt for like a few seconds and then kill itself? That's what's happening. If you already have a console open, however, then the program you compiled becomes a child process of the console you opened. When your program terminates, it resumes execution back to the console that opened it.

And I would recommend not using Visual Studio. MSVC is the worst C and C++ compiler on the market. If you MUST use Visual Studio, there's a way to get the system("pause") crap inserted in by the compiler for debugging (it's either F5 or Ctrl+F5, I can't remember which), but if you have the option to, I recommend MinGW-w64, which is literally just gcc for Windows. On other platforms, MinGW is a cross-compiler to Windows, which can be nice if you want to build for, say, Windows, Linux, and Mac OS X on the same machine, with just a change in prefix (and maybe some LDFLAGS) for each target.
>>
http://pastebin.com/XSRSkbhW

How exactly do I create a new generic object and move it its x/y values and return it?
>>
>>52867839
>When I remove the system("pause") it closes in VS before I can get the result.
If you're running under debugger - set a breakpoint on the last line.
Otherwise run with ctrl+f5 (i.e run without debugger) and it will pause at the end for you.
>>
File: 1446039129436_0.png (580KB, 800x2810px) Image search: [Google]
1446039129436_0.png
580KB, 800x2810px
>>52865520

What are you doing on 4chan then?
>>
>>52865510
>r/programming
>r/compsci
>r/ReverseEngineering
>r/softwaredevelopment
feel more like r/learnprogramming
>>
>>52868043
ABSOLUTE
S A V A G E
>>
>>52868116
Fuck off weeb.
>>
>>52867839
You can replace the system call with blocking I/O, like
cin >> someVar;
.
>>
>>52868116
Fuck off weeb.
>>
>>52868071
The trailing const makes me think it's C++, but I'm pretty sure
new circle newCircle;
isn't valid C++. Anyway, what's wrong with simply copying the original object, setting whatever you want for the new instance, then returning it?
>>
>>52867536
nice
>>
>>52868270
It is C++ yes, sorry. I am unsure about how to do that, how do I create/copy a new object with a generic name? I was just guessing with that line lol
>>
>>52868301
>how do I create/copy a new object with a generic name?
There is a thing called copy constructor. Maybe you should google it.
>>
File: ij.jpg (95KB, 600x600px) Image search: [Google]
ij.jpg
95KB, 600x600px
I want a subtle swastika logo for my program, but I don't know how to go about doing it, any ideas?
>>
>>52868270
How do I do the equivalent of this in Haskell (loop + i/o)?
int sum = 0;
for(;;) {
int a;
scanf("%d", &a);
if (a == 0) break;
sum += a;
)
}
>>
>>52868301
What the hell is "a generic name"? Are you talking about templates?
>>
>>52868369
Incorporate it as some spoke in a machine.
>>
>>52868369
No bigots allowed here, go back to /pol/.
>>
File: ee.gif (6KB, 150x150px) Image search: [Google]
ee.gif
6KB, 150x150px
>>52868369
Something like pic related.
>>
>>52868369
>>>/gd/
>>
>>52868373
loop sum = do
a <- read
print a
if a ~= 0
loop (sum + a)

main = loop 0


I'm not sure about the syntax
>>
>>52868449
This. Call it a pagan logo so you won't get scolded at.
>>
>>52865510
Haha It says DOLL because DELL is a computer name
>>
>>52865510
What are you, Github? Get your fucking code of conduct very deeply inside your anus.
>>
>>52868373
>>52868452

loop :: Int -> IO Int
loop sum = do
line <- getLine
let a = read line
if a == 0
then return sum
else loop (sum + a)

main :: IO ()
main = do
sum <- loop 0
print sum


is better
>>
File: c_colors.jpg (570KB, 1366x768px) Image search: [Google]
c_colors.jpg
570KB, 1366x768px
>>52868043
>>52867698

you guys even C?
>>
>>52868451
>>>/trash/
>>
>>52867249
>learns asio
>uses connect instead of async_resolve and async_connect

what's the point
>>
>>52868373
main :: IO ()
main = do
sum <- newIORef 0
continue <- newIORef True

whileM (readIORef continue) $ do
line <- getLine
let a = read line :: Int

if a /= 0 then
modifyIORef' sum (+a)
else
writeIORef continue False
>>
>>52868548
you even rice?
Default i3 config? What is actually wrong with you?
>>
File: h.jpg (24KB, 640x480px) Image search: [Google]
h.jpg
24KB, 640x480px
I don't think 2 should be a prime number.

There needs to be a primes must be odd rule.
>>
>>52868595
sorry, whileM should be whileM_
>>
>>52868620
Only autists care about ricing, and there's a containment thread for them; off you go.
>>
File: im_an_idiot.png (55KB, 654x387px) Image search: [Google]
im_an_idiot.png
55KB, 654x387px
https://msdn.microsoft.com/en-us/library/windows/hardware/ff551005%28v=vs.85%29.aspx

WinAPI has a specific function to draw the icons of the Device Manager. Unbelievable.
>>
File: colors.png (281KB, 1366x768px) Image search: [Google]
colors.png
281KB, 1366x768px
>>52868043

Not too difficult to do multi-platform, actually.
>>
>>52868621
OK, let's make 1 a prime number instead!
>>
>>52868669
idiot
>>
>>52868452
>>52868542
Hmm... I'd rather stay away from recursivity, but these examples do look readable.
>>52868595
>>52868634
My library-fu isn't strong enough to get all this, but it does look like it prefers higher order functions over recursivity, which I like.

Thanks for the answers, guys!
>>
>>52868707
>I'd rather stay away from recursivity
Functional programming is not for you.
>>
>>52868696

Care to elaborate?
>>
>>52868679
It would make more sense.
>>
>>52868724
tripfag
>>
>>52868595
loop :: Int -> IO Int
loop x = do
line <- getLine
let a = read line :: Int

if a == 0 then
return x
else
loop $ x + a

main :: IO ()
main = do
result <- loop 0
print result
>>
>>52868669

> Use external library for printing random characters
> Still calculate positions manually
>>
File: argument.jpg (79KB, 777x656px) Image search: [Google]
argument.jpg
79KB, 777x656px
>>52868696
>>52868748
you're at the bottom, congrats.
>>
>>52868723
That's a pretty narrow perspective, to define an entire paradigm in terms of a function calling itself.
>>
>>52868758
return $ loop $ x + a
>>
>>52868777
Weebshits, everyone. Always has to inject this childish shit into literally everything.
>>
File: 1447070979259.png (567KB, 560x577px) Image search: [Google]
1447070979259.png
567KB, 560x577px
>>52868777
I'm at your bottom fuckboy.
>>
>>52868770
here fag
#include <stdio.h>

int main() {
for(;;) {
printf("\e[%dm\e[%dm%c",(rand() % 7) + 30,
(rand() % 7) + 40,
'A' + rand() % 52);
fflush(0);
}
}

>>
>>52868777
This doesn't apply to tripfags.
>>
>>52868542
beat me to it
this is the idiomatic haskell solutionc
you're free to use whichever you want though
>>
>>52868770

addch prints a character and advances the cursor. If it's at the last spot on the console, it doesn't advance the cursor. This just makes the cursor go all the way back to the top.

But if you know of any multi-platform console libraries other than ncurses, be my guest in sharing them.

>>52868839

The problem is that this doesn't work on Windows, which has no support for these escape codes.
>>
>>52868795
actually the return isnt needed
>>
>>52868621
> There needs to be a primes must be odd rule.
You may as well say that there should be a primes must not be multiples of 3 (or 5 or 7 or ...) rule. Each prime p is the only prime which is a multiple of p. 2 is no different in that regard.

The primes aren't some arbitrary set of numbers which someone chose. The primes are what they need to be in order for the fundamental theorem of arithmetic to hold.
>>
>>52868723
Functional programming has nothing to do with recursion.
>>
>>52868839
Good job optimising-out the variables and making it 10x less readable. I'm sure no compiler could figure that out.
>>
>>52868885
>The problem is that this doesn't work on Windows, which has no support for these escape codes.
Your "portable" version does not either, so what's your point?
>>
>>52868858
I'd TCO it, myself, but non-TCO does look "cleaner".
>>
>>52868925
>optimising-out the variables
wat
>it 10x less readable
are you retarded ?
>>
>>52868885
Just print normally, any ANSI-compatible terminal for windows would print it correctly.
>>
>>52868930

My portable version demonstrably works on Windows, and should work on nearly every Unix, since it's using ncurses.
>>
>>52868908
Recursion is fundamental to functional programming. You can't write a non-trivial program in any remotely-pure functional language without it.

The fact that it also exists in (most) non-functional languages doesn't change that.
>>
>>52868970
> any ANSI-compatible terminal for windows
I.e. not the Windows console, which is what you typically care about.
>>
>>52868669
your code is shite
>>
>>52868792
>>52868908
codemonkeys will always be codemonkeys
>>
>>52869026
Functional programming is programming with functions. Functions are maps from input to output. You don't need recursion anywhere.
>>
>>52869048
desu if you're making a console app for windows chances are you will ship a decent console with it
>>
>>52869070
i didn't see yours pahjeet
>>
>>52869105

Funny. Every single console application on my machine was distributed standalone. If you're going to have to install a new terminal emulator just to run your program, you might as well just make it a GUI.
>>
>>52869080
ad hominems will always be ad hominems
>>
>>52869097
> You don't need recursion anywhere.
You need it to actually write non-trivial functions. E.g. anything which processes recursive types such as lists.

PS (just in case you're trying to be "clever"): using a pre-defined recursion operator (e.g. some form of the Y combinator) doesn't mean that you aren't using recursion.
>>
>>52869213
Uhh...
void f(Node *node)
{
while(node)
{
// process
node = node->next;
}
}

void g(Node *node)
{
if(!node) return;
// process
g(node->next);
}


Why would you have to opt-in for the second solution in case of a list like that?
>>
>>52869262
Because the first one isn't functional, node gets reassigned repeatedly. The discussion at hand is within the context of functional programming.
>>
>>52869309
>The discussion at hand is within the context of functional programming.
Yeah I realized that right after I posted.
>>
>>52869309
it gives me the same results for the same inputs every time :^)
>>
Hey guys, I'm starting a slightly bigger-than-usual project (for me) which is aims to be a sort of libnotify on steroids.

The thing is, it should communicate with other programs in a way that is nice to handle from any programming language/whatever, preferably in a pre-specified data format.

Question is, is it acceptable to let a program output JSON to stdout and then read and reconstruct this data from stdin? Or is there a better (cross-platform) way to do this.
I found unix ipc sockets, but those will not be portable to windows, will they?
>>
>>52869548
Regular sockets listening on localhost?
>>
>>52869213
>PS (just in case you're trying to be "clever"): using a pre-defined recursion operator (e.g. some form of the Y combinator) doesn't mean that you aren't using recursion.
That was what I had in mind. I was thinking of a language that has pre-defined functions (e.g. map and fold) but doesn't allow any language-level recursion.

It depends on whether you mean a function calling itself or recursion in the semantics where a part of a program is evaluated multiple times.

The semantics of loops involves recursion in the second meaning.
while e do s
means
if e then (s; while e do s)

This is a pre-defined recursion operator even though the language might not have user-defined functions at all.
>>
>>52869548
Just write the JSON to disk and let the other program read it from there, unless you have some really weird usecase but I can't think of a reason to print it to stdout.
>>
>>52869548
Yeah you can have a directory and have your daemon read JSON files from there and delete them after displaying the notification
>>
>>52869595
that sounds like a horrible idea
use some kind of platform-specific fifo ipc mechanism behind the scenes if you want it to be actually crossplatform and not horrible
>>
File: JzllBqd.png (11KB, 228x414px) Image search: [Google]
JzllBqd.png
11KB, 228x414px
Well, /dpt/?
>>
>>52869595
piping
>>52869213
Your PS is dismissing the very thing that's fundamental to the discussion. Many different computation structures can be transformed into each other, and a lot of stuff can be rewritten iteratively, recursively etc.
The important question is: does the code you write have explicit recursion? Whether the underlying interpreter/compiler is using loops, recursion, Y combinators etc. is irrelevant.
By your reasoning, Haskell wouldn't count as a pure language, because its underlying runtime can do I/O, but that's irrelevant. The important thing is whether the code that haskell allows you to write respects the laws governing functional purity and referential transparency, to allow it to be treated as a rewrite system.
>>
>>52869692
>
using namespace eyes_hat_smiley;
>>
>>52869692
Reminds me of INTERCAL.
>>
File: jcracket.png (514KB, 1680x1050px) Image search: [Google]
jcracket.png
514KB, 1680x1050px
>2016
>not dropping c++ for racket

Where were you when Racket became the top notch programming language ?
>>
>>52869213
>You need it to actually write non-trivial functions. E.g. anything which processes recursive types such as lists.
You can just use an explicit stack and/or queue, then you wont need any recursion.
>>
>>52869740
Fuck that, is he using a fucking Mac?
>>
>>52869740
Most alpha man you'll ever meet. He even has a 3d waifu.
>>
>>52869810
When will you learn it doesn't fucking matter what you use? Christ, grow the fuck up already.
>>
>>52869740
>not writing an entire ooerating system in glorious, dynamically scoped emacs lisp
its like you enjoy tormenting yourself
>>
>>52869841
And a Ferrari.
>>
File: TFIGHT295_13_800.jpg (279KB, 800x800px) Image search: [Google]
TFIGHT295_13_800.jpg
279KB, 800x800px
>>52869740
>racket
>>
>>52869842
Nvm me, he's using a fucking Mac!
>>
How do you teach a dog to program? I tried google but didn't get many relevant results. I'd like to start with csharp as I think python would be a waste of time for him.
>>
>>52869692
Daily reminded that voice programming is the imminent future:
https://youtu.be/8SkdfdXWYaI?t=9m2s
>>
>>52869842
>it doesn't fucking matter what you use?
Same can be said about using Racket.
>>
>>52869892
Retarded.
>>
>>52869716
> Your PS is dismissing the very thing that's fundamental to the discussion.
Quite the opposite, actually.

To construct a non-trivial (i.e. anything that isn't O(1)) program using only pure functions, you need recursion. Whether that's through permitting recursion in bindings (i.e. allowing the name of a function to appear within its definition) or through pre-defined recursion operators doesn't matter. Either way, you need recusions.

> The important question is: does the code you write have explicit recursion?
Ah, so *now* it's "explicit" recursion. /dpt/ - daily goalpost-moving thread.

> Whether the underlying interpreter/compiler is using loops, recursion, Y combinators etc. is irrelevant.
What is relevant are the semantics of the language. Within a binding, can the bound name appear in the expression which is bound to it (i.e. "let rec" semantics versus plain "let" semantics)? If not, does it provide some other mechanism for recursion?

If the answer to both of those is "no", then you have some explaining to do: with regard to how non-trivial programs can be written using only functions.

> By your reasoning, Haskell wouldn't count as a pure language, because its underlying runtime can do I/O
Being able to do I/O doesn't make a language "not functional". It's the implicit state and side effects which normally go hand-in-hand with I/O (but not in Haskell, which provides I/O via a pure functional interface by making the previous state of the world a parameter and the modified state part of the return value).
>>
>>52869777
> You can just use an explicit stack and/or queue
How do you do this without using recursion (or constructs which are effectively recursion, and would have to be implemented using recursion in a functional context)?
>>
>>52869892
This is exactly the kind of bullshit I would expect from a python programmer.
>>
>>52869954
>>52870277
>dude wants to program despite his disabilities
>"kill yourself retard"
nice
>>
>>52869585
This sounds pretty usable, only I'd have to make sure both programs know which port is being used but I guess I could get that done

>>52869595
>>52869644
This sounds kind of cool as well.


>>52869716
>piping
Isn't that the same thing as stdout->stdin?

Thing is, the notification-creating scripts/programs should be as simple as possible to make in any language, so they should not have to look for any folder/port/use a library for that, instead I need the simplest way possible to get some data format across to the 'server' which handles the further stuff.
So far I guess I'll go with sockets, have some command return the proper port when necessary and allow piping input for tiny scripts that can't use sockets.

Thanks for the three replies in 5 minutes anons
>>
>>52870201
>Ah, so *now* it's "explicit" recursion. /dpt/ - daily goalpost-moving thread.
Unless you can specify where the discssion was about *implicit* recursion, you did it earlier, by going on about how Y is "really just implicit recursion". One could argue recursion is "really just an Y combinator". Both positions are retarded, and I have no clue why you think recursion is more deserving of any special attention among the alternatives to it.
>>
>>52869740
>2016
>Dropping IdSoftware the company he nurture, born and grow with for hipster VR shit.
>>
File: c++-colors.webm (3MB, 1920x1080px) Image search: [Google]
c++-colors.webm
3MB, 1920x1080px
#include <cassert>

#include <cstdlib>
#include <ctime>
#include <iostream>

#include <unistd.h>

using namespace std;

enum Color {
BLACK = 0,
RED = 1,
GREEN = 2,
YELLOW = 3,
BLUE = 4,
MAGENTA = 5,
CYAN = 6,
WHITE = 7
};

struct fg {
fg (Color color) : color (color) {}
Color color;
};

struct bg {
bg (Color color) : color (color) {}
Color color;
};

ostream &printAtt (ostream &os, int att) {
return os << char (27) << '[' << att << 'm';
}

ostream &operator << (ostream &os, const fg &fg) {
return printAtt (os, 30 + fg.color);
}

ostream &operator << (ostream &os, const bg &fg) {
return printAtt (os, 40 + fg.color);
}

double randDouble () {
return ((double) rand ()) / ((double) RAND_MAX);
}

int randInt (int start, int length) {
int a;
do {
a = length * randDouble ();
} while (a == length);
return start + a;
}

char letter () {
return 'a' + randInt (0, 26);
}

Color color () {
return (Color) randInt (0, 8);
}

int main () {
srand (time (NULL));
while (true) {
for (int i = 0; i < 100; i++) {
cout << fg (color ()) << bg (color ()) << letter () << flush;
}
usleep (50000);
}
assert (false);
return 0;
}
>>
>>52870368
That's not horrifying to you?
>>
>>52870410
What exactly?
>>
>>52870363
People move on, get over it. I don't care for VR, but I sure hope I won't be doing the same stuff I'm doing now 20 years down the road.
>>
>>52870368
>
bg& fg 
>>
>>52870427
>using namespace std;
>& next to the identifier
>repetition of code for fg and bg
>((double) rand ()) / ((double) RAND_MAX)
>int a; // really, was this the best name you could come up with?
>NULL // if you're gonna use C++, you might as well take advantage of nullptr
>unavoidable assert(false)
>>
>>52870368
so much abstraction its like java
>>
>>52870368
...(Color color) : color (color) {}
Color color;

kek
>>
>>52870241
Continuation passing - keep generating new functions which either push or pop the stack and just keep calling them.
>>
>>52870314
these faggots don't seem to understand reality. wonder how old they are
>>
>>52870368
ENTERPRISE C++!!
>>
>>52870459
oh shit

>>52870513
>using namespace std;
Why is it bad habit? Provide concrete example.
>& next to the identifier
The only correct way to write it.
>repetition of code for fg and bg
Ho I miss an impressive factorization.
>((double) rand ()) / ((double) RAND_MAX)
One day you'll know why it is the correct way to do random. Modulus is bad.
>int a; // really, was this the best name you could come up with?
Is it important.
>NULL // if you're gonna use C++, you might as well take advantage of nullptr
nullptr is recent, and I love my old good NULL
>unavoidable assert(false)
No, you just suck. It's an unreachable assert.
>>
>>52870314
What did you expect? I don't think it's a big secret that this place is full of jackasses who fancy themselves as "amoral nihilists" or some other bullshit.
>>
File: DFG3RGF.png (15KB, 1864x338px) Image search: [Google]
DFG3RGF.png
15KB, 1864x338px
Does CI count as programming? Getting this shit set up for work.
>>
>>52870745
Working without CI doesn't count as programming dude
>>
>>52870715
Oh I know about that, I was just wondering if they even checked to see why he chose to program this way. I bet he himself also thinks that what he's doing is literally retarded by definition, but it's the only way in his case.
>>
>>52870704
>gets told his coding style is disgusting
>it doesnt matter guise!

You almost had me.
>>
>>52870704
>One day you'll know why it is the correct way to do random. Modulus is bad.
Why not std::random then if you're gonna shit on rand()?

>nullptr is recent, and I love my old good NULL
It's not *that* recent.
>>
>>52870745
Eh, I'd rather call it software engineering, but it does go hand-in-hand. Kinda like OBS/GYN, I guess - different, but rarely seen separately in the wild.
>>
File: INTO THE TRASH.png (377KB, 2550x1650px) Image search: [Google]
INTO THE TRASH.png
377KB, 2550x1650px
>>52869740
>Macbook
>>
>>52870704
>2011
>recent
C++ programmers, people!
>>
>>52870851
xD
>>
>>52870704
calling rand() in C++ is wrong by default.
>>
File: Facebook-logo-thumbs-up.png (2KB, 50x42px) Image search: [Google]
Facebook-logo-thumbs-up.png
2KB, 50x42px
>>52870851
>>
>>52870833
I consider it a benefit, but working in a small company allows me to do a little bit of everything.
>>
>>52870816
>Why not std::random then if you're gonna shit on rand()?
Because google doesn't know what is std::random
>It's not *that* recent.
2011 is recent

>>52870886
Could you provide sample code, I failed to find it with google.
>>
>>52870934
>2011 was recent
Yeah a few years ago maybe.
>>
>>52870704

>Modulus is bad
So... correct me if I'm wrong, but isn't RAND_MAX typically a power of two, minus one? And don't most terminals support a number of colors equal to a power of two? So wouldn't using modulo 8 with rand() produce uniformly random results (assuming rand() wasn't a piece of shit)?
>>
>>52870934
#include <iostream>
#include <string>
#include <map>
#include <random>

int main()
{
std::random_device rd;
std::map<int, int> hist;
std::uniform_int_distribution<int> dist(0, 9);
for (int n = 0; n < 20000; ++n) {
++hist[dist(rd)]; // note: demo only: the performance of many
// implementations of random_device degrades sharply
// once the entropy pool is exhausted. For practical use
// random_device is generally only used to seed
// a PRNG such as mt19937
}
for (auto p : hist) {
std::cout << p.first << " : " << std::string(p.second/100, '*') << '\n';
}
}
>>
File: upvoteracoon.webm (701KB, 388x260px) Image search: [Google]
upvoteracoon.webm
701KB, 388x260px
>>52870851
>>
>>52870934
http://www.cplusplus.com/reference/random/
>>
>>52870950
I'm not sure if I must stick with the old C++ or accept the modern thing. It's still a debate in my head.

>>52870953
>So... correct me if I'm wrong, but isn't RAND_MAX typically a power of two, minus one?
Where is it written is C89 spec?

>>52870956
C++98 or only C++11?
>>
File: Untitled.png (149KB, 771x717px) Image search: [Google]
Untitled.png
149KB, 771x717px
>>52870934
>Because google doesn't know what is std::random
ugh

>2011 is recent
so recent that all major compilers have supported it for years
>>
>>52870977
since C++11 according to http://en.cppreference.com/w/cpp/numeric/random.

Sepples has most random stuff build in already. Tested, verified and no hacks needed.
>>
#define DEFAULT_SIZE 4

struct array {
char *data;
size_t len;
};

bool ensuresize(struct array *a, size_t size)
{
if (size < a->len) return true;

size_t newlen = a->len ? a->len * 2 : DEFAULT_SIZE;

if (newlen < size) newlen = size;

char *newdata = realloc(a->data, newlen);

if (!newdata) return false;

a->data = newdata;
a->len = newlen;

return true;
}


Is this code all I need for a growable array? Anything wrong with it?
>>
>>52870977
>It's still a debate in my head.
Why not try and see? You might like some stuff, and you can go back if you don't like it. Personally, I like lambdas and the new type traits facilities, but I stay away from fancy initializer list semantics.
>>
>>52871011
It's not std::random

>>52871020
I still don't know if I must use modern C++ or stick to C++98.
>>
>>52871020
>Sepples
Most people use that term in a derrogatory fashion.
>>
>>52871056
Yes I tried it. I look what modern c++ offer. The only convincing thing is moving constructor or assignation.

I have to think a lot before making my choice.
>>
Does anyone know how to link pre-made libraries like SDL and OpenGL using CMake? I've been at it for a long time.
>>
>>52870977

I said typically, not always. I'm not sure what ISA you're using. It's probably Intel, or maybe ARM, MIPS, or POWER, but very likely, it's using bits, rather than some ternary model. I'm sorry willing to bet that RAND_MAX is probably INT_MAX. Did I call things right?

Also, why C89? We should be using C++14 and C11, and nothing older.

>>52871080

Eh, why not own the word if you're a C++ fan?
>>
>>52871086
Wtf is wrong with you guys? C++14 is such a step forward... Did you stick with WinXP and Debian Woody too or what?
>>
>>52871162

Why did autocorrect replace "also" with "sorry"?
>>
File: D39her4.png (75KB, 584x697px) Image search: [Google]
D39her4.png
75KB, 584x697px
Anyone mind explaining what's up with the Telegram API?
>reply_to_message : Message (Optional)
>For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
obviously the second one here should have that field set, but this only happens if it's a reply to a reply. anyone know why that is/how to fix it?
>>
>>52871162
>Also, why C89? We should be using C++14 and C11, and nothing older.
If I use a C function in C++ it can only be C89. The C world has stop with C89 and I refuse any modern "C". But I can accept modern C++, but the C part must be C89. It's a religion.

>>52871180
The last version of C++ isn't C++11? C++ is new for me.
>>
>>52871162
Why own it? It just sounds confusing to me to see someone speak favorably of "sepples". Do mexicans try to own "spic", for example?
>>
>>52871180
I use Symbian! Am I special yet guise?
>>
>>52868591
>sample
>>
>>52871195
Nope. C++11 is the start of "modern C++", but C++14 is out, and now they're working on C++17 (I hope, at the very least, that we'll get concepts and modules finalized by then).
>>
>>52871237
Gonna google that.
>>
>>52871195
Yep, it was 2014 at that time. It's not the biggest update you could imagine (my clock), but it has some neat things. Also C++17 is in the pipeline. It'll be out by mid-2017
>>
>>52871195

>The C world has stop with C89
In my experience, it's more like it's stuck on C99. Transition to C11 should occur when people realize that C11 exists.

>I refuse any modern "C"
Why? Don't like anonymous structs and unions? Don't like static assertions? Don't like generic macros?
>>
>>52871282
>In my experience, it's more like it's stuck on C99. Transition to C11 should occur when people realize that C11 exists.
The industry is still using C89 (embedded world). Only a minority use modern "C".

>>52871282
>Why? Don't like anonymous structs and unions? Don't like static assertions? Don't like generic macros?
Useless, useless, useless, useless...
>>
>>52871328
being this fucking backwards
>>
>>52870976
Why do some people prefer cplusplus.com over cppreference.com?

I find cppreference more pleasant and helpful in every way. I can't even find where cplusplus covers the core language.
>>
>>52871328
>"C"
Why do you keep quoting it, as if you're usig
extern "C"
or something?
>>
>>52871363
C is for C89 only. Anything else is "C" but is not C. It's a religion, I don't want to go to hell.
>>
>>52871392
>but is not C
Your cult doesn't get to decide, ISO does.
>>
>>52871425
No the majority of industry decide. C is C89. Only hobbysts use "C".
>>
>>52868373
mySum a = do 
let list = takeWhile (!= 0) a
mapM_ print list
return (sum list)
>>
>>52871191
Could be me but I don't really see a reply, just two outgoing messages from the bot, and you will only get that field set if the user responds to the bot's message.
At least that's how I'd interpret it
>>
>>52871457
it's (/=), not (!=)
>>52871701
the second one is a reply to another message (top top bit is the message being replied to)
i actually figured it out though... for some reason, the people who designed the API thought that it made sense to make those replies invisible if the bot hadn't seen the message in the first place. in order to get around that you have to disable "privacy mode" which lets you read messages not directed at your bot.
>>
$.get("http://www.a-website-here.xyz", function(data) {
var dataLatest = $(data);
console.log(dataLatest);
document.getElementById("status").innerHTML = dataLatest;
});


What format does this output the HTML from the url? How can I shorten down the variable to get a specific snipped (if I know what it's proceeded and succeeded by)
>>
>>52867698
>>52868548
BTFO
>>
>>52871985
nvm the first question. It's just returning the whole page's HTML. How can I shorten it down if I only need a specific 10 number string
>>
>>52871985
>getElementById("status")
This should only get the HTML inside the tags with id status, for example <button id="status">
You would use similar tricks to find the specific text you need.

>>52872167
>How can I shorten it down if I only need a specific 10 number string
What do you mean by 10 number string? What string of 10 numbers, where would you get it from? What would these 10 numbers represent?
>>
>>52871328
>Useless, useless, useless, useless...

You must enjoy being a troglodyte
>>
>>52872275
The page I'm getting information from has a time on it for each post made. Need to get this string (time since epoch) and store it to a variable
>>
File: mfw waiting.gif (148KB, 340x340px) Image search: [Google]
mfw waiting.gif
148KB, 340x340px
>mfw waiting for my textbooks in the mail
>>
>>52869740
>Where were you
On my computer, programming in Racket.
>>
>>52872312
Use a html parser
Or just use regex if it's not production code. This is widely regarded as a programming sin but well there's more of that in this thread
>>
>>52872312
It's going to depend on the HTML on the page. If the timestamp is inside of tags with an ID you can use exactly the code you had you just have to replace "status" with "timestamp" or whatever.
>>
File: 70w7pbE.jpg (57KB, 445x500px) Image search: [Google]
70w7pbE.jpg
57KB, 445x500px
>>52865552
PHP is also frowned upon
>>
>>52872429
 [{"code":"BBhD-V5zLaY","date":1454915838.0,"dimensions" 


It's stored like this in js
>>
>>52872421

Using regex for arbitrary HTML is a problem, but if you're trying to get a small piece of information from a page which will be mostly the same every time, it's considerably more forgivable.
>>
>>52872347
You're a drawn animation that pedophiles jerk off to?
Please just download the pdfs and save the children...
>>
>>52872458
Right click the timestamp and inspect element. While you hover over it, your browser should highlight the relevant HTML. For example if I hover over your post i get:
><div class="postContainer replyContainer" id="pc52872458"><div class="sideArrows"... Etc.

Now if I want all the contents of your post I can use getElementById("pc52872458");
>>
I've been fucking around with Excel for some small work stuff and I had a question. Say I have the following table:

A B
x 1
y 5
z 1

Is there a way to make a formula as follows:

'for all cells in column B, if value equals 1 then return value of corresponding A cell'

So in this case x and z would be returned. Anything like that?
>>
>>52872718

something like

=IF(value_cell = 1, char_cell ,"")


will do it.
>>
>>52872841
Is there a way to cycle through it for all rows in the worksheet?

Something like 'If the Current value of B = 1, output the corresponding value of cell A'?
>>
is making programs that scan and chat in IRC in C++ ok or am I severely missing out on something if I were to use like C# or Java
>>
Put that formula in the first row of the third column and then drag it down, it will apply the formula to all the pairs.
>>
>>52872959

If you're making an IRC client, C++ is fine, as is C# and Java.

If you're making an IRC bot, I would recommend some scripting language that's easy to hack together (i.e. Python, Perl, Ruby). IRC bots don't need performance; they just need to be flexible.
>>
So, I started with TeamTreehouse on Friday. I'm just wrapping up the lesson on Java Objects (I'm working through it while I'm at work, so it's slow going).

I feel like I'm not really understanding much yet, even though I'm leaps and bounds ahead of where I was.

1) Has anyone here ever used TeamTreehouse?

2) If so, have they used it specifically to find work, even freelancing?

3) What kind of supplementary studies would you suggest to really hammer home the concepts?

I don't like to think I'm dumb, but this stuff makes me feel like a potato among potatoes.
>>
>>52873023
how in demand are skills in those languages? The project I'm intending to do is for my own funsies but I have minimal experience with those languages, and if I learn something I might as well be able to put it on a resumé when I start applying for jobs soon

also I may or may not be retarded because when I tried to compile Lua on my computer and set up my path variables I couldn't get it to run the functions in command prompt
>>
>>52865706
>>52865882
>>52867249
>>52867544
>>52867664
>>52868839
>>52870368
>>52870956


hey guys, how do I do the trick of posting code here? thanks
>>
>>52873131
[ code ] my code here [ /code ]

remove the spaces inside brackets
>>
>>52873131
>>51971506
>>
[spoiler]Windows API sucks harder than a transexual thai prostitute[/spoiler]
>>
>>52873086
C++, C#, Java, and Python are all in-demand.

If you used Lua for Windows it should install correctly. Otherwise its a better idea to just install cygwin or MSYS2 and install Lua via package manager.
>>
>>52873086

Pretty much every language is in demand to some degree. You can't go wrong learning something new.
>>
For someone who did some very minor C++ and C programming back when I studied for my engineering degree, which SDK would be easiest to pick up and make a simple GPS-tracking based app, iOS or Android?
>>
How should someone go about learning C?
>>
>>52873210
>>52873198
well after taking a short gander at a website comparing the two ( http://c2.com/cgi/wiki?RubyVsPerl ) I think I shall begin my life as a perl programmer today

thank
>>
>>52873236
Android uses Java (which is similar to C++) and has more market share. Objective-C (which iOS uses) is less similar to C/C++ than Java is to them. Not sure how Swift compares.
>>
>>52873279
From the beginning. Pick up a book.
>>
>>52873279
K&R
>>
>>52865525
Dependency injection.
>>
>>52873294
Okay, thanks. Are there any significant differences in how easy it is to publish the app, or cost related to it? Gonna be a free one I guess, and just for fun. I think more feature-rich apps that cover what I have in mind already exists.
>>
stupid question but how do I increment an int within a while loop in Java

i.e.


while (inFile.hasNext())
{
sNum = 0;

. . .

sNum++;



Obviously, with the code as it is it just keeps setting nSum back to 0 after the loop runs. Can I put the variable declaration in the parens after the while? Java isn't letting me
>>
>>52873283
pffffttttt
Good one.
>>
>>52873279
C Programming: A Modern Approach is good if you want to drop some money on it.
Also find Understanding and Using C Pointers on it-ebooks
>>
>>52873365
put sNum=0 before the while loop? wtf?
>>
>>52873365
int num = 0;
while (inFile.hasNext())
{
...
sNum++;
}
>>
>>52873384
you're right sorry i'm a retard.
>>
>>52873283
Learn Perl6 or literally anything other than Perl5. Perl5 is a write-only language and the bane of every maintainer's existence.
>>
>>52873300
I was hoping for book recommendations.
>>
>>52873283

Enjoy. Perl is interesting.

You'll want this: http://www.cpan.org/
>>
how do I code a global mouse drag function in unity?
>>
>>52873365
Just put the variabe declaration before the while. Also, you should be using a for loop for this anyway.
>>
>>52873496
the while loop is reading text from a file, and as it was explained to me, a while loop is better here since a for loop is typically meant to be used when you know the number of iterations
>>
>>52873423
Don't listen to this fag.
Learn perl5.
>>
I have a little difficulty understanding this simple pseudocode:
function is_prime(n : integer)
if n ≤ 1
return false
else if n ≤ 3
return true
else if n mod 2 = 0 or n mod 3 = 0
return false
let i ← 5
while i×i ≤ n
if n mod i = 0 or n mod (i + 2) = 0
return false
i ← i + 6
return true

I get pretty much everything except this:
let

what is it, what does it do, where in the tree it sits and what's its equivalent in c++ ?
>>
>>52873436
If you're just starting out, it really doesn't matter what book you use. So long as it isn't geared toward a specific purpose like "Make your own game in 10 hours!" or whatever shenanigans like that.
>>
>>52873517
Literally let i = 5 for the rest of this function
>>
>>52873517
In this instance, it just means
int i = 5;
in a real language let has specific meaning, but in pseudocode, it's just declaring another variable.
>>
>>52873517
>what's its equivalent in c++
int i = 5
>>
>>52873517

let means create i and assign it, but doesn't give you a type annotation.

in C++, this will mean:

int i = 5;


or similar. Could be long, could be long long.. it's up to you.
>>
>>52873517
I think that is the way they say give the variable a number, because saying "set var equal to" is incorrect, because computationally you're GIVING the value the right side of the operator, you're not equating it to anything, so that right arrow means you're storing that value
>>
>>52873454
pls reply.
>>
I have code reading text from a file and one of the strings extracted is either a "Y"/"N" column.

i.e.

String ath = file.hasNext();


Then I have the code check for whether that letter was a "Y" or a "N" and some further qualifications if "Y" is true.

i.e.
if (ath == "Y" && numGrade >= 70)
{
elig = "Y"
} else if (ath == "N" && numGrade <70)
{
elig = "N"
} else
{
elig = "N/A"
}


I have the console printing out what ath ends up being and it is receiving the correct inputs, i.e. it is being designated as either a "Y" or a "N" however, elig is always set to "N/A" regardless of what ath is. Any ideas as to why this happens?
>>
(! (n==0)or(n==5)) is the same as (n! =0)or(n==5) right?
>>
>>52873511
A for loop is for iterating to a list of things, in this case, lines in your text file. It's a textbook case of something you should use a for loop for.

A while loop is for doing something until a particular condition has been satisfied.
>>
>>52873696
the while loop is checking to see whether there are still strings to be output, how is that not correct usage?
>>
>>52873674
You're using ! in differing ways. In the first example it seems as though it's the `not' operator, while in the second it looks like you're trying to use it as a factorial.

Either way, they are not equivalent.
>>
>>52873543
thanks!
so this
    let i ← 5

in c++ would be
i = 5;

and that's it?


>>52873548
>>52873550
>>52873556
oh. this place is quick. thanks guys.

and another thing. that tree is confusing me. shouldn't there be a last else after all (well, both) else ifs? and how does the while loop relate to that tree, if it does at all?

I'll post my lousy translation of that code to c++, how far I get it, in a bit.

captcha: select all images with trees
how appropriate
>>
>>52873737
The for loop is a more specific case of a while loop. Everything that can be done with a for loop can also be done in a while loop, so it's technically not incorrect. But if you want to do it "right", for loops were designed specifically for cases like these. If you are not gooing to use a for loop here, you might as well not use them at all.
>>
Any tips/advice for a beginner programmer?
>>
How would I get the opening question (name) to be in red?
#include <iostream>
#include <cmath>
#include <ctime>
#include <string>
#include <Windows.h>

using namespace std;

int main() {


int num, numrand;
char yn;
string name;
srand(time(NULL));
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
cout << "Welcome and please enter your name: "; cin >> name;
while(true)
{
cout << "Hello " << name << " Do you want to play a game (y/n)"; cin >> yn;
if (yn == 'n' | yn == 'N')
return 0;

while (true)
{
cout << "Computer will imagine one number from 0 to 5 and you guess it: ";
cin >> num;
numrand = rand() % 6; //generate a number from 0 to 5'
if (numrand == num)
cout << "You win!" << endl;
else if (num == -1)
break;
else
cout << "You lose! The computer imagined the number " << numrand << endl;
}

system("pause");
return 0;
}


Should I create a function that I will call to whenever I wanna change the cout to a a random color. How would I go about doing this in C++
>>
>>52873776
Theyre both negating. So The 1st doesnt say 'its not the case that n equals 0'?
>>
>>52873788
>shouldn't there be a last else after all (well, both) else ifs?
A final else would mean you want to do something when n doesn't fit the other cases you're looking for. In this instance, that's not particular useful.
>>
>>52873642
Here you go.
>>
what do you guys use for CI?
>>
>>52873835
what are your interests? software, games, hardware, money, webdev, ...? what do you study?
IMO, if you like hardware stuff, you should learn C AND assembler.
if you want money, learn java/python/some trendy, hipster lang.
>>
>>52873894
The first says "the opposite of whether n is 0 or 5" and the second says "whether or not the opposite of n equals 0 or n equals 5". Notice how the `not' in the second part is applied to n instead of the whole (n==0) bit. The opposite of n doesn't particularly make sense, so it's not really a good idea to put it on a variable that's an integer.
>>
>>52868373
main = fmap sum xs >>= print
where
xs = fmap read getLine >>= \x -> if x == 0 then return [] else fmap (x:) xs


I'm sure someone can make this neater.
>>
I dont understand the point of modules when all of the C++ standard library is templated to hell and back, what difference will it make? and these continuous efforts to get rid of headers, I just dont get it. how are you meant to know what functions to call without headers? are you meant to depend entirely on the intellisense capabilities of the IDE? why are modules meant to be so much better than just using headers?
>>
Any tips or advice for a beginner programmer?
>>
>>52873970
Learning languages with the motivation of making money when you are just starting out is a fools errand. Yes there are a ton of high pay jobs revolving around software development, but it's probably going to take you 5 years of programming or more until you are hireable as a software developer. 5 years from now you will hopefully barely even remember the stuff you were struggling with today, you will have moved on to different languages methodologies. All the stuff you learn in your first year, you could easily learn in a week 5 years from now. So honestly it doesn't matter what you pick to start with, just do whatever you think is fun. Don't worry about what languages you should learn, just program and have fun, then by the time you need to know what you should learn for employability's sake, you will also know how to figure that out yourself.
>>
>>52874217
Don't listen to anything /dpt/ says.
>>
>>52874217
This: >>52874225
And this: >>52874227
>>
>>52874227
I think I'll start doing that.
>>
>>52874265
You've already failed.
>>
File: 2016-02-08 19_49_31-TA YEULE.jpg (53KB, 789x688px) Image search: [Google]
2016-02-08 19_49_31-TA YEULE.jpg
53KB, 789x688px
R8
>>
>>52868660
what's the issue?
>>
>>52873788
>>52873895

surprisingly enough, it compiles and kinda works. it works correctly with numbers up to 28 (I tested each and every). with bigger numbers, however, it seems to give correct result for non-primes but stucks with primes. why?


#include <iostream>

using namespace std;

main()
{
int n;
int i;
cin >> n;


if ( n <= 1 )
return false;
else if ( n <= 3 )
return true;
else if
( ( n % 2 == 0 ) or ( n % 3 == 0 ) )
return false;
i = 5;
while ( ( i * i ) <= n )
if ( ( n % i == 0 ) or ( n % ( i + 2 ) == 0 ) )
return false;
i = i + 6;
return true;

}
>>
Does anyone have a thing where you can practice looking for/fixing bugs?
>>
I've been using several resources (books, videos, article-tutorials) to learn Python and, while I have a good grasp on it... I haven't built a fucking thing.

Anyone have any ideas or a specific list of beginner projects to work with?

I saw some /dpt/ list one day, but some of the challenges on that list seemed too tedious/impractical.
>>
>>52874436
open source software.
>>
File: Z0U3ynq.png (378KB, 1450x1080px) Image search: [Google]
Z0U3ynq.png
378KB, 1450x1080px
>>52874438
Have you made the usual games?

* Guess the number vs AI
* Tic Tac Toe (+ AI)

Here is the list.
>>
how do I code a global drag mouse function on unity?
>>
>>52874469
This isn't the one I found before; much better. Thanks man.

Any other resources appreciated!
>>
>>52867536
just thought I'd point out that it should be this
(are
(lisp brackets)
(unreadable))

also
>haskell
>useful
>python
>not shit
>go
>generics
>>
File: Participant_7.jpg (441KB, 650x657px) Image search: [Google]
Participant_7.jpg
441KB, 650x657px
I just changed the datatype from bigint to int in a table with 10M rows
did I fuck up
will this ever finish
>>
what should be your expectations if you are joining the workforce at 30, have some basic engineering/informatics education but no degree, and have learned lots of languages?
>>
>>52874636

The same as anybody else and any position.

Anger, disappointment, resentment, early death.
>>
>>52874703
about right
>>
>>52874703
well, that's implicit when you are a wage slave, no?
I meant, other than that, should I expect to be looked down? I've read that employers don't hire "old" (>30) programmers because they think you probably can't learn the latest trendy stuff, is this true?
>>
>>52874739
how good is your portfolio+github?
>>
>>52874773

Say a lot of buzzwords and you're good. If it's something like C or C++, say you prefer the latest standard.
>>
>>52874634
CTRL+C
>>
>>52874823
Do you have a list of trendy programming buzzwords?
>>
>>52874813

I have a few of >>52874469 's projects done and a couple commits/bug fixes to OSS, nothing fancy.
>>
>>52874469
roll
>>
new thread when
>>
>>52874636
I dunno
>>
>>52874813
Do you actually give a prospective employee a link to your github?
I have a few major projects that I'm proud of (and a couple of forks to fix dead projects), nothing star'd, but it's all commented and documented and shit. I'd like to show them, since it shows what languages I've actually got experience in
>>
>>52874850
'concurrency'
'integrated'
'modularity'
'parallelism'
'versatility'
'the cloud'
'paradigms'
'architecture'
'systems'

A few of those have got me hired before, and parallelism got me laid
basically just combine them
'I develop modular architectures based on concurrent paradigms to integrate the cloud into versatile systems'
>>
>>52874979
I dunno, at least it shows you have experience coding and can work in a team.
>>
File: 132.gif (2MB, 300x225px) Image search: [Google]
132.gif
2MB, 300x225px
>>52874986
>>
>>52874986
>'I develop modular architectures based on concurrent paradigms to integrate the cloud into versatile systems'

Why doesn't a programmer's version of this http://art-words.net/ exist? The world sure needs one.
>>
>>52874979
It depends on the company you're applying for. Enterprise will likely not give a flying fuck.

My Github/code samples were requested for a small company (2 devs 1 CEO) and it helped me nail the job down and get it.
>>
>>52875011
Also I forgot to mention that you can multiply the effect by adding 'computing' or '-based computing' after almost every word
concurrent computing
integrated computing
modular computing
etc
>>52875040
might write one desu
we could have our own sokal
>>
File: r4v2E__12214_zoom[1].jpg (40KB, 300x300px) Image search: [Google]
r4v2E__12214_zoom[1].jpg
40KB, 300x300px
Just ordered one of these bad boys. Gonna have a crack at programming for it.
>>
>>52874418
looks the cause was that the poor
    i = i + 6;

needed to be tucked inside the while loop.

is this legit now? seems to work to me.
or is there still something missing or wrong?

#include <iostream>

using namespace std;

main()
{
int n;
int i;
cin >> n;


if ( n <= 1 )
return false;
else if ( n <= 3 )
return true;
else if
( ( n % 2 == 0 ) or ( n % 3 == 0 ) )
return false;
i = 5;
while ( ( i * i ) <= n )
{
if ( ( n % i == 0 ) or ( n % ( i + 2 ) == 0 ) )
return false;
i = i + 6;
}
return true;
}

>>
new thread
>>52875250
>>52875250
>>52875250
>>52875250
>>
>>52874986
>parallelism got me laid
WTF, please tell us.
>>
>>52875691
it's a joke bro
nothing gets me laid
Thread posts: 345
Thread images: 36


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