/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Peace_war_game
twitter.com/NSFWRedditVideo

First for Pascal.

Second for Rust is SJW cancer.

Third for Python

Fourth for Forth.

5th for python3

6th for regular expressions

where did the sjws touch you?

Which URL should I make the POST request on? Here's how the form looks like.
Sorry if this is a stupid question. I had no issues with this the last time and I'm pretty sure I'm doing everything exactly the way I did it before.

is lisp the most redpilled language?

formlocationurl.something

...

~ $ python
Python 3.6.0 (default, Dec 24 2016, 08:03:08)
[GCC 6.2.1 20160830] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import braces
File "", line 1
SyntaxError: not a chance

nice argument

click it yourself and go to the Net tab in your browser's inspector to see what request was made

this way you can see what exact url and parameters were used

I can't figure it out, help.

for(int i = 0; i < 1000; i++)
{
if(Math.Sqrt(i) % 1 == 0)
{
Console.WriteLine(i);
}
}

I hate spoonfeeding plebs but I really want you to stop posting.

LINQ flavour if you really want to show off to your teacher/professor/mother

Enumerable.Range(0, 1000)
.Where(x => Math.Sqrt(x) % 1 == 0)
.ToList()
.ForEach(Console.WriteLine);

Thanks ^-^

i added a spinning icon to indicate the audio stream is being loaded

i'm thinking about integrating torrenting into this thing, so people can stream directly from torrents like popcorn time

would that send riaa assassin's after me?

is linq like activerecord

Would Sup Forums be interested in a prisoners dilemma competition?

We create a thread, user's implement the solution, send the code to OP, OP runs it against each other and posts results in the thread.
The code would literally be a function that returns a boolean value so even if you don't know much programming, you could still participate.

No.

hows it different

what exactly are you trying to do

LINQ is just a convenient way of enumerating (and performing operations on) collections, where as ActiveRecord is a pattern which stores stuff in databases whilst you're working with in-memory objects to make persistence simpler (or some shit like that).

i meant ActiveRecord the Rails ORM tho which has a similar chaining API, nvm

Looks pretty good!
Kinda annoying that the loading icon is not centered in the square.

search "macintosh plus"
rename it something else

Yeah, I'm working on some css magic to fix it

Sure, could be fun,i wrote some programs for that.
What language would it be in though?
Or would you use some cross-language interface
inb4 20000 tit-for-tats.

That's what ActiveRecord does in Rails, it just stores stuff in DB's.

If you're going off the basis of the chaining, LINQ is more like SQL.

A Sup Forums competition. People submit code, OP gathers the submittions and pits them against eachother, and than posts results which submission was the best.

The prisoners dilemma is as follows:
You and your friend have been accused of a crime. You get interrogated. You can either stay silent or betray your friend.
If you both betray eachother, you each get 2 years in prison.
If one of you betrays the other, and the other is silent, the betrayed gets 3 years, and the betrayer gets 0.
If you both stay silent, you each get 1 year.

You repeat this a thousand times against the same person, and see which submission racks up the least amount of years.

Most people don't even know what prisoners dilemma is so i don't expect everybody to just go for tit-for-tat.
Besides, if it gets a lot of interest, there's always more complicated problems.
As for the language, the easiest would be java. You provide an interface people have to implement with a single-class and no dependencies.

So I get to run untrusted code on OP's computer? Count me in!

But there's a way to always win at that game that involves debugging your parent to check what the other program returned.

Obviously there'd be rules like no network/disk io, no reflection, no dependencies.
And OP would get the actual source code to manually check.

Also do we get info on the previous move? As in the peace war game? en.wikipedia.org/wiki/Peace_war_game
Or more broadly, what would be the input and the scope of the program that you ask the players to write?

That's no fun.
There's not a whole lot of different solutions to the prisoner's dilemma if you don't allow people to play "creatively"

LINQ is for interacting with data structures. ActiveRecord is for interacting with databases.
LINQ is a language feature. ActiveRecord is a library.
LINQ is the best tool for its job within the languages it is supported in. ActiveRecord is inferior to the Sequel gem.

Most of LINQ's features on Ruby would be equivalent to a subset of the methods available on the Array class.

import random

def only_way_to_play():
return random.choice([True, False])

A snake game I just finished in Java runs smoothly on windows 7 but on ubuntu it's very laggy and sometimes it just shows the top left corner of the window and nothing else. Wtf is going on?

Simulating the prisoner's dilemma is pointless. The nature of the problem is that no matter what, betraying is always better for you regardless of the other person's choice.

What's wrong with stealing what they built and use it for yourself?

This is why we can't have nice things.jpg

There's literally nothing wrong with Rust

Yes you can store all the previous moves. You get to play thousands of moves against the same player, so its about predicting what the player will do based on previous moves.

It's the most simple 'AI' competition possible. It's a start, and it still can be fun seeing where your submission ranks.

That would be a valid submission yeah. Though i'm not sure it would be rank high against other more clever solutions.

>It's the most simple 'AI' competition possible. It's a start, and it still can be fun seeing where your submission ranks.
No, it can not possibly be fun. It's a waste of time for everyone involved and comparing that to an AI is an insult to machine learning.

