/dpt/ - Daily Programming Thread

Daily Programming Thread

What are you working on, anonymous ?

# New & Revised /dpt/ Code of Conduct #
We want to ensure that the /dpt/ community, while large and diverse, remains
welcoming and respectful to all participants. To that end, we have a few
ground rules that we ask people to adhere to.

- *Be friendly and patient.*

- *Be welcoming.* We strive to be a community that welcomes and supports
people of all backgrounds and identities. This includes, but is not limited
to members of any race, ethnicity, culture, national origin, colour,
immigration status, social and economic class, educational level, sex,
sexual orientation, gender identity and expression, age, size, family
status, political belief, religion, and mental and physical ability.

- *Be respectful.* Not all of us will agree all the time, but disagreement
is no excuse for poor behavior and poor manners. We might all experience
some frustration now and then, but we cannot allow that frustration to turn
into a personal attack. It’s important to remember that a community where
people feel uncomfortable or threatened is not a productive one. Members of
the /dpt/ community should be respectful when dealing with other members as
well as with people outside the /dpt/ community.

- *When we disagree, try to understand why.* Disagreements, both social and
technical, happen all the time and /dpt/ is no exception. It is important
that we resolve disagreements and differing views constructively. Remember
that we’re different. The strength of /dpt/ comes from its varied community,
people from a wide range of backgrounds. Different people have different
perspectives on issues. Being unable to understand why someone holds a
viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to
err and blaming each other doesn’t get us anywhere. Instead, focus on
helping to resolve issues and learning from mistakes.

Other urls found in this thread:

phauna.org/papers/anime/anime.pdf
hastebin.com/ehihuguhoc.vbs
github.com/saolof/clj-minesweep/blob/master/minesweep.clj
lua.org/about.html
en.wikipedia.org/wiki/Bogosort
en.wikipedia.org/wiki/Hardware_random_number_generator
github.com/perception88/judas-watch
judas.watch/
origami-fun.com/origami-fortune-teller.html
github.com/pugjs/pug
gist.github.com/bkaradzic/2e39896bc7d8c34e042b
youtube.com/watch?v=iSmkqocn0oQ
tldp.org/LDP/abs/html/
twitter.com/SFWRedditGifs

Is there one of those lists of projects to implement?

I need something to practice my C before I move on to C#

Are you expecting us to read all that?
We have important brainfuck projects to work on!

I'm making pancakes

>/dpt/ frequenters will get this

>What are you working on, anonymous ?
a TCG, with monsters and dragons and shiet

Thinking about namefagging on dpt.

Give me one reason not to.

There you go my dude

No one gives a shit.

you will instantly be hacked and all your devices full of violent gay porn.

>all your devices full of violent gay porn.
but it already is?

I have a question about good practice in C++.

Let's say I have the following class defined in Foo.h
class Foo
{
...
private:
Bar *bar;
};
where Bar is another class.

In my makefile, I've specified both Foo.cpp and Bar.cpp, which in turn include their respective header files. Now, my question is this: Do I #include "Bar.h" from within Foo.h, or simply do a forward declaration (which is feasible, due to only using Bar pointers)?

No one cares who you are on here
It means you probably have a big ego and people will dislike you for it

Forward declare wherever possible.

Why is it every shitty programmer likes anime? Whenever I see people using anime avatars on github their code is invariably shit and every person I've met in real life who likes anime is some greasy neckbeard manchild.

That is a very tiny room. I hope there's some brilliant solution for ventilation and airflow.

I've had this problem for a long time. Can't speak to their code quality, but anime lovers are invariably wierdos who I would never want to associate with irl. Nothing you can do.

Ignore and move on.

Yeah thats what I've noticed, personally. In my experience they're basically like "bronies". I don't particularly care that they like childrens cartoons, but they overwhelmingly seem to act like children as well.

I like anime but I don't shove it in anyone's face. Nobody knows I like anime. Most people are like this.

But since this is an anonymous site we don't feel the need to hide it.

I'm sorry, i must have ended up on Tumblr by mistake. Could you guys point me the way to Cred Forums?

Can I practice this with php?

Yeah these googles are killing Cred Forums

...

wow haven't been to Cred Forums for some months but op is still a faggot

So, /dpt/. If we forced all of the Haskell programmers in this thread to only program in x86-64 assembly for a week, what kind of code do you think they'd all produce?

Are you a reasonably interesting person? Can you program your way out of a box?

The problem is less so much that they like anime, and more that they're attention whores. I just use the stock avatar on github.

I'm interested in learning SDL and OpenGL for making a vidya game, but should I stick with C or learn C++?

Do you WANT to learn C++? If so, might as well start now. Otherwise, sticking with C will do fine.

If you're making anything bigger than tetris go for C++.

Sure you could make it in c. But id go for c++ as it will make your life easier.

The only reasons to ever use C these days are either embedded programming or you want to create a library with lots of bindings to other languages.

