[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: 349
Thread images: 43

File: prog.jpg (113KB, 473x496px) Image search: [Google]
prog.jpg
113KB, 473x496px
What are you working on, /g/?
Old: >>52476540
>>
Fixing Unix, check it out here
https://github.com/torvalds/linux
>>
Rewriting Gentoo in OCaml.
>>
File: NOT_ANIME.png (59KB, 1232x804px) Image search: [Google]
NOT_ANIME.png
59KB, 1232x804px
Reminder
>>
>>52481167
Yaoi's not a bad board, you should try it sometime.
>>
Pony-related vidya
>>
>>52481217
this
>>
haskell is a failure
>>
>>52481339
Just like your life
>>
File: oh-snap.jpg (187KB, 375x500px) Image search: [Google]
oh-snap.jpg
187KB, 375x500px
>>52481360
>>
what do you guys do when you aren't bent over a computer keyboard?
>>
>>52481449
not an awful lot
>>
>>52481449
sleep
piss
shit
>>
File: fuck off newfag.png (343KB, 1760x1760px) Image search: [Google]
fuck off newfag.png
343KB, 1760x1760px
>>52481167
Fuck off back to where you came from
>>
/* Text scroller. Designed for 80x24 terminals that support color. */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

// x, starts at 4
int x = 4;

int main()
{
// DO NOT REMOVE!
// disable buffers so that we can have immediate printing
setbuf(stdout, NULL);

// loop variable
int l;

// main text box loop occurs here
// TEMPORARY: change the # in the for statement
// to change how many times it scrolls.
for (l = 0; l < 100; l++)
{
loopblock();
// set delay; this will work since we disabled buffers!
usleep(200 * 1000);
}
return(0);
}
int loopblock()
{
printf("\r%*s", x, "Hell");
x++;
}

I got the text scrolling now I need help actually wrapping it around one single line in the terminal

It just goes off the screen border in a glitchy kind of way right now
>>
>>52481449

I spent 80% of my waking hours in front of a screen. When I am walking between classes, or sitting on the bus, I have my phone out. When I am at home, I am typically on my laptop.

I am rarely "bent over" a keyboard, however. I like to do a lot of my computing laying down in my bed. Programming while horizontal is good shit.
>>
>>52481534
it prints "Hell" over and over again?
>>
>>52481572
It scrolls the text "Hell"

yes
>>
>>52481534

1. Use code tags next time.
2. Use ncurses, if possible. Your code is not portable to Windows, but with ncurses, it could be. It would also run on OS/2.
>>
Do you guys watch porn with your sister?
>>
>>52481652
>ncurses
I puked a little.
>>
>>52481667
I did with my cousin once
>>
>>52481667
No, I either watch porn of my sister or I make porn with my sister.
>>
>>52481501
Most anti-anime fags are hating anime just for replies and to piss you off. The only way to get rid of them is to pretend they don't exist.
>>
>>52481449
Watching animu
>>
who wants to team up and make a game
>>
>>52481449
watching anime, playing retro vidya (I bought ocarina of time for my N64 this morning), and 4chan.
>>
What are some tips for staying up and not feel sleepy?
I'm extremely tired right now and going to bed would probably like heaven, but I need some shit done and I can't go to sleep yet.
>>
>>52481734
I'll make the logo
>>
>>52481734
i'll think of the title
>>
>>52481734
let's make a game about animu girls that fight for free software.
>>
How do I make my code more masculine, /dpt/?
>>
>>52481769
Write it in ocaml.
>>
>>52481652
Do you actually believe he should convert what appears to be babby's second C program to use ncurses?
>>
>>52481769
Write procedural code. The computer is your bitch. You must command it to obey you. Procedural code is the only way. OOP and FP are feminism embodied.
>>
>>52481734
What kind of game?
>>
>>52481815
rpg
>>
>>52481810
>you should do the job of the computer in its place like a bitch
>that's manly!
>unlike commanding the computer and letting it do all the work
>that's womanly
t. cmen
>>
>>52481801

If he wants to start doing color text and other various non-standard terminal tricks, then yes. Besides, ncurses isn't that hard to use, and every C programmer has to learn how the hell to use a 3rd party library someday anyways.
>>
>>52481815
A roguelike but it's not a roguelike and also all other roguelikes are grinding games or sidescrollers and please donate to me i make best game in world please

Or so he said last thread.
>>
>>52481837
It's not that hard to use if you don't mind every other action crashing the program with a segfault and being forced to trial-and-error how to setup the parameters for functions because the documentation is dogshit.
>>
>>52481845
i never said that
>>
>>52481796
Like this:
#define _3(x) {
#define _8(x) }

#include <stdio.h>

int main()
_3(=====|)

puts("Hello world!");

_8(=====|)
>>
>>52481845
also what last thread?
>>
>>52481888
Damn, replied to the wrong post: >>52481769
>>
>>52481829
Oh sorry, I thought you were that anon from the previous thread and I was trying to bait. (See also: >>52481845)

I don't actually have time to join a team (got a large project of my own to work on right now), but what sort of RPG are you planning to make?
>>
>>52481764
>>52481829
>>52481845

sounds good i'm in
>>
Why can't I create, /g/?

I've never been able to make something original in my life. Whenever someone has asked me to make them a program that does X, I've always been able to do it, but the problem I have is I can't make my own goals. I always have to be given an idea by someone else.

I'm like this with everything, I can draw a picture if someone else comes up with a rough sketch for it, but I can't make the initial idea up on my own. I can write a paper if someone gives me a topic, but I can't make up my own topics. I can program anything I want, as long as someone else tells me what to program. No matter how much I try or want to, I can't come up with a single original idea on my own.

Am I broken? Does someone know how to fix it?
>>
>>52481915
lol kill yourself you just got counter-baited haha roflmao xd
>>
>>52481939
You're creative spirit has been destroyed by the public school system, same as everyone else.
>>
>>52481951
Yeah I realized about 30 seconds after I posted that I was probably a fucking dumbass. I took >>52481873 to be the same anon as >>52481829, confused about why people were assuming he was making a roguelike.
>>
File: 1435885287781.jpg (49KB, 640x480px) Image search: [Google]
1435885287781.jpg
49KB, 640x480px
>>52481939
>I have lots of ideas
>They would all be shitloads of work
>Can't be fucked with such a huge undertaking
>All of my ideas are worthless now
>>
>>52481939
Autism, seriously
>>
>>52481810
what's the difference between procedural and oop?

does it just mean you don't use functions?

sorry for being retarded, i'm just a silly girl.
>>
>>52481983
Post tits or gtfo
>>
>>52481963
>dmg+ctrl
>>
>>52481983
codrrr grrrrlllllllll

post tits and learn proper practices faggot
>>
>>52481939
Try LSD or shrooms.
Or just think of something in your life that you could make better with a certain program. Like, how can you improve your life right now?
>>
>>52481993
>>52482004
please answer my question, anons.

what's the difference between procedural and oop?
>>
>>52481999
>literally admit in my own post that i was a dumbass and completely misinterpreted what was going on in the thread
>"lol damage control"
???
>>
>>52481962
Not everybody, apparently, my girlfriend can create I have friends that can create, I just seem to lack the ability

>>52481978
How do you get them? Where do they come from? How can I get some for myself?

>>52481982
I'm not going to deny the possibility, but if I am it's really minor. Is complete lack of creativity a symptom?

>>52482010
>just think of something in your life that you could make better with a certain program.

I feel like this is a little bit different from the creativity I'm talking about. I've made programs for myself before, but what causes it is me thinking "fuck, I'm not going to do this all by hand" and I feel like that is different from real creativity.

>Try LSD or shrooms.
I've tried two tabs of LSD, but it must have been some weak shit, because I barely felt it
>>
>>52481999
Some people are actually capable of admitting they were wrong, you know.
>>
https://www.youtube.com/watch?v=LS37SNYjg8w
>>
>>52481167
But anon you've got LGBT, Pony, Random, and S4S listed in columns.
>>
>>52482054
both columns*
>>
>>52482054
>>52482065
Is that a complete intersection there? Why did you go through all of them to find that? Why don't you just ignore shitposts?
>>
>>52482090
Because muh autism.
>>
>>52482040
>How do you get them?
It's mostly stuff that I want. "I wish I had a program that does this" or "I want a program which uses this new technology".
>Where do they come from?
Most of my idea comes when I'm taking a shower. I'll usually spend ages in there, just thinking about shit.
>>
>>52482040
Real creativity is coming up with a unique solution to a problem. So if you've made programs for yourself that's already creativity.

Think of something that'll help other people or that they'll find useful. It doesn't have to be something huge like Facebook, but when you start getting ideas more ideas will come to you.
>>
Why aren't you using docopt, /dpt/?
http://docopt.org
>>
>>52482025
If your tits are good enough maybe I'll tell you, grill!
>>
>>52482189
Because Command is better and comes with the standard library.
>>
are there any app devs here looking for freelance work?
>>
>>52482201
456
>>
>>52482233
Me.
>>
File: CS wow.png (2MB, 942x743px) Image search: [Google]
CS wow.png
2MB, 942x743px
Can /g/ do /sci/'s hw?

>>>/sci/7788752
>>In C++
>1. Declare a 10 integer array called fluffy.
>2. Declare a pointer to the 3rd element in fluffy.
>3. Create a for loop that prints each odd number between 27 and 63.
>4. Declare a filestream object for reading a file "data.txt"
>
>Afterwards, professor asks who thought to themselves "What did I get myself into?", only people raising their hand are the 6-7 somewhat attractive girls in the class.

/sci/'s solution:
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>

int main(){
using std cout;
using std endl;
using std fstream;
using std string;

//1
int * fluffy= nullptr;
fluffy= (int*) realloc ((void*) fluffy, 10*sizeof(int));

//2
int * fluffy3 = fluffy;
for(int i=1; i<3; ++i)
++fluffy3;

//3
for(int j=0; j<100; ++j){
if(j>26 && j<64){
if(j&1)
cout<<j<<endl;
}
}

//4
string file("data.txt");
fstream obj(file.c_str());

return 0;
}
>>
>>52481810
>getting cucked by the compiler and assembler
>not writing in machine code
>>
>>52482258
are you
>>
>>52481535
Can you draw a diagram? I don't see how that'd be comfortable at all.
>>
>>52482197
Cringe.

You sound like a teenager overexcited to be potentially talking to a girl on the internet.
>>
>>52482270
top kek you're lying
>>
File: IMG_20151209_230220.jpg (35KB, 469x527px) Image search: [Google]
IMG_20151209_230220.jpg
35KB, 469x527px
>>52482270
Can't wake up
>>
File: carson jeb wake me up trump.jpg (199KB, 1240x299px) Image search: [Google]
carson jeb wake me up trump.jpg
199KB, 1240x299px
>>52482347
WAKE ME UP
>>
>>52482333
If you're not gonna post'em, get the fuck out bitch!
>>
>>52481449

6AM gym
9 - 5 work
6 - 8 study / build personal apps
8 - 10 prep for next day / chill with fiancee

I spend a lot of time in front of the computer to help prepare my future for my soon-to-be wife and me. We want kids and a crib in the country somewhere, so we're willing to bust our butts to get it.

>tfw video games aren't fun anymore
>tfw building apps that have little to do with games are the most fun

I have a couple ideas I'm fleshing out and I couldn't be more pleased. Venture capitalism is something I'm really interested in so we'll see where my builds can lead me.
>>
>>52481830
>implying procedural means low-level
Schools have been shilling for FP since the 70's so they don't teach much anymore. The quality of education suffers as a result.
>>
>>52482375
As evident by the likes of you.
>>
dubs test
>>
>>52482295
>getting cucked by actual code
>not writing in mix
>>
>>52482401
REEEEEE
>>
>>52482270
>>Afterwards, professor asks who thought to themselves "What did I get myself into?", only people raising their hand are the 6-7 somewhat attractive girls in the class.

I found that the further I get into the CS program, the women are less attractive, crazier, and fewer in number.

Too spooky.
>>
>>52482419
This 5
>>
File: 1452124326364.jpg (137KB, 917x871px) Image search: [Google]
1452124326364.jpg
137KB, 917x871px
Do you think men's brains are just better at thinking logically than 3D women's brains?
>>
>>52482270
Why not
int * fluffy3 = fluffy + 3;

>>52482424
That's just how this shit goes
>>
File: 1441439560294.jpg (80KB, 500x500px) Image search: [Google]
1441439560294.jpg
80KB, 500x500px
>>52482270
Retard reporting in.
#include <stdio.h>

int main(void)
{
// 1
int fluffy[10] = { 0 };

// 2
int *fluff3p = &fluffy[2];

// 3
unsigned int i;
for (i = 28; i < 63; ++i) {
if (i % 2 == 0)
continue;
else
printf("%d ", i);
}

// idk how to do 4
}
>>
>>52482447

Yes. Men have more idiots than women, but also more geniuses.

Women's standard deviation is closer to the mean.
>>
>>52482460
wrong. even the stupidest man is atleast as smart as the smartest woman
>>
>>52482475
Only if you limit the selection of men to the top 10% as most people do.
>>
>>52482475

Oh, you're right. My mistake. Damn, I feel like the smartest woman in the world right now.
>>
>>52482487
If you're so smart why haven't you posted your tits yet?
>>
>>52482318
Yes, that's correct.
>>
>>52482475
Don't be stupid, anon.

Men on average are smarter than women, but some men are more stupid than the average woman (see mirror).
>>
>>52481939
start with something unoriginal and make it original, think of ways you can make something better or more efficient.

Here are some ideas to get started:
https://github.com/karan/Projects
>>
>>52482501
post your email. i might have a job for you
>>
>>52482040
Why not pick a creative hobby, learn how to paint or learn how to play an instrument
>>
>>52482270
fucking retarded solution

even if you knew this little about programming you should be able to do better

>>52482424
>women suck at programming
this is new
>>
File: 1452190950134.jpg (30KB, 272x350px) Image search: [Google]
1452190950134.jpg
30KB, 272x350px
What's it called when people pretend to be retarded just to make a position they disagree with look bad?
>>
>>52482521
[email protected]

Contact me through there until I know you're not going to sign me up to a bunch of gay porn.
>>
>>52482562
Falseflagging.
>>
>>52482475
some men are really fucking dumb

almost all women are more or less average

the majority of men are average (still smarter than the average woman when it come to logical reasoning), some are really smart and some are really dumb
>>
File: animeface.png (3KB, 800x600px) Image search: [Google]
animeface.png
3KB, 800x600px
>>52482562
a strawman
>>
Anyone have any tips for making shit actually stick when I'm trying to learn it?

I've been reading through the online version of Automate the Boring Stuff with Python and while I'm working through a chapter I feel like I'm totally getting it, but then the second I move down to the questions and practice projects I draw total blanks outside of the incredibly basic stuff.

I've tried re-reading, taking notes even, and all that but it just doesn't seem to work.
>>
>>52482578
nice bait
>>
So, guys, I understand that a computer stores a floating point number basically as scientific notation in the form of binary using the formula m b^e.

But how is the decimal number calculated from the binary number you're left with? Is it some algorithm? Actually, I guess it would be the reverse of what you did to get to that in the first place, wouldn't it.

Where can I see this algorithm? Or is it some really low-level logic gate wizardry that I could never comprehend?
>>
File: Screenshot (20).png (528KB, 1920x1080px) Image search: [Google]
Screenshot (20).png
528KB, 1920x1080px
>>52482590
Not bait. It's my actual secondary email.
>>
>>52482270

That should absolute be the next /dpt image.
Fuck that loli shit.
>>
>>52482552

It's not that women are inherently bad at programming, it's that the women that are actually interested in programming are scary and crazy.
>>
>>52482589
you must actually write code
>>
>>52481939
it's all in your head
>>
What's the metric by which a programming language is deemed low or high level? Is it how closely it lets you interact with memory?
>>
>>52482270
Rate:
use std::fs::OpenOptions;

fn main() {
let fluffy: [i32; 10] = [0; 10];
let _ptr = &fluffy[2];

for n in (27..64).filter(|n| n % 2 != 0) {
println!("{}", n);
}

let _file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.open("data.txt");
}
>>
>>52482640
1/4, failed all but the first task.
>>
>>52482639
Kind of.
It's based off of how obfuscated it is from binary code. Machine language uses mnemonics which have a one-to-one relationship with binary so it's considered to be the lowest level code that is viable for programming.
>>
>>52482603
Go through the IEEE 754 spec for floating point numbers. It specifies the format for storing and retrieving the number. The algorithm is implemented in hardware to allow it to be encoded in constant time AFAIK.
>>
>>52482671
Meant to say assembly instead of machine language. Machine language IS binary, sorry.
>>
>>52482457
>if (i % 2 == 0)
> continue;
>>
File: dd.jpg (24KB, 300x250px) Image search: [Google]
dd.jpg
24KB, 300x250px
>tfw i got into an argument on reddit

hold me, /dpt/
>>
File: 1406803019377.jpg (103KB, 1280x720px) Image search: [Google]
1406803019377.jpg
103KB, 1280x720px
>>52482719
I think you should kill yourself
>>
>>52482639
Just general terms. It's to do with abstraction, and how close you are to what the computer's actually doing.

A list of programming languages ranging from very low to very high level:

Machine Code could be considered the lowest level programming language.

Assembly language is at the level of telling the processor what to do. There is still a conversion step towards machine code.

C is a step up from assembler, because you get to specify what you want to do in slightly more abstract terms, but you're still fairly close to the metal.

Java/C# do similar things to C++ in a way, but without the opportunity to do everything you can do in C (like pointer manipulation in Java's case [thanks Joe!]). They have garbage collection though, which you have to do manually in C++.

SQL is even higher level (it's declarative). Just say "Give me all the items in the table sorted by age" and it will work out the most efficient way to carry this out for you.
>>
>>52482719
post thread
>>
>>52482719
>>>/reddit/
Or kill yourself.
>>
>>52481667
If I had a sister and she asked, I think I would. I'm not much of a fan of lewd things, though. Lewd things with my sister, though? Of course I would make an exception.
>>
>>52482612
>2612â–¶
>>>52482589


This.

Make something.

You'll find books and documentation are absolutely essential to do this. Hopefully, what happens, is that you think about the problems you run into while designing and making your program, and recall the documentation and academic shit.
>>
Any bored hackers out there? I need your help please
>>
>>52482590
Do you want my help or not?
>>
>>52482746
shoot
>>
>>52482746
I hacked ur mum last nite lol
>>
File: dfg.jpg (104KB, 1280x720px) Image search: [Google]
dfg.jpg
104KB, 1280x720px
It triggers my autism that there isn't a known pattern with prime numbers.

Please find a way, /dpt/. I've tried everything.
>>
>>52482691
thank you!
>>
>>52482746
Me.
This is me>>52482604

Contact me on that email.
>>
File: m'hacker.jpg (48KB, 469x463px) Image search: [Google]
m'hacker.jpg
48KB, 469x463px
>>52482746
This is guy fawkes. What do you need, friend?
>>
>>52482767
But there is:
https://en.wikipedia.org/wiki/Ulam_spiral
>>
>>52482767
Here's the pattern: they all are only divisible by one and itself.
>>
>>52482774
So you can help me?
>>
>>52482746
Yeah, just input AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA into the program and hope something works
>>
*sighs* It's something stupid but, there's an iFunny username I want, since that person is very unactive I wanted someone to help me out
>>
>>52482792
Yes. Depending on how much you're willing to pay
>>
>>52482786
>>52482789
I mean, for example, I should be able to work out what the 4824th prime is on a calculator in less than 5 seconds.
>>
>>52482833
I'm in. Check your mailbox tomorrow for a letter from "Anon-sama".
>>
>>52482851
XD aww shit, I forgot about that
>>
>>52482405
>getting cucked by writing
>not buying a shitload of electronic logic gates and wiring them yourself
>>
>>52482833
I'm guessing you want money right? I don't know how to repay
>>
Alright, I'll be upfront about it
It's not actually an iFunny username I want, but a Furaffinity username >.>
>>
>>52482767
Just make an iterator that returns numbers divisible by itself and 1. Access that number by referencing the index that it's at.
>>
>>52482861
Wha?! How XD
To be honest I'm just a newfag
>>
>>52482889
Hey! XD not a furry
>>
>>52482907
I launched a MS-DOS attack on furaffinity's mainframe. I got the user and pass. Send a bitcoin to the wallet I'll email you tomorrow to your live account and I'll send them.
>>
>>52482449
>using unnamed constants
>>
If I make a kik chat, will you join in to help me out?
>>
>>52482851
but anon, its already instantaneous:
Prelude> import Data.Numbers.Primes
Prelude Data.Numbers.Primes> primes !! 4824
46687
>>
>>52482640
What functional language is this so that I know not to actively avoid it?

The syntax is OK.
>>
File: ih.png (337KB, 554x720px) Image search: [Google]
ih.png
337KB, 554x720px
>>52482901
I know how to generate primes, anon.

I just think it would be neat if there were a way to tell if a number is prime without checking if it is divisible by previous numbers.
>>
>>52482956
that loops OOP to me
>>
>>52482971
Maybe you could figure it out if you weren't a disgrace to your parent's genetic make-up and had your brain rot by Japanese cartoons for infants.
>>
So no one will help me out? ._.
>>
>>52482978
Apparently it's Rust. How terrible. Oh well.

What got me though is that it reminded me of C#.
Like, a lot.
>>
>>52482955
>Prelude> import Data.Numbers.Primes

><no location info>:
> Could not find module ‘Data.Numbers.Primes’
> It is not a module in the current program, or in any known package.
>>
>>52483043
cabal install primes
>>
File: Screenshot_2016-01-17-21-23-28.png (319KB, 1440x2560px) Image search: [Google]
Screenshot_2016-01-17-21-23-28.png
319KB, 1440x2560px
>>52482971
Maybe you could make use of this
>>
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47...


What's the pattern, /dpt/?

How do I work out the billionth number in this pattern?
>>
>>52483093
>false positives are possible
Into the bin it goes.
>>
>>52482270
int* realloc void*

bruh
>>
>>52483104
odd numbers
the answer is 500,000,001
>>
>>52483104
the numbers are the zeros to the function
y = (x - 2) * (x - 3) * (x - 5) * (x - 7) * (x - 11) * (x - 13) * (x - 17) * (x - 19) * (x - 23) * (x - 29) * (x - 31) * (x - 37) * (x - 41) * (x - 43) * (x - 47)
There are no other numbers in the series.
>>
>>52482712
What's the problem senpai?
>>
>>52483119
If you're trying to find the billionth number of the pattern then generate prime numbers until i.length = 1 billion.
If you're testing to see if the number is prime or not then do what the picture tells you. You're almost never going to get a false positive.
>>
>>52483104
EZ just prove the Riemann hypothesis
>>
>>52483154
Where's 15 anon? What's 2 doing there?
>>
>>52482270
It's amazing how bad this is.
>>
>>52483104
they're primes you dip
>>
>>52483244
And why isn't there a pattern?
>>
>>52483260
Holy fuck
>>
File: Ulam_1.png (12KB, 400x400px) Image search: [Google]
Ulam_1.png
12KB, 400x400px
>>52482786
Yaw 'avin' me on incha?
>>
Does anyone know what the software used to analyze .exe file is called? I remember using it a while back, but I forget the name. It starts with an "O".
>>
>>52483272
Does that mean, "I don't know"?
>>
hayy lmao

int cunt,fu=0;
cin >> cunt;
cout << "\nDivisible by: \n";
for(int i=2; i<cunt; i++){
if(cunt%i == 0){
fu=1;
cout << i << endl;
}
}
cout <<'\n';
if(fu==1){
cout<<"number is not prime\n";
} else {
cout<<"number is prime\n";
}
return 0;
>>
>>52482786
Just looks like random dots tbqh.
>>
>>52483314
Of course I don't know. It's one of the open questions in mathematics for fucks sake. Go on mathoverflow anon
>>
$ cat o.nim 
proc test(n): auto =
if n == 0:
return 0
else:
return 1
echo test(9)
$ nim c o.nim
Hint: system [Processing]
Hint: o [Processing]
o.nim(1, 11) Warning: '(n): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
CC: o
Hint: [Link]
Hint: operation successful (9859 lines compiled; 0.131 sec total; 14.148MB; Debug Build) [SuccessX]
$ ./o
1
$ cat s.nim
proc test(n): auto =
if n == 0:
return 0
else:
return "fuck"
echo test(9)
$ nim c s.nim
Hint: system [Processing]
Hint: s [Processing]
s.nim(1, 11) Warning: '(n): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
s.nim(6, 10) template/generic instantiation from here
s.nim(5, 12) Error: type mismatch: got (string) but expected 'int literal(0)'
$

what is this
Can I not mix return types?
>>52483296
OllyDBG? Ida?
>>
File: 1432474561840.jpg (150KB, 450x640px) Image search: [Google]
1432474561840.jpg
150KB, 450x640px
Hello, im wanna get into programming.What are some beginner languages you could recommend?
pic unrelated
>>
File: nj.png (1MB, 700x992px) Image search: [Google]
nj.png
1MB, 700x992px
>>52483345
No need to be so upset, anon.
>>
>>52483363
http://www.htdp.org/2003-09-26/Book/
>>
>>52483363
C++, C, and assembly

fuck all the other babby languages. Learn from the best first.
>>
>>52483387
ok ill give it a read.
>>
>>52483363
Learn C
get a good book with a lot of examples
type out all of the examples yourself or you won't learn anything
>>
>>52483396
>C++
>best
>>
File: 1450681384030.gif (549KB, 720x534px) Image search: [Google]
1450681384030.gif
549KB, 720x534px
>>52483382
I'm not upset, just suprised someone one doesn't know there's no known pattern for primes.

I AM upset your animu isn't a smug loli. Fix this
>>
>>52483363
Hello, friend. I will recommend you a language based on a personality test:

>Why do you want to get into programing?
>Do you have autism?
>Any projects in mind?
>Windows or Unix?
>cheeky or verbose?
>Do you do drugs?
>>
File: 1432860473789.png (40KB, 335x342px) Image search: [Google]
1432860473789.png
40KB, 335x342px
>>52483396
>C++
>>
File: altf4_keyboard.jpg (67KB, 403x142px) Image search: [Google]
altf4_keyboard.jpg
67KB, 403x142px
>>52483419
>>
>>52483396
Fuck this kid, do NOT learn C++ first, or your whole experience will be figuring out its indecipherable bullshit rather than learning how your code actually works
leave learning C++ to when you absolutely have to (if you're planning on programming for a career you will have to)
>>
>>52483490
>indecipherable

want to recommend a language that is more "decipherable"?
>>
File: 1452446496816.png (616KB, 895x892px) Image search: [Google]
1452446496816.png
616KB, 895x892px
>>52483430
I think smug anime girls are rude.

I don't like to be rude.

And I know there isn't a known pattern, I even said so in my first post: >>52482767
>>
>>52483514
bythn :DDDDd
>>
>>52483514
C is the obvious one

it doesn't have some of the features C++ has, obviously, but you almost certainly won't need those features until you have to learn C++ anyway
>>
>>52481088
jesus, almost gave me a boner there
>>
>>52483559
So... C is more decipherable than C++... even though C++ is backwards compatible ...
>>
File: 1451611925138.jpg (226KB, 600x960px) Image search: [Google]
1451611925138.jpg
226KB, 600x960px
>>52483520
My lolis can bully your lolis
>>
File: fZQOg8v.gif (2MB, 400x595px) Image search: [Google]
fZQOg8v.gif
2MB, 400x595px
>>52483592
How about now
>>
>>52483599
>C++ is backwards compatible
Not completely
>>
>>52483599
Yes

What are you trying to say with all those ellipses you're throwing around?
>>
File: wq.png (188KB, 500x476px) Image search: [Google]
wq.png
188KB, 500x476px
>>52483602
Your lolis are brown and therefore have more testosterone.

Bullying isn't a nice trait for lolis to have anyways, my lolis are superior because they never bully.
>>
>>52481939
People don't usually code just for the hell of it. It's a solution to a problem. If you don't have any "problems" you won't need to write anything. Just think about something that could be done easier, quicker, more efficiently with code. Draw up a plan or specific set of requirements if you have problems keeping it in your head, then implement. Maybe a change of languages will motivate you. I noticed I wanted to write more when I started implementing things in python instead of C or bash. I've written a script to go from a command line Debian install to a full desktop, a script that updates maps based on deltas to save bandwidth and time, and currently working on a programmable rpn calculator. Those are just some of the things I've written out of my own necessity. At some point you will find something you want and do it.
>>
>>52483609
>3D
I mean, sure, it would beat masturbation, but I'd still be thinking of 2D girls.
>>
>>52482727
Late versions of c++ have garbage collection that you can use. Not exactly the same way as Java, but it's something.
>>
>>52483631
Trying to be condescending I guess, but seriously I agree. Learning it in the order of C then C++ makes a lot of sense.
>>
File: 1449201110198.png (217KB, 531x705px) Image search: [Google]
1449201110198.png
217KB, 531x705px
>>52483705
Only the superior can bully anon. Only inferior lolis get bullied. It's a doggy dog world anon
>>
>>52483823
*dog eat dog
>>
>>52483431
ok
>because I like computers and want to learn more
>not that i know of
>not yet i just wanna learn it as a hobby
>w-windows
>verbose I guess
>no
>>
>>52483741
Not him, but I would really like a program that read a book for me and distilled the essentials of it. Kids are too fucking wordy with their writing these days,
>>
>>52483599
>C++ is backwards compatible
int array[n];
>>
>>52483839
People like you are a diamond dozen. You just can't tako or leaf it, it's always Busy Ness when you're round.
>>
File: 1452322895006.png (70KB, 300x468px) Image search: [Google]
1452322895006.png
70KB, 300x468px
>>52483826
>>52483874
You deleted your post because you forgot ">" at the beginning of your quote?

Kek.
>>
>>52483909
Meme arrows are important
>>
File: 1404852528863.png (1001KB, 2000x3112px) Image search: [Google]
1404852528863.png
1001KB, 2000x3112px
Hey /dpt/.

This is not exactly a programming question, but I would appreciate you guys' input on this.

I am working on an assignment for a CS course, and the professor provided the following line of pseudocode as part of a larger algorithm:

for i = 1 to n print("x");


My question is this:
When the line says "1 to n", would you interpret it as "1 to n INCLUSIVE" or "1 to n EXCLUSIVE"?
For example, if n were to be 2, would the output be "x" or "xx"?

I would ask the professor on this, but it is Sunday and I have no friends in the class to ask either.

What do you guys think?
>>
>>52483878
I am sorry to be the baron of bad news, but you seem buttered, so allow me to play doubles advocate here for a moment. For all intensive purposes I think you are wrong. In an age where false morals are a diamond dozen, true virtues are a blessing in the skies, and are more than just ice king on the cake. We often put our false morality on a petal stool like a bunch of pre-Madonnas, but you all seem to be taking something very valuable for granite.

So I ask of you to mustard up all the strength you can because it is a doggy dog world out there. Although there is some merit to what you are saying it seems like you have a huge ship on your shoulder. In your argument you seem to throw everything in but the kids Nsync, and even though you are having a feel day with this I am here to bring you back into reality.

I have a sick sense when it comes to these types of things. It is almost spooky, because I cannot turn a blonde eye to these glaring flaws in your rhetoric. I have zero taller ants when it comes to people spouting out hate in the name of moral righteousness. You just need to remember what comes around is all around, and when supply and command fails you will be the first to go.

Make my words, when you get down to brass stacks it doesn't take rocket appliances to get two birds stoned at once. It's clear who makes the pants in this relationship, and sometimes you just have to swallow your prize and accept the fax, instead of making a half-harded effort. You might have to come to this conclusion through denial and error but I swear on my mother's mating name that when you put the petal to the medal you will pass with flying carpets like it's a peach of cake.
>>
>>52483944
Try the algorithm with both?
>>
>>52483944
To go from 1 to 2 requires 1 step, therefore I would say "x"
>>
>>52483957
>everything in but the kids Nsync
> rocket appliances
my sides
>>
>>52483841
>C# - because you are on windows
C# is a a great language that is amazing on windows (but less portable than m$ would like to you to think). It's high level, so you wont be learning as much about how computers really work. C# has loads of libraries that can figure out dates, search through text, etc. In essence, it babies you more than C.
>C - because you wanted to learn about computers
C is "close to the metal" in that you're literally ordering the CPU to allocate memory and operate on it. You'll learn about how the computer really works. As a language it is simple, which is great. The toolkit is very small as well - all you need is a compiler and a text editor. C will perform much better than C#, but you'll miss out on all of the cool libs of C#.
>>
>>52483944
most likely inclusive, but email your prof because /dpt/ cant read his mind. be sure to include an anime avatar image so he knows its you.
>>
File: image.png (66KB, 1323x664px) Image search: [Google]
image.png
66KB, 1323x664px
>>52483999
The assignment isn't about running the algorithm, sorry for not being clear.

I have to make an equation that evaluates to the number of times that "x" is printed out for any given value of n, and prove that this is the case.

Whether or not that line is supposed to be inclusive or exclusive would have an impact on the final result, and I'm not sure which one to go with.

Pic related, it's the problem
>>
>>52484061
>be sure to include an anime avatar image so he knows its you
good idea thanks
>>
>>52484069
1 to n usually implies [1,n]. Starting at zero implies [0, n).
>>
File: 1449878616110.jpg (408KB, 1024x720px) Image search: [Google]
1449878616110.jpg
408KB, 1024x720px
>>52484061
>>52483944
I got you senpai
>>
is anyone having a problem where 4chan threads load extremely slowly?

>open gif from local storage
>gif doesn't play
>close gif
>gjewgle chrome totally chimps out
>spend hours saving incognito shit (didn't want to use session buddy because i knew i wouldn't open it again but i resorted to it for the last 2 windows)
>restart google chrome
>all other websites load fine but 4chan threads still load extremely slowly like a batch of posts at a time instead of everything at once
>>
>>52484093
Well, that's news to me

Thanks for the clarification, I'll go with inclusive for the assignment but still email the prof before its due
>>
HEY MOOTWO

GIVE US /PROG/ BACK
>>
>>52484122
It was slow as shit, anon.
>>
>>52484033
ok I will thank you
>>
>>52483233
What's wrong with it? It works doesn't it
>>
>>52484171
It was faster than /po/
>>
>>52483957
>baron of bad news
>>
https://www.youtube.com/watch?v=Zi0RpNSELas

We are the world, /dpt/
>>
Trying some cross platform networking in C. Is Winsock as bad as the rest of the Windows API? Should I use Cygwin instead?
>>
>>52484265
>cross platform
>Windows API

what
>>
>>52484104
seems like it's something with javascript because i disabled it and now 4chan loads fine too

but it's extremely uncomfortable to post with javascript off so what the fuck can i do
>>
>>52484314
I'm obviously using POSIX sockets for other platforms, I just don't know if I should write Windows-specific code or not.
>>
>>52484069
It's not exactly difficult to answer it both ways and then just turn in the right one when you ask him later.

Hell, the phrasing is going to be the same either way, just memorize the numbers for both answers, and fill in the blanks on the spot when you ask him
>>
File: 1425271680909.gif (848KB, 665x662px) Image search: [Google]
1425271680909.gif
848KB, 665x662px
>>52484332
scratch that

FUCK GOOGLE DEVS
>>
>>52484265
>>52484354
The basics are kind of the same, socket/connect/bind/listen/accept just need to initialize a struct (WSAStartup)and use SOCKET type instead of int.

You also don't have unix goodies like select() on the descriptor.
>>
>>52482833
it's quite difficult to do i'd have to consult an expert

what are your credentials?
>>
>>52484069
isn't the amount of "x" outputted given by
xs (n) = n * log2 n
>>
>>52484471
Good to know, thanks.
>>
>>52481702

When it gets off topic its annoying though
>>
>>52484539
I only count 3.
>>
File: 1452403462016.png (79KB, 307x400px) Image search: [Google]
1452403462016.png
79KB, 307x400px
>>52484539
Did you delete it because you realised you made an off-by-one error in your counting?
>>
File: 1452449294308.png (401KB, 500x708px) Image search: [Google]
1452449294308.png
401KB, 500x708px
What's the algorithm to make the most circley possible thing out of X amount of items?

For example, if I had 4 items, the most circley thing I could make is:

 #
# #
#


If I had 5 items, the most circley thing I could make is:

 ##
# #
##


And so on.

I don't want to hear talk of pi as pi is for perfect circles and it is impossible to have an infinite number of items.
>>
>>52484646
>If I had 5 items
6*
>>
>>52484646
Use a switch statement.
>>
>>52484646
instead of items, thing of them as sides of a regular polygon, so the most circle-like shape you can make is an n-gon
>>
>>52484524
yes
>>
>>52484695
i didn't read ur post og post, so I thot you didn't know the answer
you had figured it already and was asking another question?
also, what class is this?
>>
>>52484646
https://en.m.wikipedia.org/wiki/Midpoint_circle_algorithm
>>
>>52484722
I'm not the original poster, I had just been looking at the algorithm and came up with the same answer.
>>
>>52484646

for (t = 0; t < 2pi; t += (2pi / count))
((largest line you can draw through 1) * count / 2pi) * (cos t, -sin t)

then rotate so that the largest lines are perpendicular to the tangent

just a guess though
>>
>>52484836
alternatively if you don't want to rotate, make it the smallest line

for a character you can assume it's a box around the actual image so the min would be the width or height
>>
File: bpt.png (22KB, 819x642px) Image search: [Google]
bpt.png
22KB, 819x642px
what does /g/ think of blitzplus?
>>
File: temp.png (177KB, 1024x1022px) Image search: [Google]
temp.png
177KB, 1024x1022px
>>52484104
no one else? happens in internet explorer too
>>
>>52484104
>>52485003
This is a programming thread, fuck off.
>>
>>52485040
Any cute girls with penises who know haskell here?
>>
>>52484944
Literally who?
>>
Why does functional programming make people so angry?
>>
>>52485068
All programing is rage.
>>
>>52485068
They were angry before they learned functional programming, they were just complaining about something different at the time.
>>
is it possible to create a tree that is contiguous in memory? Like if I use new or malloc it'll create the node right next to the other ones?
>>
>>52484944
All them magic numbers though...
>>
>>52485097
Not if you intend to delete any nodes.
>>
>>52485068
FUCK YOU
>>
>>52485068
Haskell raped me when I was younger
>>
>>52485040
the problem is obviously caused by faulty programming
>>
who here knows libGDX
>>
>>52485068
FP is a stupid fad and its proponents are insufferably smug about using FP and they think they're so smart for it when they really aren't. hahasklel is literally a FAILED experiment according to its own creator.
>>
>>52485135
i know part of it. what would you like to know?
>>
>>52485150
>according to [..haskell's] creator
then it's probably wrong
>>
>>52485150
>all FP is Haskell
Okay.
>>
>>52485161
how do you dispose a textureatlas that's linked to an assetmanager asset
>>
>>52485150
the salt is stronk
way to prove >>52485068 right
>>
File: 1307836671279.jpg (58KB, 720x540px) Image search: [Google]
1307836671279.jpg
58KB, 720x540px
>Getting back into programming
>Did 3 years of java in highschool
>got no college cred cause local college didn't believe "java had a place in the world"
>Go back to college, Java class
>ezAezLife
>All the current Java IDEs are fucking garbage

BlueJay sucks nuts and makes you jump through hoops to run fucking hello world

Eclipse is the most top heavy, try hard fucking kit I have ever seen. I has a heart attack every time I make a variable cause "it hasn't been used yet" NO SHIT I JUST MADE IT!

Jsource is the least backed IDE ever, my god if you google it you get a bunch of jewish resources. I aint making this up!

My fucking kingdoms for an Java IDE that is bloated, or designed in the most bass ackward way possible.
>>
Need to learn opencv with python very quickly, unfortunately its still developing and the documentation I can find stinks, anyone have suggestions on resources?
>>
>>52485068
Because it is by far the best paradigm, but the only language that successfully implements FP and yet still manages to be used in the real world is ocaml. Thus, people who are savvy about languages are angry because they know lisps are the best languages but they also know they'll never see a real-world (non-dsl) lisp that's not broken beyond any attempt at use. As for the others, they know they'll never see a language with C syntax and proper FP support reach a usable state, thus even if they were to use ocaml, they know they'd never manage to find contributors for their project outside of jane street.
>>
>>52485172
using functions is okay. basing the entirety of your program around functions, essentially turning it into a glorified math expression, is stupid.
>>
>>52485192
The docs are great. Kill yourself, pajeet.
>>
>>52485191
Isn't the most recommended one currently IntelliJ?
>>
>>52485200
The irony here is that you seem to think "math expression" is a trivialization.
>>
>>52485200
>essentially turning it into a glorified math expression, is stupid.
Explain your reasoning.

>>52485209
Not pajeet here... I regard the python documentation as pretty subpart and poorly organised, honestly. Maybe I just have higher standards.
>>
>>52485199
>>52485200
All these dubs.

I'm trying to learn some web dev for making games. Right now my primary experience involves text based console games in C#.
>>
>>52485200
all programs are math expressions senpai
>>
>>52485200
>enabling trivial parallelization
>enabling entire slews of optimizations
>enabling provability
>stupid
Back to india with you!
>>
>>52485223
>>52485219
most interesting programs have state, imperative procedures and I/O. FP is not the most suitable paradigm for those things.
>>
>>52485200
>essentially turning it into a glorified math expression, is stupid.
that's not even what Haskell does though
and if you actually find a language that does this to an extent, it's actually pretty ingenious
if you can base the language's type system off of real math theory then you can use that for safety (verifying formal correctness of you code at compile time) and speed (can eliminate many runtime checks because things have been statically verified)
>>
>>52485250
Why?
>>
>>52485241
just run your shit through wolfram mathematica if evaluating math expressions is all you're going to do
>>
>>52485241
>enabling provability
Dang, an idrisfag.

>>52485250
Yes. It is. You simply don't understand FP. I don't think you understand how FP programmers think about state. A program as a whole isn't stateless. The "stateless" concept is that no outputs are depending on some overall state of something, but only upon their inputs.
>>
>>52485180
sorry i'm not too familiar with that.

this might help if you haven't read it already:
https://github.com/libgdx/libgdx/wiki/Managing-your-assets
>>
>>52485239
This. Arithmetic sets are turing-equivalent; any computation can be described as an arithmetic set (or its peano equation) and vice versa.
>>
>>52485239

I/O isn't a math expression, Anon, and a program that doesn't do I/O is equivalent to an empty program.
>>
>>52485282
>The "stateless" concept is that no outputs are depending on some overall state of something

But why not?
>>
>>52485265
>imperativefags are literally THIS retarded
>>
>>52485295
I/O can be modelled with functional programming very very easily.

>>52485311
Because that way lies the land of buggy and untestable garbage.
>>
>>52485250
FP can model state easily. Simply return a tuple of the returned value and the new state.
FP can model I/O easily. Simply define an operator to chain or sequence I/O actions. You see this in imperative programing with promises.
FP can model imperative procedures easily, with the same methodology as I/O.
>>
>>52485282
>The "stateless" concept is that no outputs are depending on some overall state of something, but only upon their inputs.
this is stupid because the output still depends on the state of the inputs. you're just spergically deciding that everything has to be passed as function parameters. where is the benefit in that?
>>
how good is everyone here as programmers? in a scale between 1 and 10
>>
>>52485337
8 (9 while drunk, 10 while high and drunk)
>>
>>52485199
F#
>>
>>52485324
>FP can model state easily. Simply return a tuple of the returned value and the new state.
so it's exactly as a non-FP program just that you're passing state around "because reasons".
>>
>>52485350
found the 2
>>
Language: Java -
Im working on an object that the user can move around with WASD but im running into a problem where if I press A and D rapidly the object "sticks" and wont move for a split second and then resumes. What can be done to fix this?
if(tempObject.getId() == ObjectId.Player){
if(key == KeyEvent.VK_D) tempObject.setVelX(5);
if(key == KeyEvent.VK_A) tempObject.setVelX(-5);
if(key == KeyEvent.VK_SPACE && !tempObject.isJumping()){
tempObject.setJumping(true);
tempObject.setVelY(-14);
}
>>
>>52485334
>>52485360
If you weren't so retarded, you'd realize that this is something imperative programmers will advocate as well.

We shouldn't have to explain to you why global variables (and by extension, any kind of global mutable state like I/O) are an issue when it comes to writing safe and fast code.
>>
>>52485295
it can still keep your computer warm though :^)
>>52485282
>Dang, an idrisfag.
we need more tbqh
>>52485311
lots of reasons. first and foremost, it makes concurrency simple (even in imperative languages, concurrency and global mutable state are considered incompatible). it lets you debug things without having to bring along the whole program (i.e. one function can be tested at a time, and also dropped into another program with 0 side effects). it also can be evaluated at compile time so you can completely remove function calls that don't rely on any sort of state or IO and replace them with their results, or you can prove that the functions behave in a certain way for certain inputs.
>>
>>52485068
The claims do not match the reality AT ALL.

They keep claiming something is superior despite all evidence in the last 40 years proving them wrong.
>>
>>52485323
>buggy and untestable garbage.

It's been working just ""fine"" for 100 years now.
>>
>>52485337
depends on what you're comparing against and what kind of scoring system you're using but i'd give myself about a 9 compared to all employed programmers (including code monkeys)
>>
>>52485334
>this is stupid because the output still depends on the state of the inputs.
Inputs don't have state.

If you enter "cats", it is cats. It doesn't change later after you do some work to be "dogs". Cats are always cats. A new input later of "dogs", and thus a new call stack based upon that is similarly not going to mutate any state.

>He writes glorified state machines instead of functions defined for all inputs
WHY.

>>52485381
>we need more tbqh
I view them basically as gods.

>>52485384
>It's been working just ""fine"" for 100 years now.
Clearly you don't work as a programmer. It's MAYBE. MAYBE. been working """""""""""""""""""""""""""""""""fine""""""""""""""""""""""""""""""""""""
>>
>>52485375
the variables don't have to be global.
>>
>>52485360
yep, as simple as that.
>>
>>52485324
>Simply define an operator to chain or sequence I/O actions.
; (A new line would work too.)
Every language is functional now.

>>52485381
>it also can be evaluated at compile time so you can completely remove function calls that don't rely on any sort of state or IO and replace them with their results, or you can prove that the functions behave in a certain way for certain inputs.
This is where your arrogance reveals your ignorance. Imperative languages have been doing this optimization before any compiled functional language existed.
>>
>>52485383
That's a fair point, and is the reason why I'm working on my language.

>>52485384
Only when you reprove your program using type theory. Functional programming kills two birds with one stone.

>>52485398
If they're not global, aren't they getting passed into the function? Methods are just object->object functions with special call syntax.
>>
>>52485392
>If you enter "cats", it is cats. It doesn't change later after you do some work to be "dogs". Cats are always cats. A new input later of "dogs", and thus a new call stack based upon that is similarly not going to mutate any state.
this is what i mean when i say that the program becomes a glorified math expression. an interesting program is going to have a mutable variable (or variable output coming from a different function) fed into the function, so it could be "cats", "dogs", "fags" etc.
>>
>>52485420
>Every language is functional now.
I don't think you really understand what he was saying. We're talking about values which represent I/O actions and can be composed, and treated as values in their own right.
>>
>>52485436
If you're trying to imply that a functional program can't do I/O, you're off your rocker.
>>
>>52485399
so it's stupid and pointless

>>52485424
>If they're not global, aren't they getting passed into the function? Methods are just object->object functions with special call syntax.
so OOP is FP now? lmao kill yourself
>>
>>52485445
Actually, it is. Objects are equivalent to closures and each can be implemented using the other.
>>
>>52485420
>This is where your arrogance reveals your ignorance. Imperative languages have been doing this optimization before any compiled functional language existed.
yes, but pure FP makes it easier for the compiler to recognize which functions that can be done for. it requires a lot of analysis for the compiler to determine that, and that optimization is still very conservative in most languages. D is on the right track because it lets you mark functions as pure so that the compiler can tell.
>; (A new line would work too.)
>what is do notation
>>
>>52485436
>an interesting program is going to have a mutable variable (or variable output coming from a different function) fed into the function, so it could be "cats", "dogs", "fags" etc.
What are you talking about?

Why on earth would it need to mutate?

  @tailrec
final def gameLoop( action: PlayerAction, gameState: Game ) {
import MuhSurvival._

clearTop()
//Describe the action
printArray( action.describe )

if( gameState.gameEnd.isDefined ) {
endGame( gameState )
} else {
printFullGameState( action, gameState )
print("Command: ")
val choice = io.StdIn.readLine.toLowerCase
val chosenAction = determineAction( choice )( gameState )

gameLoop( chosenAction, chosenAction.resultingGameState )
}
}



Here's the main game loop for something I was playing with. Not that no state mutates. If you ever have a reference to something, that value will never change on you. It will always be what it was when you got the reference. Immutability is beautiful.

I know this is a rough example, but it was just something I had offhand. I've actually been doing some imperative programming lately because I'm working with someone who is just starting to learn and finds imperative more comfortable.
>>
>>52485461
You can mark functions as pure in gcc if you want.

Just saying, don't care about your faggot paradigm argument.
>>
>>52485323

That it can. I am merely noting that the claim "all programs are math expressions" is incorrect. More correct is to say "all programs are I/O."
>>
>>52485483
>>52485483
>>52485483
>>52485483
>>52485483
>>
>>52485487
There's nothing mutually exclusive about the two.

Is a program that inputs X and outputs Y not just a function from X to Y?
>>
>>52485471
>code
there is no point in doing this. you're just packing everything up into one "mega object" (gameState) that holds fucking everything at once. and unless the compiler is super clever you're doing a lot of needless data copying. immutable variables are inefficient as shit. you ARE mutating the game state because you're just throwing the old one away as soon as you get the new one. it's just a roundabout way to accomplish the same thing while adhering to your shitty ideology. it's dumb as shit.
>>
>>52485438
Those are called procedures. Composing procedures to produce new procedures was around since the 60's, but not very common because GC technology was slower than it is today.

>>52485461
>D is on the right track because it lets you mark functions as pure so that the compiler can tell.
PL/I let you do that in the 60's. It was called REDUCIBLE.

I guess we get back to the idea of the "FP" paradigm reinventing ideas from the 60's with new names and syntax.
>>
>>52485125
>>52485132
I laughed hard
>>
>>52485360
>its impossible to model state with functions
>no, its actually really simple, see?
>oh, so its just like other programs?
>>
>>52485541
so there is no inherent advantage to FP vs other paradigms
>>
File: 1444589415464.jpg (165KB, 439x550px) Image search: [Google]
1444589415464.jpg
165KB, 439x550px
too much FP talk
>>
>>52485580
i'd FU
>>
If we could find an energy source that relies on pointless discussions, /dpt/ would be rich as fuck.
>>
>>52485965
I didn't see any function operators
Thread posts: 349
Thread images: 43


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