/dpt/ daily programing thread

old thread:

Attached: Julialogo.png (370x208, 10K)

Other urls found in this thread:

github.com/mfyuce/GitTorrent
kiwiirc.com/client/irc.rizon.net?channels=#Jow
stackoverflow.com/q/50683786
docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value
pastebin.com/85AELxts
twitter.com/NSFWRedditVideo

I was just reading about Julia
Seems like an amazing language, Fortran speed with Python-like expressivity and easy way to call C functions
Why is Jow Forums not memeing Julia so that we can finally get rid of R?
Why are shit like Rust being shilled instead of Julia?

>why is /dpt/ not memeing Julia to get rid of R
I'm confident based on the posts I've seen that very few of us use R.

Thinking of things to do for my final year college project. I want to do something involving games but I don't know if that's a good idea generally or what sort of thing I could focus on.
What would be an appropriate thing to do with games? Just make any sort of game I'm interested in? Or would there need to be some underlying reason and context for its existence?

Isn't it just for le data science meme?

Decentralized Github NOW github.com/mfyuce/GitTorrent
Decentralized Github NOW github.com/mfyuce/GitTorrent
Decentralized Github NOW github.com/mfyuce/GitTorrent
Decentralized Github NOW github.com/mfyuce/GitTorrent

Attached: Terry.gif (480x270, 1.63M)

Why does Visual Studio have 2 types of attributes? Do I use private fields or properties?

Julia is a meme. Learn Python or R.

What's a good community to have fun with and share my experiences and questions as a beginner programmer who started with C and is now experimenting with C++?

This morning I tried out for_each and lambda.
When capturing members in an object, I don't understand why I can't capture single members like [this->member] instead of capturing everything with [this].
Compiler gave me an error about missing , or identificator or something.

I feel like this is due to some information I am missing about the this pointer or maybe scope. Can I get a pointer? (no pun intended)

Attached: 1488093780011.png (543x550, 276K)

Learn Haskell.

Trying to use json-glib in my C program. But I can't get the include to work.
#include
gcc says "No such file or directory".
I have the package installed - but the path is this:
>/usr/include/json-glib-1.0/json-glib
with the contents:
>json-glib.h json-gvariant.h json-path.h json-types.h json-version.h ... etc.
I can include so gcc can find it, but that header file includes the others as just so it doesn't find those.

What do?

Attached: 7897.png (581x530, 337K)

something like this?
struct Foo
{
int var = 42;
auto create(){
var++;
return [x = var]() { return x; };
}
};

Still considering writing my git web frontend.
The issue tracker should use a SQLite database and be structured like an imageboard, but the authoritative data store should be a git repository.
1 board = 1 folder
1 thread = 1 text file
commit-originated thread = c.txt
issue-originated thread = i.txt
discussion-originated thread = d.txt
All markup (that is, backlinks and external links, as well as distinguishing the statusline [Anonymous 06/09/18(Sat)19:15:40 No.66286236] from ordinary text) should be ANSI escape codes, so it can be shown in an ordinary terminal.

Then, it can easily be mirrored.

Sorry I needed a sec to make an example

#include
#include
#include