C++ is a terrible terrible language.
Stick with C, or use another language like Rust or D.

/dpt/-chan, daisuki~

C++ with sfml or clanlib

phauna.org/papers/anime/anime.pdf

codingame

is something wrong with

vector v;
vector::iterator iter;

v.push_back(object);
v.push_back(object);
v.push_back(object);

for (iter = v.begin(); iter != v.end(); iter++)
cout parameterofobject)

It won't work out the way you think it will.

>final project
>6 pages
Why the fuck won't you stay filtered?

>phauna.org/papers/anime/anime.pdf
tl:dr

Trust the compiler, Luke.

nothing visibly wrong with that. if you want a better answer, post all the code.

There is a reason everyone uses c++ in vidya dev user. Don't listen to Cred Forums, they have a superiority complex so they think telling people to use C for everything makes them look smart.

>D
>Any better than C++
Just no.
>Rust
Unproductive language, it takes ages to write something. Maybe I'd use it if I was gonna program a space shuttle and a single bug could kill people.

The last line *literally* answers your first line

I'm currently writing a game engine using C++ and OpenGL, and I would say it's worth it to learn C++. Sure, it's been done before in C by many, but I like the object orientation when it comes to games, which obviously is made up of objects.

I'm trying to research diversity of race and ethnicity in Hollywood movies (2016 titles if that matters).
It is pretty easy to scrape and compile the data of titles and actors/actresses, but I'm stuck on the problem of how/where to look up the racial background of each individual actor in an automated way.

OOP is a terrible way to design games.

How so?

False

>the entire industry is wrong

here the concrete code

class Card
{
public:
Card();
virtual ~Card();
void printcarddata();
int cardnumber;

protected:
string cardname;

private:
};