Not always no. If you betray all the time, you gain all those years because other smarter submissions would figure you out and betray you every time. And than when the smarter bots ran against more passive bots, they would gain less years overall than your bot.

Which is why 'AI' was in quotation marks.

"fun"

Untrue in the described scenario (repeated trials)

If you want prisoner's dilemma, just go play Zero escape virtue's last resort.

It's about writing a bot that plays it for you, not playing it yourself.

But a bit is boring. The thing about the prisoner's dilemma is the human judgment and decision taking. A bit will follow rules for it's decisions so it stops being a dilemma.

s/bit/bot/g

Damn phone

Fine. You want more 'fun'?

You can modify the game so instead of fixed 0 (if you betray and he stays silent), 1 (if you both stay silent), 3 (if you get betrayed) years, the years you get are random each time, so you have to keep that in account when making your decision.

So there is no viable strategy since you can't predict the outcome

So the only option is betray because I might get 0 years, otherwise if you pick a truly random integer I'll get a stupidly huge number of years in prison.

No, each iteration you would know all possible outcomes. The only difference would be, it would be random every time.
So you know how many years you get if you get betrayed, you know how many years you get if you betray the opponent, and you know how many years you get if you both stay silent. Three variables that change every time, and you get all three as input.

Obviously there'd be bounds for the years. And who says the years have to be integers? It can be a float.

There would also probably be anons who would compete to maximize their years instead of minimize them.
There's all kinds of stuff you can do.

>Obviously there'd be bounds for the years.
That's still not an interesting game, now you're just introducing noise in the process but that doesn't change the usual strategy.

>And who says the years have to be integers? It can be a float.
That doesn't change anything. You can also measure it in milliseconds instead of years, but who the fuck cares?

Then what would be an interesting game? Something that involves probabilities? Incomplete information? Impossibly deep state trees?

Rules that are a teeny tiny bit more complex than the 60 years old begginer's introduction to game theory.

You have to start somewhere user.

How about Ruby's sex collaboration game?

>Stop trying to do interesting things!
>Why don't you go do some coloring books instead of reading that Feynmann guy?
If you don't challenge yourself, you'll never get further than "starting somewhere".

>Then what would be an interesting game?
A game where you can get information about the competitor's program so you can outsmart them.

Can I hang with you guys?

>lazarus
yes my new friend

Not unless that whole environment is written in LISP.

Everything about this image looks disgusting

Anthony Hopkins

Is it permissible to interpret the ncurses window just as a field of rows and lines and just use it a an array of rows? At least temporarily? Like, if I wanted to draw a rectangle
draw_rectangle(corner_h, corner_v, height, width) {
for(i = corner_v; i < height; i++) {
for(j = corner_h; j < width; j++) {
if (i == (corner_v || corner_v+height - 1) || j == (corner_h || corner_h+width-1))
put_character('#', window_cursor[i][j]);
}
}
}

Sorry for the pseudocode, but I hope the idea is understood.

I wanna make a programing language of some sort, I think it could be fun. Not a general purpose one, just a small DSL of some kind. But I can't think of anything I could use a DSL for, any ideas?

write a virtual OS in Haskell

Filesystem management.

It's the "Write once, run everywhere" part of Java.

Interesting. What would it look like? I guess it would have to be interactive, because you generally only wanna make a set of changes to a given file structure once. For example, the program "move every file from here to some other folder" only makes sense to execute once. So it would be more of a REPL than a compile and run kind of thing.

Jesus how the hell do you work in that cluttered mess

It would look like bash.

Stop using dynamically typed languages

Just stop

You don't see builders trying to drill holes with hammers

I just puked a little in a mouth, and then couldn't stop from throwing up entirely

>muh tools
general purpose languages are NOT specialised tools

Who here /golang/

Actually, unless you say 'using dynamic languages to do X', that's not a great metaphor.
Unless you name a specific task, the last line is more like 'You don't see builders trying to use hammers'.

See

Nobody, not even you

Anyone know ClojureScript?

I need to make a piece of code to get the average age of everyone over 50 from a vector of ages. I know how to filter but how the fuck do I average the results?

This is what I have so far.

(defn gt50? [n] (> n 50))
(filter gt50? [55 20 75])


Returns [55 75]

golang is great for getting shit done, it doesn't have any of the abstract wankery that other languages do, and static typing allows it to have good performance, and concurrency is very easy in it, literally one function is all you need

>ClojureScript

why

race conditions and no generics

You don't see builders using dildos

you don't need generics

every language has race conditions, they're a fundamental problem of concurrency

But what about the homosexuals? Dildos aren't just for women, user.

Homosexuality is wrong

Why not? I wanted to learn a Lisp and ClojureScript allows me to do webshit.

rust solves race conditions in threads

But what about the women? Dildos aren't just for homosexuals, user.

It's the best language in its field. It's still shit though.

Nope, it simply tries to paper over the problem, but it's impossible to solve it at the language level for all cases.

>It's still shit though.
This.

Rust solves data races, not race conditions. They're different things.