class word{
private:
std::string str = "hellooo";
int numOfChars, uselessVar;

public:
void count(){
numOfChars = 0;
for_each(str.begin(), str.end(), [this](char &x){numOfChars++;});
std::cout token.
Would it not be better to specifically capture only numOfChars, which is what I need, instead of uselessvar and the string too?

Apparently I'm retarded. My build script wasn't using the pkg-config output for json-glib-1.0.

Is there any practical reason to actually learn Haskell? I'm going to anyways just because I think it's interesting and it'll look good on a resume, but it kind of seems useless outside of theory.

you're one stupid nigger.

u2

you can do
for_each(str.begin(), str.end(), [&n = numOfChars](char &x){ n++; }); // capture numOfChars by ref

Depends on what you focus on. A popular idea is to games for medical purposes.

Stuff like games for people with disabilities: (blind or partially blind people, games that require few inputs that can be played with one or no hands, or motor problems). Or games for people with mental problems: autism, ADD...

Could be something very simple, and this sort of stuff is usually pretty well received.

Thanks, I didn't know about generalized lambda captures.
I just realized that this->numOfChars wouldn't be in the same scope either way, maybe that's the problem but the compiler error says that there needs to be an identifier before ->, "this" should be a valid identifier but it wouldn't work anyway I guess

Come to the IRC channel to talk about:
>kiwiirc.com/client/irc.rizon.net?channels=#Jow Forumsdpt

Do a simple centralized VCS. When the user change a file, rename the previous version with a number (.001 .002 ...). git is overrated and overcomplex. The use case is the kernel. Nobody does that.

Even if you didn't know about generalized captures, some very simple thinking would have told you that you could have done something like

int& ref = numberOfChars;
foreach(..... [&ref](char &x){ ... })
...


So don't say "you didn't know" as an excuse for your own stupidity.

I wanted to know exactly why this->numberOfChars doesn't work, not how to circumvent it.

It's my first week learning Python 3 and I'm having a lot of fun making this "Lotto 10K" game which basically just uses the random module to generate 10,000 numbers between 0 and 10,000. If the iteration number matches the generated number, it gets printed.(If the generated number is 1x - 5x larger than the iteration, it also gets printed, as well as if it's 0 or 10,000 OR the user's "lucky number").

Basically what I want is a way to add up all of the randomly generated numbers that are being printed in the if/else statements. Kinda stuck on this... please be gentle with me. I was an English major.

Attached: lotto1.png (674x582, 29K)

Attached: lotto2.png (881x820, 44K)

Thoughts on perl, /dpt/?

Attached: lotto3.png (509x304, 13K)

Powerful, complex and slow. Larry wall is a great guy.

Nigger

C'mon I was in the dark and I value my eyes

Attached: 1525525985017.gif (500x233, 839K)

Have a variable sum, then do something like sum += target, which is synonymous to sum = sum + target.
This will sum the number each time it's printed. But for instance, if num is 5000 and target is 10000, it will trigger both if target == num*2: and if target = 10000:. So keep another variable summed_already, then do if not summed_already:.

Why would it work if you weren't following through this? How would it be used within the lambda?

Capturing the this pointer the compiler knows that numOfChars is a member of the object and using numOfChars in the lambda is the same as this->numOfChars just like in a normal class method

Can someone explain to me what is wrong with making the simplification to particle swarm optimization that you just put a bunch of "particles" in a search space and on each iteration make them all move gradually closer to the currently best fit? I've looked online and it seems the algorithm is supposed to be more complex than that, but I don't see any arguments for why that should be any better.

>something like sum += target, which is synonymous to sum = sum + target.
Not in java lol

??? Retard

>slow
why though
From what I've read about it, it seems like a very simple language. It doesn't even have proper OOP and garbage collection.

I'm trying to make a chart that looks like this with React, what library should I use? Or should I do it manually with SVG?

Attached: Screen Shot 2018-06-07 at 1.10.53 PM.png (940x440, 61K)

stackoverflow.com/q/50683786
No you

I'm just so new I don't fully understand local variables I guess. Maybe, I'm getting UnboundLocalError. I'm obviously just writing this wrong.

Current best fit might suck

Hey guys
my video game company is looking at hiring a "creative design" person, basically an idea guy. We're AA but aiming high, competitive wage and benefits, great time to get on board. Remote is preferred.

Thought I'd give back and tell you before the ads go up. Hit me up with your best game ideas and I'll let you know if we should talk further.

Dark Souls but with
-New weapon types like murkrets or a medievil bazooka and you can take cover for things that are shoot back at you
-Parts where you have to run away from a huge enemy and the huge boss chases you to a turrent and you use it to kill him
-Other parts where you can use turrents on loads of people or even a catapult
-You can see how many kills and deaths you have in pvp and the more kills you get unlock extra abilities for you and new skins for your weapons and armour
-Free running and climbing up on sthings
-You have a npc partner and he is an ethnic and he makes jokes and he gives you estius flasks and stuff when your in trouble
-If you get backstabbed or parryed you can press a button at the right moment and you do a counter
-Bosses arent just running around hitting them you can get to like press buttons at the right time and it does damage
-Vehicle sections like on a horse and cart or a boat or like a stone age motorbike and gliders
-When someone invades it asks you if it's ok and if you press no then they are sent away
-You can go into peoples houses and talk to them
-If you get hit then dont get hit for a while your health comes back
-You can have a romance with someone and even it can be a man if you are a gay
-Better support like map packs for arena and new weapons and amrour or better versions of weapons and armour in the game
-Moderators chosen from popular members of the community, they will monitor for poor sportsmanship and ban those they feel are a negative influence on the community & metagame
-Some people need you to get things so you can go get them and bring them back and they give you souls or items
-You can get a pet and they go around and find items for you and secrets so you dont have to search around so much
-You can do a crafting if you gather enough materials or you can buy the materials for money

Sorry, not interested at this time. But really, best of luck to you.

post what you tried that gave you the unboundlocalerror.

these kinds of errors are caused by trying to assign to variables that aren't in the local scope. Python has to figure out where a variable lives on its own, it works like this:

if a variable is assigned a value, it is assumed to be local to the current context. unboundlocalerror occurs here if that assignment is something like += that assumes that the variable already holds some value. you have to specify nonlocal or global in order to tell python to look elsewhere for the variable declaration.

if the variable is just referenced, it's assumed to be global. this is why you can have constants at the top of your file and use them all over the place without having to use the global keyword 80 times.

>video game company is looking at hiring ... an idea guy.
No fucking way

also since you're new to programming feel free to ask if you have any questions about some of the terms I used there. Google first obviously, but I'll try to explain if you still don't quite get something. The relevant python documentation is here, it's a common enough point of confusion that they have a faq page on it:
docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value

>get index out of bounds error
>cant replicate it

I can make the logo. 500$/hour

Attached: 1464180848994.jpg (470x313, 15K)

An MMO, think chronotrigger + undertale

Hey thanks a lot man.

I don't understand how to get only the printed targets summed. I've been trying sum += target but I'm clearly missing something. I've also tried while loops with some really hilarious fails involving random numbers infinitely scrolling.

But yeah, summing printed numbers only. I tried assigning variables to all of the individual outcomes but that didn't work either. I've been all over google but I'm obviously misunderstanding the problem in such a way that the questions I'm asking don't generate relevant answers...

Attached: Capture4.png (764x548, 30K)

it's basically a write-only language. Writing Perl code is fun, but reading it is torture.

C has this neat feature:

void mysterious_function();

mysterious_function(&lorem, &ipsum);
mysterious_function(3.7f);


What is it called?

Autism

How much of a retard am I for skipping the SICP exercises?
Got through a good chunk of the book before I got the feeling that I shouldn't be as much of a lazy prick as I usually am, so I tried to pick up the slack before moving on.

What environment is the best for Scheme?
I'm trying to use MIT/GNU scheme but it's really obtuse.
I don't know how to use the Edwin debugger properly, the subproblems all tell me things about low-level functions that work under my code instead of the code itself, confusing the hell out of me.

Attached: 1506678975167.jpg (655x527, 36K)

What kind of response were you expecting with that "clever" comment?

>no anime in the image
>there are no signs of civilization here

Attached: 1561589489516.png (1920x1082, 3.28M)

just so you know it's undefined behavior if you call a function with arguments that don't match its definition.

undefined behavior

it's bad
it's not declaring a function with no params, as you might think looking at it
rather it's declaring a function with any number of params

it's bad

get DrRacket and download the addon for SICP.

nice idea, but implemented in NodeJS? is that even efficient?

this, but just slap in the #lang scheme and you are good to go

Thanks frens, I'm currently setting it up.
Time to stop being a couch potato and start conjuring some computer spirits.

Attached: 1506709724161.jpg (250x250, 49K)

I checked on godbolt, it seems gcc clang and msvc all put the expected values into the correct argument registers even at optimization levels, so I suppose its fine as long as you know what you are doing

you also need to worry about promotions if you do things that way

can anyone help me (an idiot) sum this shit?

so your current function will just always add target to sum. If you want to only add target to sum when one of the if statements is true, you need to move that logic inside of them.

but that would cause a bug right now, because if the lucky_num is 5000 then target being 10000 would result in adding it twice. one way to avoid this would be to have a boolean that starts out as False in each iteration of the loop, and gets set to True inside each of the if statements. Then at the end you just add to sum if that boolean value is True.

If you'd like an overall code review, post a pastebin or something of your entire program and I'll go through it.

It will do the 'correct' thing at the call site of course, but the problem comes in the actual definition of the function (unless you also define the function with an empty argument list and just ignore any arguments passed in)

Can someone explain me what is operational semantics.
Let's take a simple example. Given the function
let square x = x * x
we can transform it to something like this:
(defun square
(set $result (apply2 mul $arg1 $arg1))
(return $result))
which would perfectly describe what our original notation means, i.e. that our source, when executed, shall define a function, that uses its argument in multiplication, and return computed value.
Does it mean that the second form describes operational semantics of the original form?

>hosted on github
DOA

Turing was a mistake
Church was robbed
it didn't have to be like this

dumb frogposter

help im trying to learn c++ and coming from java im used to ctrl+clicking to read source code and understand

but in c++ when i do that i don't understand wtf is gong on. Like I click on std::string and its some weird stringfwd.h file and i cant see anything that looks like operations or osmething

anime website

All you've done is turned one language into another
One way of doing this is to define the redunction relation

stupid frogposter

see

>All you've done is turned one language into another
Yes, but semantics must be expressed in some language anyway.
>One way of doing this is to define the redunction relation
But how would it look? Could you show it on that simple example?

Thoughts on nim, /dpt/?

thanks man, would really appreciate it. Also take a look at play_again() - I'm not sure how to get it to actually quit the game...

pastebin.com/85AELxts

well for example

i ::= an integer
e ::= i | e + e

e1 -> e3
------------
e1 + e2 -> e3 + e2

e2 -> e3
------------
e1 + e2 -> e1 + e3

e1 -> i1
e2 -> i2
i1 + i2 = i3
---------------
e1 + e2 -> i3

this is a bad example because things always evaluate to integers, so it ends up being a lot like denotational semantics

Hi I'm going to be taught C# and Python from a programming course soon, are these any good? I want to make games but I know I will be taught to make software as well, how different is making software from making games? Seems so foreign to me.

Question about C++ destructors:

Let's assume you have a singleton class. class A{
public:
static A &getInstance();
private:
A();
~A();
};
will the following code result in a destructor call?
{
A &a = A::getInstance();
// do something
}
Not in front of a computer right now, can't test it myself.

No.

the singleton pattern in C++ is pointless anyway, just do class { /* ... */ } global;

Honestly, "denotational" and "operational" are mostly buzzwords. Denotational semantics tends to be understood as equating to mathematical objects, whereas operational semantics tends to be understood as sequences of reduction steps. Of course, a reduction sequence is a mathematical object and mathematical expressions are evaluated through reduction steps. It's all just semantics through slightly different lenses.

Usually, when it comes to programming language theory, denotational semantics is used for specification whereas operational semantics is used for implementation.

Another possibly enlightening example is type theory. Denotational semantics = proofs, operational semantics = executable programs.

What are the pros and cons of this compared to a Singleton?

A singleton is just a hack to achieve globals in a language that lacks them. You gain nothing but verbosity by continuing to use a singleton here.

line 83, in repeat
print(sum(target))
TypeError: 'int' object is not iterable

Fucking hell, I'm so close I can feel it

Attached: butwhy.png (717x889, 46K)

That's not a singleton. You may instantiate multiple copies of this object.

just print the traget you fag

Where can a cute girl find a guy to do her java hw (=

only by using some hack like decltype(global){}

I'm trying to sum the targets.

Read

I've started to go through your code, but I can fix this real quick. sum() takes an iterable object and adds up its elements. you're just passing it a number each time. Do a running sum instead, have a variable you declare outside the loop called target_sum or something and then just add to it.

To properly use sum() here you'd have to be appending all the intermediate numbers that you care about to a list and then passing that list to sum(), or wrapping your number generation in a generator and summing over that.

anyone?

prinft("hello");
:)

What kind of response were you expecting with that stupid comment?