void startgame() {
vector game;
vector ::iterator cardn;

[many card-class objects are declared and pushed back into game here]

for (cardn = game.begin(); cardn != game.end(); cardn++) {
cout cardnumber)

OOP is bad, but objects themselves aren't.

In games you will make heavy use of polymorphism and using c++ virtual functions beats using function pointers or creating your own dispatch table.

Why not try and see for yourself?

"""
The more social subset of hackerdom watches anime because it reinforces their identities and values. Anime shares a certain aesthetic with the computer and Wired culture, thus it is attractive to hackers.
"""

"""
76 to 85 percent of anime fans are male.

Anime fans tend to be students.

Most anime fans who are student major in either computer science or electrical engineering.

Most anime fans who are not students are high-tech workers.
"""

OOP is a terrible way to design anything, so it's a terrible way to design games.

Polymorphism is not exclusive to OOP.
>virtual functions
Terrible performance.

I'm finishing my electrical engineering studies and they're making us learn the following languages
>C
>C++
>VHDL

What are some other languages that could be relevant to my field of work at some point?

Explaining nothing.

>Anime shares a certain aesthetic with the computer and Wired culture
Wat?

verilog
forth

What is your field of work?

>Terrible performance
As opposed to function pointers or a dispatch table? But user, virtual functions ARE implemented using dispatch tables.
The only difference is that in C you have to write it manually and so you're more likely to write bugs.

x86 assembly
MATLAB

>There is a reason everyone uses c++ in vidya dev user.
Mainly technical debt and cultural spread tho.
Ride the tiger etc.

Technical debt?

the -> operator has higher precedence than dereferencing, so this (*cardn->cardnumber) is equivalent to (*(cardn->cardnumber))

also cardn is an iterator, so *cardn has type Card, so it should be cardn->cardnumber, or (*cardn).cardnumber

at least, thats what i think. im kinda tired.

Any LUA programmers here?
I trued writing this hastebin.com/ehihuguhoc.vbs
For mpv, to download the currently playing video file.
But It doesn't work.
Any idea?

>Suggests user is wrong
>Doesn't suggest the solution

rolling

The industry is moving toward muh data-driven and muh homegrown entity systems.

Historically it was all C user.
There is a reason they switched to C++

They would switch again if something better came available. Most gameplay code is no longer written in C++ already.

"""
The Anime Aesthetic

The anime aesthetic is similar to Harris' description of
the aesthetic of the computer[9]. Harris goes even so far
as to say that modern computer systems are filled with
"comic-book froufrou" which hides the internal function of
the computer. The connection between the comic-book look and
anime is simple: anime comes from Japanese comic strips, called
manga. The colorful, smooth, articulate aesthetic is common to
both the computer and anime. While Harris goes on to describe
why this aesthetic is a bad thing -- at least that it serves no
purpose -- computer hackers appreciate the beauty they can create
with the computer even if it is useless in practice. Levy's
description of the hacker ethic states you can create art and beauty
on a computer , and he goes on to discuss how a hacker spent hours
working on program that would play a song.
"""

From what I get so far, if I dont wish to make Computer games or other high performance stuff, there is no reason to go deep into C++?

Simply learn Java, JS Angular, CSS, as everyone does?

thanks a lot, I will try it

I have met some god-tier anime loving programmers. So I have respect.

Still have never watched any of that shit. Still visit an antarctic 2d pictorial interaction application.

#include
#include
#include

char *strrevdup(char *src)
{
size_t len = strlen(src);
if (!len) return NULL;

char *str = (char *) malloc(len+1);
if (!str) return NULL;

size_t i, j;
i = len;
j = 0;
while((str+--i) >= str)
{
*(str+j++) = *(src+i);
}
*(str+len) = '\0';
return str;
}

int main(int argc, char *argv[])
{
char name[] = "HELLO!";
char *bob = strrevdup(name);
puts(bob);
free(bob);
return 0;
}


how can i improve my program to make it less shitty? t. new so no bulli pls

Applying for that kind of job right now (binding). It will make me very happy if I get it.

Sounds like a load of bullshit.

Thank you user

Well I don't know that yet, I'll have to make the decision in a few months and the big specialization next year

Oh yes we've dabbled in both of those, I remember assembly being a massive pain

Exactly.
>C
Embedded stuff, kernels, small libraries.
>C++
Large high performance projects (like games)
>C#, Java
Desktop/mobile apps. Server apps.
>Python,ect...
If you wanna make it werk quickly and don't care about performance.
>JavaScript
Web
>Ruby
Only use if you're gay

>so it should be cardn->cardnumber, or (*cardn).cardnumber
thats what helped!

thanks a lot again.

>ow can i improve my program to make it less shitty?
>strrevdup
More descriptive function names comes to mind.

Okay, thanks. This is the impression I got as well.

And I will consider Ruby.

> Mainly technical debt and cultural spread tho.
Those are reasons they didn't switch from C to C++ earlier (that, and the fact that C++ compilers tended to be fairly shitty for the first decade or so).

They aren't going to be switching back to C, whose only real advantage is that there's less to learn, which only counts for something if you're an amateur/casual programmer.

hey Cred Forums what books would you recommend for a dev stuck in "no mans land" (not a beginner, but not advanced), i have seen the god-tier books on the wiki are they still relevant?

what should i put instead?

I would recommend you stop reading books and start a project on something that interests you.

Then just google/read up on problems as they arise.

I don't know, do i? That's the problem.
I shouldn't have to analyze the code to know what the function is supposed to do.

If I wanted to start with some basic graphics, as if wanting to make my own game engine, what should the language and library I use be?

It's mainly for learning experience, rather than developing anything particular.

c++

it duplicates a string and reverses it

And libraries?

I don't know enough about graphics yet to use something like Vulcan/opengl

C++ and opengl

c++ has the most libraries and tools for game development.

Are you unable to think of a good function name for that?

Is OpenGL easy to get into? I don't think I know enough

Something like
char* DuplicateAndReverse(char *cstr);

yeah i have no imagination sorry

>CamelCase
eww

There's plenty of documentation and tutorials for it. It helps if you know a bit linear algebra

its not camelcase
camelcase would be

duplicateAndReverse

That's even worse!

strdup_rev()

Now you're back where you started.

>Making your own engine
As someone with experience making games as a hobby. Making an engine is the wrong way to go about it.

What you wanna do is make games. Not engines. Otherwise you'll waste a lot of time wondering what features your engine needs and implementing ones it doesn't need. And half a year later you'll still have nothing.

Anyway I think learnopengl.com is currently the best resource for beginners to learn graphics programming.

what would be a beginners tool for testing?
particular functions, instead of having to relaunch the whole program again and again.

But making the engine is the interesting bit.

what language ?

Going through a roguelike C# tutorial. It's cool to see stuff I learned previously actually come together.

BlueJ
IDLE

c++
and java

thanks. i think IDLE is the more mainstream one?

JUnit

Yeah I agree but if you don't have a game in mind you can work towards you'll just program aimlessly, i've been there myself and there is a reason /agdg/ cals engine devs nodevs.

Once you're on your second, third,... game you'll start reusing your old code and eventually you'll be left with an engine.

>game you'll start reusing your old code and eventually you'll be left with an engine.
True enough.

rate my hello world:
#include

int main(void) {

printf("hello, world!\n");

return 0;

}

BlueJ is for java. I took a noob java course a long time a ago. We used BlueJ. At the end of the course we were supposed to make a small complete program, and the whole class was stumped, and the teacher was "oh wait, did we actually forget to teach you about main?".

For c++ it's HTFU.

careful, someone might steal your ideas and claim ownership

"hello, world!"/10

Add length into strrevdup as a second argument so you can avoid strlen() if the user already has the length (for example with a static sized buffer).
Then either let the interface always be: strrevdup(s, strlen(s)) or maybe add a special case for len == 0 and then you call strlen() inside strrevdup.

If I want to make games, I think I'd use Unity or GameMaker Studio.

But making an engine would be fun side project to slowly build. I know it'd never amount to anything serious, but would be fun thing to do.

But yeah, I realise making a game engine to make my own game is reinventing the wheel.

>HTFU
google search doesnt give me anythung
;__;
typo?

To be honest followed the C philosophy of naming functions.
If you'd create a function named strrevdup in Java I would agree that is stupid, but in C I really don't see an issue.

bloated as fuck

>Give me one reason not to.
I can't think of one reason you should.

Cool man. i have some RLtuts "queued up" aswell. Atleast the ones with hq

how much is that

Forward declarations save compilation time.

However, raw pointers in C++ is generally considered bad. You need to have an exceptionally good reason to justify not using unique_ptr, shared_ptr etc.

>printf instead of puts or write
2 / 10 see me after class

theres nothing wrong with this code, is it?

Ally fish (15, "Deep Sea Fish", 400, 1, "Beast", "Water");
cout

The C philosophy of naming functions is shit, and a relic from when storage space was limited so you didn't want your source code to me unnecessarily large.
There's absolutely no reason to stick to it anymore.

No wat I mean is that without something in mind you'll have a hard time figuring out how to write an engine that is practical or even usuable.

If you don't want to make a game then just clone Mario or something. As long as you have a clear goal on mind.

m80 if you want an answer you really need to start including all the code thats executed.

Ah, yeah I guess that's fair.

I think my "engine" would just do a basic 3D environment, that can be walked around and textured. But I guess once I did that, it would be a "well that's done, not much point now..."

That would be a good start. You would have something to build on. Then you can give the player a reason walk around the environment.

AGDG is retarded though because most enginedevs are clearly working towards a specific game.

more CALLs than actual code

Ambitious target for one, self-learning programmer with only C as a good experience.

But yeah, I will try and follow something.

It's either that or make some games in studio maker. Or learn Swift and do iOS app development that way.

I don't know what I should focus on.

Rate my clojure: github.com/saolof/clj-minesweep/blob/master/minesweep.clj

HtDP or SICP?

I'm new to meme science and R. What are some good beginner projects?

TAOCP

filtering

...

...

>trusting the compiler

>unique_ptr
Why? What benefits does it has that a raw pointer doesn't?

>You need to have an exceptionally good reason to justify not using unique_ptr, shared_ptr etc.
How about "I'm not a baby"?

do i still need to learn arrays in C++, if i can already use STL containers and iterators?

yes.

Yes you do. Don't be a bargaining codemonkey, master the fundamentals before depending on the STL.

okay senpais. but i am still finding myself using vectors, for convenience reasons.

arrays are now an obsolete data structure, a relic from the past.

Nah, they are great for cases where you want to avoid overhead. A vector of ints can be wasteful if an array works for your purposes, since you'd use 64 bit pointers for each 16 bit integer and the extra level of indirection increases access times.

so the basic difference between java and c++ is the lack of pointers in the former?

Java has pointers
sun.misc.Unsafe

>since you'd use 64 bit pointers for each 16 bit integer
lel, no. the only overhead is 8 bytes.

dreamt in code last night: i can't really remember what the program was about now though. i think it was oop

>dreaming in oop
get help

014 Collatz Conjecture
ayy

Was it when of those dreams that made perfect sense while you were in the dream, but then when you want up you realise how insanely illogical everything was?

It was OOP, so I doubt even he thought it was logical

>i think it was oop
that's no dream, that's a nightmare

these get funnier and funnier everytime

known to hold for values well above INT_MAX
not the worst short script to write

r u a kid prodigy
can u make me a google

rloling for a gud projekt

garbage collection in the former, as well, so you have non-deterministic object destruction.

personally i prefer C++ templates to java generics, particularly when it comes to functors.

#include
#include
#include
int main() {
std::vector v = { 5, 1, 3, 4, 2 };
std::sort(v.cbegin(), v.cend());
for (int i : v) std::cout

why do weebs have to ruin everything

You're supposed to implement it yourself you donut.

>Java lacks pointers
>All objects are pointers by default
?
Integer a = 10;
Integer b = a;

a += 10;
System.out.println(b);
????

>LUA
see lua.org/about.html
>Like most names, it should be written in lower case with an initial capital, that is, "Lua". Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!

that's what the :^) was for you muffin
>tfw my shitposting is too advanced for Cred Forums

Thanks for nothing you useless reptile.

in haskell this is just
import Data.List (sort)
main = print $ sort [5,1,3,4,2]

But that's a singly linked list user, not a vector. Lists don't have O(1) random access.

>1474404234145.jpg
fizzbuzz plez

it didn't say anything about vectors

...

Here you go, I editted his code for him

#include
#include
#include
#include

int main() {
std::vector v = { 5, 1, 3, 4, 2};
time_t seed;
time(&seed);
while (!std::is_sorted(v.begin(),v.end())){
shuffle (v.begin(), v.end(), std::default_random_engine(seed));
for (auto a:v){
std::cout

Best algorithm.

Can someone please calculate the big-O of that one?
Is the worst case O(∞) ?

After reading every single post to this point, you might as well call this a C++ thread ...

best case is O(n)

>Is the worst case O(∞) ?
No.

im going to rewrite akaribbs in x86 assembler!

>shuffle
>no using namespace std
>not std::shuffle
This shit's not even gonna compile. Probably better anyway.

en.wikipedia.org/wiki/Bogosort
Yes, worst is O(infinity)

an object is a pointer faggot.

OP's pic is very true. Only women program computers. It's where they belong. Couldnt make money with them in the kitchen anyway. Good they know their place these days.

Fucking idiots

>en.wikipedia.org/wiki/Bogosort
>Yes, worst is O(infinity)

"""
For any collection of fixed size, the expected running time of the algorithm is finite for much the same reason that the infinite monkey theorem holds: there is some probability of getting the right permutation, so given an unbounded number of tries it will almost surely eventually be chosen.
"""

Also, it could be infinite with a true random number generator but such a thing doesn't exist.

I meant to say "is not" a pointer. fuckit.

who here /osdev/?

char *strrevdup(char *src, size_t len)
{
char *str = (char *) malloc(len+1);
if (str) {
str += len;
*str-- = 0;
while(len--)
*str-- = *src++;
}
return str;
}

...

do modern RNGs ensure that every possible output will be outputted given enough time?

no

>en.wikipedia.org/wiki/Bogosort
>Unbounded (randomized version),[1] O((n+1)!) (deterministic version) or O((∞)!)
>O((∞)!)
is the factorial REALLY necessary there?

is it generally possible to make a function with a custom return-type in C++?

like,

class custom {

};

class returnACustomObject () {

custom object;
return object;
}

>a true random number generator but such a thing doesn't exist.
en.wikipedia.org/wiki/Hardware_random_number_generator

wait do you mean within their range? if so, more or less

yes

custom wouldBeDumbIfYouCouldn't (bool baka) {
custom object;
return object;
}

>having to import libraries
I shig at both of you
(sort #(5 1 3 4 2) #'

what's that supposed to show me?
i don't suppose she's 'cd..'ing in her own shell running on her own kernel, therefore your pic isn't related

yeah, but you do it like this:
class Custom{
};

Custom returnACustomObject(){
Custom object;
return object;
}

>true

thanks

but that is basically what I have written, isnt it?

yes, true. Quantum properties are true random.

rolling ma dudes

github.com/perception88/judas-watch

It's a command line app for getting the data for judas.watch/

no
you wrote

class returnACustomObject () {

that's not a real function
you want

custom returnACustomObject () {

Yeah, but instead of 'class' you use the name of the object class, like when you define the object.

ah, ofc

my bad
and you are right, would be dumb if you could not

i'm not ur dude, "man"

I stopped caring about Haskell when I was introduced to the concept of monads. What a crock of shit. If your program can only modify state by inventing a higher-order abstraction that can't exist, like some kind of programming deity, then you are fucking wrong and the language is flawed. Same for type checking that basically says "the correct type is whatever the correct type is". That's what the error message said transcribed to words, but god forbid if i wrote in down in English instead of the meme Haskell runes that GHC marks me wrong.

Haskell is logical and category theory never lies my ass. Haskell is just as flawed as any other """functional""" language.

also this won't work because the iterators passed to sort need to be non-const

You have seen the light.

You're baby is now read for OCaml.

Pasta

> Posting #1488 meme image
Poltard, who told you to get outside your containment board? Go back, we don't want or need you here. Reported for racism.

>body*

what is the point of having a language for functions only?

Sorry, retard time here, why are/would you putting pointers to another class in your class?

see you next thread

No one cares about your /pol memes, alt right stormtard.

then how can apply the infinite monkey theorem here.

more or less is not something I can proove something with

...

The answer is yes, if you run any proper random number generator long enough it will eventually produce all numbers within the range.

float dist = distance(point, center);
float circular_gradient = 1.5 * sin((1.0 - dist / HEIGHT) * 50) * cos((1.0 - dist / HEIGHT) * 50);

float adj = center[0] - point[0];
float adj_over_hyp = adj / dist;
switch (d) {
case R:
px = 0.25 * circular_gradient * MAX_COLOR;
break;
case G:
px = 0.5 * circular_gradient * MAX_COLOR;
break;
case B:
px = 0.75 * sin(circular_gradient * 100) * MAX_COLOR;
break;
default:
px = 0;
}
px -= 100 * cos(acos(adj_over_hyp) * 10);
px *= cos(asin(adj_over_hyp) * 10);

>*iter->parameterofobject
Nope, operator precedence fucks it up, you virtually always want to wrap *iter in braces just to be safe, also
>Iter++
This is autistic, but with C++ that'll create unnecessary copies of iter to do the operation, whereas ++iter won't.

how do I design a function that searches for a particular parameter in an object?

the input is "number"
and the function returns the first, lets say, car, where number = carnumber

It's literally against the global rules to post your pol meme images here, newfag poltard.

O(n!) solution in Hasklel

import Control.Monad.Logic

bogosort l = once $ do
p = insert x

insert e [] = pure [e]
insert e l@(x:xs) = pure (e:l) `mplus` (((:) x) insert e xs)

MLton > OCaml

'tism

thisdesu

That's bad how?

...

Hey /dpt/ trying to work in C++, already know a bit of C and Java.

I've noticed that I can use classes in C++ for polymorphism etc, what are the differences between using classes and using structs?

Also, I'm used to having structures with headers and the functions on a normal cpp file associated, like car.c includes car.h, with classes, do I need to do this or just write the functions in the header file?

I don't get the meme, is it because there's spanish on the box and a lot of latinos are criminals?

What is the point of having a language for objects only?

>MLton > OCaml
explain

samefag

none

Name a programming language that ONLY has functions.

'tism

C

No

True randomness is idealistic, like a perfect circle.

>((:)x)
(x:)

>if sorted p then pure p else mzero
monad comprehension:
[ p | sorted p ]

Don't try to play dumb stormtard, that is a reference to the Nazi 1488 meme. 14 is the number of words in a white supremacist mantra, and 88 is code for HH (Heil Hitler).

>True randomness is idealistic, like a perfect circle.
no it's not. Just listen for quantum properties. Easy as shit.

epin
:DDDDDD

post the most pointless function you can think of

void function()
{}

main(){for(;;)main();}

Those get used all the time. Someones you need to pass a function to another function, but you can't always want that function you are passing to do anything. So empty functions are useful.

A struct is a class, in c++. The only real difference is struct memebers are public by default. Any other difference is semantic.

safePerformIO :: IO a -> IO a

they still depends on the state of the universe.

something truly random depicted in pseudo code would be

state = get_current_universe_state() // the state of all things
assert( random(sate) != random(state) )


you are confusing randomness with impracticability.

Or else what?

Because the classes need to communicate to one another. In some cases, pointers are the only way to avoid circular dependencies.

The identity function is the only function that can be typed as (X : Type) -> X -> X so it is not useless. It functions as the sole value of the Church-encoded unit type.

[](){}

>they still depends on the state of the universe.
No it doesn't. That's not how quantum properties work. They are truly random and unpredictable.

>get_current_universe_state()
One of the fundamental concepts of quantum mechanics if that you can't measure the state of the universe without affecting it.

-impracticability +unpredictability (word corrector)

notIdentity :: a -> a
notIdentity _ = undefined

`,:^)

I wasn't talking about Haskell.

float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}


i think i fucked up

No I'm not. Quantum properties are predictable with regards to what possible values they will have and how likely each one of those properties is, but which one actually gets observed is completely random.

Nice OS.

First of all, use string.format instead of .. (it's faster for concentration because .. makes extra copies of the string). Second, just pass the download function as a key callback, no need to wrap it in an anonymous function that calls download, so like this:

function download ()

generate_filenames("")

local full_command = ('(wget -c %s) && notify-send "Download completed"'):format(file_in)
mp.osd_message("Download started")
os.execute(full_command)

end

mp.add_key_binding("alt+m", download)

Other than that, you've not pasted the entire code, you're not doing anything with generate_filenames() and you've not posted any errors so I cannot help any further.

Do you want to search every object of "car" for the matching number?
Jam all the objects into an array/vector, then iterate through the container comparing number to Car.getNumber() (ie) then if true call Car.getName() or whatever you're looking for.
If C++ use std::array or std::vector and learn about iterators and auto.

Which one is the best practice then?

Does anyone else get spurs of motivation, like once every month or two I'll spend an entire night programming then not touch code for months, but this time it feels different - I've been doing nothing but programming in my free time for a week is this finally going to be it boys am I going to be a programmer?

thats the method i itended to use, thanks

Planning on making origami-fun.com/origami-fortune-teller.html
in python am I right in thinking I can have more than one if statement?

>OUT KEEP
What did she mean by this?

did you honestly think that you could only have one if statement? what kind of language only allows one if statement?

Thanks for replying.
I'm getting this [download] Lua error: ~/download.lua 27: expected near 'end'
The code is a cut and paste from the mpv lua scripting guide.

sorted xs = zipWith (

...

anyone a clue what this could mean?

error: could not convert 'cardn.__gnu_cxx::__normal_iterator::operator*()' from 'Card' to 'Ally'|

card is a parent, ally an child class

Yeah it seems like you've not copied the entire snippet because the upper part of the code is missing the function name and variable declaration (and possibly some logic).

first time programming and on codecademy it would always make me use if, elif then else never made me use two ifs

It's not Japanese, though.

It's in japan or Taiwan presumably.

I've went through it again, and everything seems right.
As I've copied everything. I know it's a hackjob but I most be missing something crucial.

no

Why are jews so rude?

are you talking about nested if statements or does it actually limit you to a single if statement for the whole program? If so then wow, I'm sorry you had to put up with that

nevermind, found it out

always trust the compiler

did you mean and . (drop 1 >>= zipWith (>=)) ?

If it has methods, it's a class.

Already stuck on my first python project lads
4 def a1()
5 choice1=("Pick red or blue")
6 if choice1 == ("red")
7 print("red")
8 a1()

Error message
if choice1 == ("red")
^

SyntaxError: invalid syntax

I use struct when I have something POD and class otherwise.

I disagree.

It just means you'll crash harder.

dubs confirm

You're comparing two tuples rather than the strings.
You're not reading the user choice.
You're missing a colon.

replace
6 if choice1 == ("red")

with
6 if choice1 in ("red"):

thanks, working fine now

what's the most meme template engine out there
i think it might be this

github.com/pugjs/pug

IM SO FUCKING DONE WITH POINTING EVERYTHING TO EVERYTHING IN C++

FUCK IT, EVERYTHING IS IN MAIN() NOW

Just take Adderall

>FUCK IT, EVERYTHING IS IN MAIN() NOW

Okie-silly-dilly-dokie-o.

c++

gist.github.com/bkaradzic/2e39896bc7d8c34e042b

i have also been coding for five days in my free time

but i still have such a fucking lot to learn before i even get considered for an internship ;___;

Pug is pretty nice, but I haven't tried any other template engines as I'm not big on web dev. Why is it meme and what other template engines would you recommend instead?

memes aren't necessarily bad

>A language must be good enough for everything

What the actual fuck Stroustrup. Are you insane?

The absolute madman.

If a language is only the best at one or two things (but bad at everything else), isn't it more of a DSL than a "real" programming language anyway?

That's what it means to be a general purpose language.

>file.png
please use descriptive variable names

That would be true, but that's not how most language are developed. Most languages identify some things that should be their selling point and really solves a problem and the defines a language around those selling point and then put reasonable limits around what can be done in the language so it doesn't lose focus.

C++'s objective is different. It goes and identifies problems that C++ can kinda do but not too well, and then schemes up some pretty well designed but bloated feature to solve the problem. Which is why the language has a ton of ways to solve one problem and why it is so big.

General purpose doesn't mean to do everything under the sun that's possible.

I'm not going to save something I just printscreened.

reminder that pure functional programming is the only true multi-paradigm

new thread when ? :3

Purity can be accomplished without being overly functional.

this is the last one

purity isn't enough

I mean I agree that using higher order functions is good but it's not exactly multi-paradigm.

you can easily embed other paradigms into FP, but not vice versa
compare "multi-paradigm" FP with FP FP

Okay, I see what you mean.

>you can easily embed other paradigms into FP, but not vice versa
You can embed FP into procedural somewhat easily, and by extension you can embed anything that you can embed into FP, into procedural.

>You can embed FP into procedural somewhat easily
No you can't.

Pure procedural means no lambdas, which means you're fucked.

pure functional isn't multiparadigm by definition

You can embed other paradigms in pure functional code

>Pure procedural means no lambdas
Okay fair enough, but "pure procedural" is just a term you made up right now.

No you can't.

I mean purely procedural. Not necessarily procedural with no observable side effects.

Yes you can.

Playing about with Godot and it's funky Python dialect. Haven't had this much fun coding in a while.

I guess it's just a matter of definition, but I don't see why it wouldn't include lambdas or at the very least function pointers.

>As opposed to function pointers or a dispatch table?
Yes.
> But user, virtual functions ARE implemented using dispatch tables.
The shittiest possible way to implement them.
They take up valuable space in the first cache line of objects.
They are invisible to you so you can't actually achieve true dynamic dispatch by hotswapping different sets of functions.
They incur double indirection because you need to deref the object itself, then indirect into the array of function pointers.

Manually implementing your own dynamic dispatch is much more flexible, reusable, ultimately cleaner AND more efficient because you can control memory layout better and do clever things like sort the function pointers to maximize instruction cache usage.

No you can't. If you add them it's no longer pure FP.

If it had lambdas, it would be functional. There's a lot of overlap between procedural and functional, that being the main difference IMO.

>if you add them then it's no longer pure FP
the language is pure FP

Pure FP means you don't have object oriented shit and don't have mutation, which non functional paradigms tend to rely on.

Objects work best without unbridled mutation (strong updates), actually.

State monad

I agree. But OOP means they need to contain mutating state. So pure FP bans that kind of shit.

not OOP, not mutation

struct Handle
{
Handle() : m_index(0), m_counter(0), m_type(0)
{}

Handle(uint32 index, uint32 counter, uint32 type)
: m_index(index), m_counter(counter), m_type(type)
{}

inline operator uint32() const;

uint32 m_index : 12;
uint32 m_counter : 15;
uint32 m_type : 5;
};

Handle::operator uint32() const
{
return m_type : 12

Wtf. I've used C++ for years but I've never seen this syntax before. I'm guessing this tells the compiler how many bits to use, What's it called?

Not really. Objects don't need mutation, not that purity means no mutation at all. Mutation is just an optimization where you use the same memory instead of making a copy somewhere else.

bitfields

Bitfelds, but you should generally avoid them, compilers tend to generate horrible machine code for them.
Better to mask and bit twiddle manually.

>Pure FP means you don't have object oriented
wrong. thank you for sharing your ignorance with us.

>Objects don't need mutation
They do in OOP. THat's the entire point of them actually. To contain mutable state and keep it encapsulated.

You could program in an OOP style, or embed a DSL, and just because you can run state purely doesn't mean you have to.

State monad

Please Cred Forums rate my fizzbuzz:

#include
#include

bool fizzbuzz()
{
unsigned int index = 1;

while(true)
{
if(index%3 == 0)
{
if(index%5 == 0)
{
printf("%d - fizzbuzz\n" , index);
}
else
{
printf("%d - fizz\n" , index);
}
}
else if(index%5 == 0)
{
printf("%d - buzz\n" , index);
}
else
{
printf("%d\n" , index);
}

if(index == 100)
{
break;
}
index++;
}

return true;
}

int main()
{
return !(fizzbuzz());
}

>and just because you can run state purely doesn't mean you have to.
We're only talking about "pure" fp, so obviously everything needs to be done purely.

Maintaining invariants through encapsulation is one thing they're good at but it's not the only thing. And, again, you can have mutation and have it still be pure. So if you have e.g. Rust where the type system is good at verifying mutation but can't verify other properties you still want to make use of encapsulation. But it's still pure.

Pure FP means all the expressions are pure, you can still have values representing impure computations thanks to the first class nature of monads

>if(index == 100)
> {
> break;
> }
> index++;

If only there was an easier way to do this.

Linear types are better at making side effects non-observable.

>you can have mutation and have it still be pure.
wrong.

>Rust where the type system is good at verifying mutation but can't verify other properties you still want to make use of encapsulation. But it's still pure.
Rust is absolutely not pure. Just about any remotely FP language can be considered "pure" is rust is pure.

Linear types do not achieve what monads do, stop bringing them up and shilling them at every opportunity

Linear types have nothing to do with effects, and even if you tweak the semantics so that they do, they still aren't as powerful as monads.

if(++index == 101) {break;}

something like this annon?

while (index < 100) {
...
index++;
}

or

for (index = 0; index < 100; index++)

Purity isn't the complete absence of effects. Otherwise, nothing useful could ever be pure. It's about controlling effects to ensure that they're either not observable or expressed in the type system. Rust does a good job of this.

Even Haskell isn't that pure since you have partiality and non-termination everywhere.

Calm your tits, I never said they were good at everything monads do.

>Purity isn't the complete absence of effects.
yes it is but it's idealistic. the best we can do is to separate the pure from the impure which is what haskell is about.

Rust is about that as much as Haskell is.

>Otherwise, nothing useful could ever be pure.
Exactly
youtube.com/watch?v=iSmkqocn0oQ

>It's about controlling effects to ensure that they're either not observable or expressed in the type system.
Sure, with OOP and mutation require happening. Sure you can find FP ways of achieving what these concepts seek to achieve, but that doesn't mean you are doing OOP and mutation.

I want to make a bash script that does the following
>makes a .txt file with a random letter
>waits 1 hour
>deletes old .txt file
>makes a new .txt file with a random letter
>repeat
any help is appreciated

rust is a meme

>351
We need a new thread now !

that's incredibly simple. I don't know much about bash scripting, but I'm sure you can find the few commands you need here tldp.org/LDP/abs/html/

>Exactly
I don't think you get my point. I'm saying that you can be pure for all the reasons that purity is good without having to give up usefulness.

Think about what a pure function is. Same input means same output, every time, yeah? Haskell gets around this by (at least conceptually) reifying computation in a monad and using laziness to "interpret" the reified computation at runtime. Linear types facilitate this by allowing you to simply say you can't ever call this function on that input again. In both of these frameworks, you can perform useful effects without disrupting the "pure invariant".

>Sure you can find FP ways of achieving what these concepts seek to achieve, but that doesn't mean you are doing OOP and mutation.
OOP has fuck all to do with mutation. It's encapsulation that's important.

This should be incredibly easy to figure out

here you have it

is it okay if I start my curly brace on a new line instead of at the end of a line

hey to be an asshole but i just wanted to get some input on these courses i am planning on starting on 1 this winter witch one would you pick and why?

1-5 and 7

Can't have Let's Encrypt on LAN server, so figuring out alternatives. Not going to use a self-signed certificates either.

Might go with public+private keys for encryption coupled with one-time challenge to prevent replication attacks on login only. The problem is session cookie is still up for grabs. Might need to link the session cookie to IP, but then changing IPs becomes a hassle.

Looks like all shit but I guess one of the last three

No one cares about CompTIA

can i get a decent job doing it?

Ayylmao

HtDP, then if your good at math work through SICP.

I don't always dream about programming, but when I do, it's functional.