[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: Sleep Sort edition

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: 370
Thread images: 16

File: sleepsort.png (33KB, 733x488px) Image search: [Google]
sleepsort.png
33KB, 733x488px
Old: >>57165960

What algorithms are you working on?
>>
>>57170056
First for D
>>
File: haskell..png (7KB, 397x131px) Image search: [Google]
haskell..png
7KB, 397x131px
>>
>>57170066
>no qt trap bf
;__;
>>
>>57170056
/prog/ legitimately contributed to computer science.

RIP
>>
>>57170090
Sadly the wikipedia page on sleep sort was removed because /prog/ was the source.
>>
>>57170108
Who will remember /prog/ and all of its "HAX MY ANUS" now?
>>
im gay
>>
>>57170125
Many do and the tradition lives on. Eventually I'll have to learn SQL and look through the backups.
>>
>>57170080
So why don't you go find yourself one? Shit, there's probably a bunch of lonely traps just chilling in /lgbt/ and /soc/...

>>57170090
/prog/ was the best. Most of it was memes, but there were still moments of brilliance.

>>57170108
There's still a page dedicated to it on Rosetta Code
https://rosettacode.org/wiki/Sorting_algorithms/Sleep_sort
>>
>>57170175
https://rosettacode.org/wiki/Sorting_algorithms/Sleep_sort#Haskell
>>
>>57170175
I hope that a [spoiler]/prog/[/spoiler] can be brought back on 4chan, I mean the guy who started the largest textboard in Japan now owns the site.
>>
>>57170175
holy shit just went to a kik thread on /soc/ and you aren't joking
>>
File: hiro.jpg (9KB, 200x200px) Image search: [Google]
hiro.jpg
9KB, 200x200px
>>57170209
>not knowing hiro's name by heart
>>
>>57170175
>https://news.ycombinator.com/item?id=2657277
Also the HN discussion.

>It finally happened.
>HN cut out the middle man. Instead of linking to something on Reddit about 4chan, we finally just linked straight to 4chan.

How cute.
>>
>>57170209
i mean a simple text board wouldn't be hard to start up yourself. hell, you could code the whole thing from scratch yourself if you wanted. no need for a user database or anything like that.

if you want to be silly about it, you could implement the site using several backends (e.g. ruby, javascript, php, python) and then give people a toggleable option for which backend they use to access the same site database/tables. the way 4chan lets you pick your own front end css.

it'd be totally pointless, but kind of funny.
>>
>>57170218
gosh he's cute isnt he? and his freak*n twitter avatar. ahh
>>
https://stefanprodan.com/2016/aspnetcore-vs-golang-data-ingestion-benchmark/
>>
I made a thread on the D forums asking about pattern matching, I hope Andrei responds :3
>>
>>57170239
I don't really want to add yet another textboard that is already covered in popular bbses. Maybe when I have the money and have more experience with web stuff. 4chan could do it since there is a large userbase here, but building up more than two regulars would be a long slog.

>>57170218
It's Hiroshima, right‽
>>
>>57170199
Rosetta Code is pretty nice if you want example code for... pretty much every language people use.

>>57170217
If you want a date, you just have to seek one out... and have good hygiene, a job, and a place to live that is not your mother's house.
>>
>>57170277
they'll never understand
they'll be like
"lol just use
match(x => ..., y => ..., (x,y) => ...)"

>>57170296
hiroyuki nishimura
>>
>>57170309
Maybe, but I'll do my best to convince them! Though I do have my high doubts it'll go anywhere
>>
>>57170334
show them use cases
>>
>>57170277
>D forums asking about pattern matching
Does D not have native regex support or something?
>>
>>57170361
>converting all your data type to strings to then regex match on them
this is dumb
>>
>>57170269

So native code is performing faster than the CLR. What else is new?
>>
>>57170349
I posted some links on how it works in Rust and Haskell (that also include examples), but I can't really think of any good use cases of my own
https://forum.dlang.org/post/[email protected]
>>57170361
It has std.regex, but that's not what we're talking about
>>
>>57170393
error codes
ASTs
they subsume enums
>>
I'm sure this has been asked a hundred times but what are some good programming exercises for beginners to program development?
I mean, all C programs aren't composed of just manipulating variables/arrays and using loops right?
>>
>>57170308
I can't leave my mom until I can afford a house lady
>>
Anyone wana be a real nigga and help me not fails my C programming class.
>>
>>57170423

Are you incapable of picking up after yourself?
>>
>>57170417
Right, I'll mention those when I get a chance
>>
>I mean, all C programs aren't composed of just manipulating variables/arrays and using loops right?
What else would there be?
>>
>>57170433
yeah
nor can I cook or do laundry

or go outside unless its work/school
>>
>>57170437
these are for variants btw
>>
>>57170447
I want to create a C program which has a seven-segment display on the screen when run and a counter which updates the display every 5 seconds.
Unless it's something stupid like using sleep, I just don't see how I can make a program like this, not that it's my objective.
I know that there are tons of libraries which might be able to do this, but as a student I want to know how they did it and what they used to do it.
Hopefully that's coherent.
>>
>>57170422

>I mean, all C programs aren't composed of just manipulating variables/arrays and using loops right?

With C, it's mostly about breaking your program down into logical procedures and manipulating data structures. You don't need to get into heavy abstractions, but you shouldn't be writing huge functions that could be split up into tasks.

>>57170448

>nor can I cook
If you can follow directions, you can cook. You don't need to do any fancy shit like flipping a pancake without a spatula to be able to do basic food preparation.

>or do laundary
Put clothes into washing machine, add in soap powder/liquid, turn on washing machine. When it's done, put shit into dryer. Turn knob to dry. If you don't understand the settings on your washer/dryer, there's bound to be a manual either with it, or somewhere on the Internet.

>or go outside unless its work/school
Do you suffer from social anxiety? You know there's medication for that, right?
>>
>>57170453
Right

Also, it looks like they've had multiple discussions already on it this year, so maybe they'll notice the growing interest in adding pattern matching and start taking it more seriously.
>>
>>57170466
Graphics without libraries is messi shity. Sdl2, opengl or vulcan, ftom higher to lower level

>>57170448
That's pretty pathetic desu, youll die a virgin
>>
>>57170480
> You don't need to get into heavy abstractions, but you shouldn't be writing huge functions that could be split up into tasks
That makes a lot of sense. I'm also studying EE so I'm beginning to develop an interest in programming of things like microcontrollers.
Do the same principles apply?
Is there an added layer of abstraction for interfacing with the hardware in these situations? Or is it all just done by the compiler?
>>
>>57170466

>I want to create a C program which has a seven-segment display on the screen when run and a counter which updates the display every 5 seconds.
Get something like GTK, make a window, draw some shit in that window.

>Unless it's something stupid like using sleep, I just don't see how I can make a program like this, not that it's my objective.
If you want to update something every 5 seconds, sleep would be the general wise idea.

>I know that there are tons of libraries which might be able to do this, but as a student I want to know how they did it and what they used to do it.
You can always read the source code to how they do it. That said, with all I/O shit, there's a level of abstraction that looks like this:

User application <---> Portable library <---> System specific library <---> Kernel (via syscall/interrupt) <---> Hardware

You want to make a window. You'd probably like to make it work on various systems other than just one. You use a library like GTK and tell it to draw a Window.

GTK knows what system-specific library to use on your system (X11 on Linux, BSD; Win32 on Windows), it calls the appropriate functions there.

The system library probably doesn't have the right permissions to do what you want to do, but it knows how to tell the operating system to do it for you. It invokes a special instruction known as a system call that switches your CPU into kernel mode and lets a syscall handler do the job for you.

The kernel, knowing you want to draw onto some sort of framebuffer device or whatever, starts writing to video memory.

The rest is just hardware interpreting a write to some memory that's backed by an I/O device and translating that into this rectangular shape being drawn to the screen.
>>
procedure Ada_Run is
type Integer_Ptr is access all Integer;
type Read_Integer_Ptr is access constant Integer;

procedure Ref_Pass (Value : out Integer_Ptr) is
begin
Value.all := 5;
end Ref_Pass;

procedure Read_Ref_Pass (Value : in Read_Integer_Ptr) is
Local : Integer;
begin
Local := Value.all;
end Read_Ref_Pass;

procedure Value_Pass (Value : out Integer) is
begin
Value := 4;
end Value_Pass;

procedure Read_Value_Pass (Value : in Integer) is
Local : Integer;
begin
Local := Value;
end Read_Value_Pass;

A : aliased Integer;
B : aliased Integer;

-- W : access Integer := A'Access; --W is a pointer
-- X : constant access Integer := A'Access; --X is a constant pointer
-- Y : constant access constant Integer := B'Access; --Y is a constant pointer with read only permission
-- Z : access constant Integer := B'Access; --Z is a pointer with read only permission

-- Or more simply
W : Integer_Ptr := A'Access;
X : constant Integer_Ptr := A'Access;
Y : constant Read_Integer_Ptr := B'Access;
Z : Read_Integer_Ptr := B'Access;
N : Integer_Ptr := Null; -- Dangerous but legal, read only access (Null) to be accessable by a R/W variable

begin -- Ada_Run
Ref_Pass(N); -- will throw error at run time
Ref_Pass(W); -- OK
Ref_Pass(X); -- X is constant, Ref_Pass expects variable
Ref_Pass(Y); -- not equivalent types
Ref_Pass(Z); -- not equivalent types

Read_Ref_Pass(W); -- not equivalent types
Read_Ref_Pass(X); -- not equivalent types
Read_Ref_Pass(Y); -- OK
Read_Ref_Pass(Z); -- OK

Value_Pass(W.all); -- OK
Value_Pass(X.all); -- OK
Value_Pass(Y.all); -- constents of pointer not variable
Value_Pass(Z.all); -- constents of pointer not variable

Read_Value_Pass(W.all); -- OK
Read_Value_Pass(X.all); -- OK
Read_Value_Pass(Y.all); -- OK
Read_Value_Pass(Z.all); -- OK

end Ada_Run;
>>
>>57170537

>Is there an added layer of abstraction for interfacing with the hardware in these situations? Or is it all just done by the compiler?
If there is, it is handled by the library, not the compiler.
>>
>>57170587
>>57170564
Thanks for the responses.
Usually I just get a stupid response like 'install gentoo' so I appreciate it anon.
>>
>>57170480
i refuse to red pill
>>
>>57170711
if you're going to talk like that, you need to leave and maybe kill yourself.
>>
>>57170616

Worth noting I was not aware you were talking about EE when I wrote my first post. Obviously you would not be drawing windows to the screen to create a 7 segment display if you are using a microcontroller and not a traditional desktop. That was a derp. In fact, the abstraction level with a microcontroller is probably a bit shorter, since you likely won't have a kernel in the way between your application and your hardware. So it's going to look more like

user application <---> library <---> hardware

And the way your library is going to be talking to the hardware is going to either be through specialized instructions for dealing with I/O ports, or through memory mapped I/O. This is more or less just "this section of memory is actually not RAM at all, but if you write at it like it is RAP, the memory controller is going to throw that at some other piece of hardware."

>>57170711

Then git gud and go the fuck outside.
>>
File: NeoPong.jpg (94KB, 1055x590px) Image search: [Google]
NeoPong.jpg
94KB, 1055x590px
Writing pong in ActionScript
Well, it's written, just fixing bugs because its the ultimate meme language.

Should i add multiplayer?
>>
>>57170821

>ActionScript
Why are you using this language in 2016?
>>
>>57170835
School
>It dosent matter what language you learn, they're all the same
Most retarded shit ever but its fine, an easy A
>>
File: kek.jpg (103KB, 917x592px)
kek.jpg
103KB, 917x592px
>>57170848
Tbh im beginning to like it, which scares me
>>
>>57170862

It's not so much that ActionScript is an absolutely terrible language, so much as the platform it runs on is absolutely shit.
>>
>>57170922
A lot of things are really easy in flash that would take me weeks or months to make in other game/media engines. I really wish we had a solid replacement for it. It should be possible now with canvas I think.
>>
>>57170922
Thats true, 5 crashes only today and even the .exe has security issues >_>

>>57170941
I mean... if you cant function without flash's handholding you should probably just stop
>>
Ruben is being rude. Holy shit something is wrong.
>>
>>57170982
Also, we're forced to use CS5.5 to get it covered by the school, which just makes everything worse.

Animate seems kinda ok desu
>>
>>57170982
Go make me one of those swirly screen transitions then you faggot. See how long that takes you with sepples and ncurses. It's not about handholding, it's about not spending an autismal amount of time on something that takes seconds to make with a different tool.
>>
>>57171007
What in the fuck was that curtail at the end? Do you subtract too?

Do you burn harder than fire or something
>>
>>57171007
>swirly screen transitions
>drawing shit
>cant into import assets
>possibly retarded
>>
JavaScript stronk
function qsort(n) {
return n.length === 1 ? n : qsort(n.filter((nr) => nr < n[0]).concat(n[0])).concat(qsort(n.filter((nr) => nr > n[0])));
}
>>
>>57171034
My eyes hurt
>>
>>57170941

Canvas and WebGL have been pretty decent for a while now.

>>57170982

Flash is pretty damn insecure. However, Mac OS X and iOS both had more vulnerabilities than Flash in 2015.
>>
int main() {
std::string inputpath;
std::string line;

std::cout << "Please enter the full path of the file: ";
std::cin >> inputpath;

std::ifstream inputfile(inputpath);

if (inputfile.is_open()) {
while (inputfile.good()) {
std::getline(inputfile, line);
std::cout << line << std::endl;
}
inputfile.close();
} else {
puts("Unable to open file.");
}

system("pause");
return 0;

}



Is there a better way of doing this /g/?
>>
>>57171034
it's sronk noob
>>
>>57171050
Thats hilarious
Someone should patch that bite out of the apple then

Arigato Ruby senpai
>>
>>57171054
>iostream throughout project
>puts() randomly on error
>program does not return on error
why mane
>>
>>57171054
Dro the close call, it'll close automatically because RAII.
Drop the system pause, it's completely unnecessary.

The rest is okay.
>>
>>57171091
was actually just messing with cstdio functions
>>
>>57171110
fair enough im just being a dick

std::cerr, btw
>>
>>57171034

It looks nicer in CoffeeScript:

qsort = (n) ->
if n.length is 1 then n
else qsort(n.filter((nr) -> nr < n[0]).
concat(n[0])).
concat(qsort(n.filter((nr) -> nr > n[0])))



>>57171054

First of all, remove the system("pause") from your program. That will improve it immensely.

Secondly, why are you using both puts and cout? Pick one.
>>
>>57171118
read
>>57171110

also what should I do to pause the console?
>>
>>57171054
You can simplify this a tiiiny bit.

#include <string>
#include <iostream>
#include <fstream>


int main(void)
{
std::string path;

std::cout << "path: ";
std::cin >> path;

std::ifstream in_file(path);

if (!in_file.is_open())
{
std::cout << "Unable to open file.";
return 1;
}

std::string line;
while (std::getline(in_file, line))
{
std::cout << line << std::endl;
}

return 0;
}
>>
>>57171127
You should not pause the console at all. Console programs are not like GUI programs. You don't want them to run indefinitely. You want them to do their thing and then return to the console that called them, preferably so they can be scripted together.
>>
>>57171165
The thing is I need to make sure my output is correct, so if I wanted to make sure of that what would be the best way to do this? In Visual Studio the console immediate closes as the program terminates (obviously) and I don't actually want that to happen.
>>
>>57171199
I believe if you use f5 and build from it, VS will pause. However, I find gets() works.
>>
>>57171225
sorry, getchar(), not gets().
>>
>>57170056
my hw: evaluating expressions using stacks. The expression has arrays and variables.

pretty fucking dumb
>>
>imperative programming
deprecated
>>
>>57171118
but coffeescript is dead desu
>>
File: like_this_retard.png (60KB, 1855x1056px) Image search: [Google]
like_this_retard.png
60KB, 1855x1056px
>>57171199

>I need to make sure my output is correct
You should be perfectly capable of checking the output of your program after it has terminated.

>In Visual Studio...
Start
Without
Debugging

Or for fuck's sake, learn how to use a goddamned command line. And I highly recommend this option unless you are being forced to use Visual Studio by, say, a class. See this? This is how you compile and run a fucking program. Do you see how the console has not closed out after the program was run? That's how console applications are supposed to behave.
>>
Which programming language are /dpt/ approved for building REST APIs? Scala, Python?
>>
>>57171263
calm down bro


ny
>>
>>57170175
>https://rosettacode.org/wiki/Sorting_algorithms/Sleep_sort

sleepsort←{{r}⎕TSYNC{r,←⊃⍵,⎕DL ⍵}&¨⍵,r←⍬}


I've seen some meme languages but holy shit
>>
>>57171263
nice font, my dude
>>
>>57171263
>comic sans tier font
>hacker green color
>capitalized host name
ahaha nigga u dumb
>>
>>57171297
how did i know that was APL
>>
>>57171322
(-⍵-)
>>
>>57171301
Thank you. That is Nova Mono. Found it on /dpt/, thought it looked nice, decided to use it for myself.

>>57171313
>hacker green color
It is easier for me to read than the default white on purple.

>capitalized host name
What is wrong with this?
>>
>>57171313
It's actually quite normal to capitalize the first letter of a host on a network.
>>
>>57171322
Because it's easy as shit to recognize
>>
Is there a way to write to an output file and to console in C++ without having to write multiple lines of code?
>>
I am trying Python out and it kinda blew my mind away that you do not have to define types of variables. And that you can have a HashMap consisting of entirely different items.

Is there even a way in strong-typed languages to create a HashMap that accepts multiple variables?

For example, Python allows:
items [
"Gold" : 500
"Weapon" : "Sword"
"Backpack" : "Health kit", "Map", "Strange Stone", 450
]


I have no idea to how to create something like this in Java.
>>
>>57171533
set your editor not to wrap text into a new line and make liberal use of whitespace and semi colons.
>>
>>57171533
You can always cram everything in one line of code, sempai.
What you probably mean is whether you can do it with one command. You cannot. You have to define the ofstream first, then write there second.
>>
>>57171548
That's not what I meant.
Lets say I want to cout a specific line of text to console but I also want to save that cout to a file at the same time. Is this possible?
>>
>>57171547
Yeah you think OH this is great, I don't have to type my variables anymore, and it is great, until you start making constants and large programs with lots of data and lots of input and lots of output, which means throwing everything through a billion checks and debugging the fact that '3' + 3.5 = 33.5 at runtime and is not a compile error, at least in JS.

ahh
>>
>>57171563

I do not believe that its "great" for every scenario. That is why I am asking how to do a HashMap that accepts multiple variable types in the first place, so I can do it in Java.
>>
>>57171560
write a function to do it then call that function every time
>>
>>57171560
./program | tee file.txt
>>
Whats the point of learning c when c++ basically has all of c?
>>
>>57171593
horrifying. but it works. horribly. god please don't do this
>>
>>57171603
What are you talking about?
That is the preferred way of doing it.
>>
>>57171596
Because you won't and should not be writing C in C++ all the time. A lot of C++ deprecates C and a lot of C++ is not okay or doable in C.
>>
>>57171596
Wouldn't that make it have more of a point?
You not only learn C but a chunk of C++ as well.
>>
>>57171609
Oh, if you meant from outside the program, yeah obviously. But inside the program you could technically do that sort of thing from inside a shell call.
>>
>>57171547
[("Gold", ["500"]),
("Weapon", ["Sword"]),
("Backpack", ["Health kit", "Map", "Strange Stone", "450"])
]


alternatively
https://hackage.haskell.org/package/multimap-1.2.1/docs/Data-MultiMap.html
>>
>>57171533

Write a utility function for it.

#include <iostream>
#include <fstream>
#include <string>

void write_twice(std::ostream& fst, std::ostream& snd, const auto& out)
{
fst << out;
snd << out;
}

int main(void)
{
std::ofstream foo("example.txt");
write_twice(std::cout, foo, "Hello World\n");
return 0;
}
>>
>>57171618
reread what i wrote, C++ is what im arguing for, and arguing against C
>>
>>57171699
Rereading your post, I only see you argue about what language to learn. And since learning C will improve your understanding of C++, your argument falls apart.
>>
>>57171547
>I have no idea to how to create something like this in Java.
HashMap<String, Object>
It's pretty simple desu.
>>
>>57171878

What I asked about was a HashMap that accepts multiple types of inputs.
Your HashMap accepts only Strings as first input.
>>
>>57172004
Your example only has strings as keys. I don't know why you would different-typed keys but nothing stops you from making a HashMap<Object, Object> either.
>>
>>57172016

Ah, so "Object" is a codeword for different-typed objects. I missed that, sorry.
>>
>>57172004
why would you like different object in a list?

>>57171626
looks like a 2d array
>>
>tfw no longer a NEET
we can all make it bros
>>
>>57170056

How do the DSL capabilities of Ruby, Haskell and Lisp (whichever dialect is best at DSLs) compare?
>>
>>57172034

How did you make it?
What were your prior qualifications?
What is your job now?
>>
>>57172034
You started Educating yourself about chinese cartoon porn?
>>
>>57172044
after 1 year of rejections after interviews
graduate with no experience
software dev in a .NET shop
>>
File: god damn.png (106KB, 1082x542px) Image search: [Google]
god damn.png
106KB, 1082x542px
So I'm putting together a live install media for Arch and it's got a lot of required packages to achieve desired functionality.
Is there an easier / cleaner way to pass the massive list of packages to scripts than this? I mean it works just fine, but god damn is it fugly as hell
>>
Ohayou, /dpt/.

Right now trying to understand why

if (rc.dec(release) == 1) {
fence(acquire);
free;
}


works for more than three threads.
>>
>>57172039
Haskell is the best, check this out

http://scrambledeggsontoast.github.io/2014/09/28/needle-announce/
>>
>>57172062

What did you graduate in?
What is your salary?
Congratulations.
>>
>>57172022
The way most OOP languages are made is that there is a base class that every class inherits from. In java that's the Object class. It has some built-in methods and stuff, take a look here: https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html
>>
Just made this:
http://pastebin.com/ynrMMLBT

File input:
Amarillo 3 2 1 3 5 -7
Rochester 5 6 7 4 6 -2
Albuquerque 3 4 5 2 3 -9
Durham 9 8 7 9 9 8 -4
Boise 3 4 6 2 8 9 -1
Jacksonville 2 5 2 1 5 7 2 1 1 -3
Lexington 8 9 12 3 4 10 11 -6
Tulsa 8 2 9 5 6 11 8 4 2 9 -1
San_Francisco 1 1 2 1 1 0 0 1 -8
Washington -3

Is there a cleaner/simpler way of doing this? Seems messy to me...
>>
>>57172089
#include <iostream>
#include <thread>
#include <vector>
#include <chrono>

int main() {
std::vector<int> input { 2, 3, 1, 0 };
std::vector<std::thread> threads;
for (auto n : input) {
auto thread = std::thread { [n]() {
std::this_thread::sleep_for(std::chrono::seconds(n));
std::cout << n << "\n";
} };
threads.push_back(std::move(thread));
}
for (auto &t : threads) {
t.join();
}
}
>>
>>57172089
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
int num;

for(int i=1; i < argc; i++) {
pid_t pid = fork();

if (pid == 0) {
num = atoi(argv[i]);
sleep(num);
printf("%d ", num);

return 0;
}
}
return 0;
}
>>
Would it be possible to add these two lines of code with assembly editing, or is assembly editing only for simple tweaks and deletions?

public static Equipment FC_AnchorCannon;
EquipmentManager.FC_AnchorCannon = new Equipment("Anchor Cannon", EquipType.FixedCannon, 1f, 2, AbilityManager.L_AnchorCannon, false, new StatModifier[0]);
>>
i watched a video interview with the creator of perl and he said that languages like java, perl are implemented in C or a similar language. what does that mean? at their most base level they are running C code?
>>
>>57172160
from the way you ask, no.
>>
I wrote a web scale implementation of sleep sort. What does /dpt/ think?

#include <stdlib.h>
#include <stdio.h>
#include <sys/epoll.h>
#include <sys/timerfd.h>

int main(int argc, char **argv)
{
int efd = epoll_create1(0);

for (int i = 1; i < argc; i++) {
int n = atoi(argv[i]);
int tfd = timerfd_create(CLOCK_MONOTONIC, 0);
struct itimerspec its = { .it_value.tv_sec = n };
timerfd_settime(tfd, 0, &its, NULL);
struct epoll_event e = { .events = EPOLLIN | EPOLLET, .data.u32 = n };
epoll_ctl(efd, EPOLL_CTL_ADD, tfd, &e);
}

while (argc > 1) {
struct epoll_event e;
epoll_wait(efd, &e, 1, -1);
printf("%u\n", e.data.u32);
argc--;
}
}
>>
>>57172132
Don't use `std::endl` so much. It doesn't just append a newline, it also flushes the buffer. every. single. time. Doing so before you're done is inefficient, use `cout << "\n"` instead and only flush when you want to be certain it went all out.

When #including library headers, use `<angle brackets>`. Quotes are for your own headers.

Learn what a function is, and define one to reduce some repetition. I'm sure you can look this one up.
>>
>>57172224
By that he meant that the compiler is written in C.
>>
>>57172224
Compilers are programs that turn bytes (of text) into other bytes (of executable code). Just because they are programmed in C doesn't mean they output bytes that represent C code.
>>
>>57172330
Cbytes are for serious programmers, like myself.
>>
>>57170056
I found the old thread if anyone wants to
>>
>>57172114
CS
around 50k usd
>>
>>57172084
Not exactly what I had in mind...
I'm skeptical of the benefits of ASCII programming, personally, though that is admittedly cool.
>>
File: like what the fuck man.png (6KB, 421x243px) Image search: [Google]
like what the fuck man.png
6KB, 421x243px
>>57172084
Fucking Haskell

Calm down with your dumb bullshit
>>
>>57172262
From the way I ask?
>>
>>57172224
1. Larry Wall is a god
2. A compiler is technically a translator, usually from a higher-level language to a lower-level language (most commonly to machine code), but even Java to Python is a compiler.
So when a compiler is written in C, it means that the program doing the translation was originally written in C.
>>
>>57172475
Not the anon you're responding to, but a snap judgement says you're not too experienced, and you probably shouldn't be injecting lines of code into already compiled assemblies.

Rebuild the assembly from source code with your desired modifications.
>>
Maybe I am already way too late, but I have already written the answer in the previous post:

When I am with C++ programmers they always want to convince me that C is just a subset of C++, that C++ is much more power, and that I can basically do the same things in C just like in C++.

I then usually tell them that I could switch to C++, but then they'd all start foaming from their mouths because I'd only use templates where I actually need it, which is almost never because the only usage for templates would be data storage structures, and for those I already have a somewhat fast and decent implementation in C. Otherwise I wouldn't give a fuck about templates, about exceptions, about static/const/dynamic/reinterpret casts, and it even makes my code compile slowly on g++.

In other words I am not switching to C++ not for my sake, but for others.

>inb4 maybe you just want yourself the discussions about using the wrong language

In my experience with C, there is no real wrong language, it's more about missing, non-retarded frameworks. Because nothing in C forces you to use dynamic memory or such. When I can't do task X in a reasonable amount of lines I program a module to do X in a reasonable amount of lines. That has nothing to do with the language.
>>
https://www.reddit.com/r/rust/comments/587ecn/looking_to_possibly_learn_rust_i_come_from_a/d8z7iqy/

really made me think
>>
>>57172565
I am a retard - meant to quote >>57171618, but forgot about that.
>>
>>57172574
get out
>>
File: Problem 6.png (37KB, 769x82px)
Problem 6.png
37KB, 769x82px
For this one, I wanna split the string by 2 and compare the left and right of the string. How would I make it so the string is divided in 2, and if the string is odd/even, then I'm guessing i'll need conditions for both. Any better way to implement this or will this work.
>>
>>57172574
so basically, people can get stockholm syndrome from using rust?
>>
>>57172662
You see people defending OOP in /dpt/.
>>
>>57170128
k
>>
>>57170258
>>57170128
>>57170080
We get it, you're gay.
>>
>>57172704
they normally don't sound like they were physically abused by the language, though
>you will get beaten by borrowck for unsafe habits, you will have to recite parametric trait mantras every day, and contemplate the Zen of lifetime and thread-safety. It will be initially painful, but it's a path to enlightenment.
>>
>>57172638
int palindrome(char *str, int n)
{
if (n < 2)
return 1;
if (str[0] != str[n - 1])
return 0;
return palindrome(str + 1, n - 2);
}
>>
>>57172638
A better way is to reverse the string and see if the to strings are equal

Reverse it recursively

Your way should work too, you just have find the middle (length/2 generally), reverse the second half, and compare it to the first half

You can also compare it char by char recursively like >>57172749 (forgot the function call)
>>
>>57172638
>C++
>return 1 or 0

I've heard of C with classes before, but damn!
Also, see >>57172749, you can't solve things recursively if you're stuck in an imperative mindset.
>>
>>57172776
what's the issue with that?
>>
I've heard that unsized types are evil for anything but bitfields. What does /dpt/ think?
>>
(fork&&die sleep$_)for@ARGV
>>
>>57172807
what are unsized types supposed to be? types whose size isn't known at compile time?
>>
>>57172837
Sorry I meant unsigned types.
>>
>>57172638
Did you manage to solve the one from yesterday?
>>
>>57172801
C++ has a bool type, C doesn't. Your problem has literally nothing C++-specific in it whatsoever, and calling for a "C++ function" when they don't even ask for a bool as a return type is retarded. They should have just asked for a C function.
>>
>>57172876
And panic all the noobs who think they've been learning c+ and don't know fuck all from c, in the process.
>>
>>57172807
size_t is unsigned and your best bet for sizes.
Whatever you heard is a piece of dog shite.
>>
>>57172922
Explain yourself.
>>
>>57172827

>perl
literally worst language desu
>>
>>57172841
I agree, but I'd go further and say that if you need a bitfield, use a bitfield, not an unsigned type. Define a bitfield and use the unsigned type as a necessary implementation detail, if need be.
>>
Class::staticMethod;
Class::$staticProp;
$this->prop;
$this->method;
self::staticProp;
self::staticMethod;

for
what
pvpose
>>
1. What would be the effect of the following sequence of calls to function order in C?
( Hint: Trace the calls for num1 = 8 , num2 = 12 , num3 = 10 .)
order(&num3, &num2);
order(&num2, &num1);
order(&num3, &num2);
>>
React vs Angular?
pros and cons?
use cases?
>>
I'm implementing RSA with biginteger as the type to use when encrypting bytes of the file, then I get the new byte array which is the encrypted file, but how would I go about reading it back in and decrypting the biginteger values since I don't know how big the bigintegers in the file are?
>>
>>57173014
/dpt/ or >>>/g/wdg?
pros and cons?
use cases?
>>
>>57173014
>>>/g/wdg
>>
>>57172876
that's how it's usually thaught, and i agree with it. I think C++ should be thaught as C with a few nice features like cout rather than printf. Once you understand the general concept you can move onto more advanced stuff like classes etc.
>>
>>57173031
>I think C++ should be thaught as C with a few nice features
hmm
>>
>>57173031
C++ should be taught like Java.
Prove me wrong.
>>
>>57173014
react is way better
>>
>>57172938
>Fast
>Flexible
>Rich
>Has great culture
>Concise
>Has long history
>GOAT creators
Stay Jelly pleb
>>
>>57173031
C++ should be taught like C++
https://www.youtube.com/watch?v=YnWhqhNdYyk
>>
>>57173014
Vue.js d00d, keep up!
>>
>>57173026
dpt pros:
cute traps
anime
'computer scientists'
wdg pros:
actually code programs
actually have jobs
'programmers'
>>
>>57172928
I already told you. unsigned types are used fucking everywhere (size_t, uintptr_t ...). Overflow is only sanely defined for unsigned types. Without unsigned types C would be several times less secure than it already is.
>>
>>57173031
No, it's fucking retarded. First of all, teach the damn difference between the two. Second of all, if you want a function of type
int(const char *, int)
and decide to make in a C++ function, you gain nothing while losing portability, because you now have a mangled name in the binary.

Why the fuck is actual learning treated like some sort of heretical idea?
>>
>>57173050
why?
I thought react only works on the View while Angular has more functionality than that out of the box.
>>
>>57173104
>Overflow is only sanely defined for unsigned types.
And that is good?
>>
>>57173061
HA
I cant keep up, I haven't even fully learned JS but I'm learning frameworks. I cant keep up even though im skipping over so much.
>>
>>57173104
C's not meant to be secure, it's meant to be fast. The problem is that people don't realize that.
>>
>>57172498
Easier said than done.
The decompiled version I have contains 1,112 .cs files, which I assume means C#.
I have absolutely no clue how to recompile them again, it'd probably require me to learn to use a new tool which would really suck.

But my question wasn't whether I should inject a line of code, it was if I could inject a line of code or if that was impossible with the tools for doing so.
IIRC, assembly editors can have some pretty specific requirements about how they're used.
>>
>>57173122
With sanely defined overflow you can actually CHECK for overflow easily via:

if(i + x < i)


because only in the instance of a sane overflow i + x is going to be SMALLER than i. Even if x were 0xFFFFFFFF FFFFFFFF, adding it to i is basically just a sane i - 1 < i, which meets the overflow case.
>>
>>57173143
I never argued that. I only said that without unsigned types it would be even less secure than it already is, which is not much to begin with.
>>
>>57173166
But 99% of operations are not overflow checks. Why would you use a type just because it has a useful property in 1% of the cases.
>>
>>57173174
But if less security allows for higher speed benefits, it's in the spirit of the language to trade off the security for speed.
>>
File: 1465639188844.jpg (135KB, 1066x1491px)
1465639188844.jpg
135KB, 1066x1491px
Which programming language should I pick up to get a code monkey job or at least be capable of doing some projects on stack overflow?

A friend of mine told me to do C++ since most commercial software uses that, and said it would be easier since its like C but basically OOP style, like Java. Is this true?
>>
>>57173193
>But 99% of operations are not overflow checks
You have never written a network protocol implementation or a parser. Overflow checks are all over the place there. I did it so often that I actually defined macros for checking overflows for various types.

Hell, gcc even has builtin functions to perform those checks as fast as possible. They make sure that you only have the operation, the check for overflow, and a conditional jump.

If you don't believe me, start writing your own HTTP server and prove me wrong. Protip: you can't. You really can't.
>>
>Current year
>Still people using Ruby
https://crystal-lang.org/
>>
>>57173143
>C's not meant to be secure, it's meant to be fast.
i disagree, C is meant to be simple(to implement) and fast. C++ is meant to be fast. The simplicity(and age) makes it easy to exploit bugs.
>>
>>57173216
>I want to be a code monkey
You don't. Learn Go.
>>
>>57173213
What are you even arguing about here? I never made the implication that C should be more secure. But without overflow checks it would be an incredible clusterfuck only to USE the language.

>>57173216
If code monkey is all you wanna be, Java or Python or Perl should be good for you.
>>
>>57173216
visual basic.
>>
>>57173216
C++ is not easy at all (but it is widely used).

Go for Python, JavaScript, C# or Java if you want to get hired. Stay away from C++ if you want an easy time. Also consider the niche. For iOS learn Swift instead, for Android there's no substitute for Java.
>>
>>57173238
>C++ is meant to be fast.

Bull-fucking-shit. Most STL containers do their own memory thing which is slow as hell (because they use new/delete). In fact, usage of new/delete is discouraged in more modern versions of C++, because "everything is supposed to be abstracted" - a.k,a. just do dynamic memory management in the background like fucking your concubine.

And it's not easy to fix with just overwriting new/delete, it's an conceptual error to have a globally link with all memory chunks being used for all threads.
>>
>>57173241
>I never made the implication that C should be more secure.
My mistake then.
>>
>>57173216
Java or C#.

C# is much more enjoyable to use than Java, for what it's worth.
>>
>>57173263
>for Android there's no substitute for Java.
Is this meant literally or figuratively?

Because i've been thinking i should learn a little about how to develop for android, but i hate Java.
>>
>>57173269
I meant "direct usage of new/delete". Of course new/delete is still used in an objects code, but you are not supposed to see that.
>>
>>57170572
That highlighting is just cancer.
>>
>>57173269
>Most STL containers do their own memory thing which is slow as hell (because they use new/delete).

Don't they all take allocators for customized allocation behavior? Like, to allow memory pools and such?
>>
>>57171034
"quicksort"
>>
File: 1476892072933.jpg (89KB, 700x780px) Image search: [Google]
1476892072933.jpg
89KB, 700x780px
>>57173025
Anyone? The language is C#.
>>
>>57173287
You can go for C#(Xamarin) or C++(NDK) instead, I guess, but you have to know Java in order to understand the official API documentation, and the NDK isn't fully-featured yet, I think.
>>
>>57173216
I'd recommend C++, but stick to mostly C features.
OOP makes things harder to understand at first.
>>
>>57173293
They do take default allocators, true.
What does new/delete? What does malloc/free? Reserving memory in such a way that you don't see HOW the memory is reserved from the runtime. Which often incorporates using multiple heaps for proper pooling and page alignments, and in the case of Linux also ways to tell the allocator on what thresholds they are supposed to do certain stuff (using hugepages, using entirely own mappings for allocations and such).

That's not different from what a C++ allocator does. It still does not fix the underlying issue that in the end, everything needs to be brought down to a global list of memory chunks. Per process, I should add.
>>
>>57173292
gookmoot and moot before him are incompetent, the code tags use Google's prettyprint js which can be passed a language name to get better highlighting than just the 'generic' syntax it does by default, but they're too lazy to add [code="Ada"] or whatever.
>>
>>57172084
QuasiQuoting is bad and you should feel bad.
>>
>>57173221
>You have never written a network protocol implementation
If you write network protocol implementations 99% of the time then be my guest and use unsigned types.
>Hell, gcc even has builtin functions to perform those checks as fast as possible.
And they work for signed types. So once again you've proven that there is no need to use unsigned types.
>>
>>57173269
Python is slow, in Java you can't even do you own memory allocation and it's generally regarded as relatively fast.
>>
>>57173227
>immature as fuck
>>
>>57173309
> C++(NDK)
Thanks for the tip. I'll look into it.
>>
>>57173344
C++ memory allocation is slower than Java. Java preallocates memory in large chunks, idiomatic C++ allocates small structures individually left and right and spends a lot more time waiting for the OS.
>>
>>57173380
doesn't that depend on your STL?
>>
>>57173380
>C++ memory allocation is slower than Java.
What did he mean by this?
>>
>>57171547
It's called dynamic typing. It's not the same as weak typing.

Static typing: value types are tied to variable names.
Dynamic typing: a variable name can reference a value of any type.
Static typing does NOT necessitate the programmer specifying variable type at declaration, or even necessity of declaration.

Strong typing: value types are not easily coerced between one another.
Weak typing: value types can more easily coerced.
Best example of weak typing is all that JavaScript '==' and '===' horror.
>>
>>57173227
>https://crystal-lang.org/
>That logo is actually a realtime 3d rendering
What the FUCK is wrong with gifs?
>>
>>57173331
No. Go for pure C if you want to avoid OOP.
>>
>>57173391
Are you stupid? He clearly explained what he meant by that in the next sentence.
>>
>>57173401
"no"
>>
>>57173399
B-b-b-b-but you can, like, drag it around and stuff! IN THREEEE-DEEE!!!!
>>
>>57173410
The implication is that he's talking out of his ass.
>>
>>57173341
Read the rest of the fucking post. Network protocol implementation was ONE example when to constantly check if you are still within your buffer.

>And they work for signed types.
While that is true, they are not available everywhere, which means that it's hard for programmers to implement their functionality for other operating systems.

>>57173344
That is because the Java VM performs its own memory voodoo magic which reuses memory constantly.
>>
>>57173414
SPINNAN POLYGONS
>>
>>57173428
The implication is that >>57173391 's face is an ass.
>>
>>57173389
I'm not a language lawyer, but I really doubt it, since the standard demands particular performance characteristics and I think potentially wasting memory with preallocations would fly in the face of that.
>>
>>57173399
    Have a syntax similar to Ruby (but compatibility with it is not a goal)
Statically type-checked but without having to specify the type of variables or method arguments.
Be able to call C code by writing bindings to it in Crystal.
Have compile-time evaluation and generation of code, to avoid boilerplate code.
Compile to efficient native code.


So it's literally Go?
>>
>>57173438
Before you ask: no, it's not applicable to C++, because the Java VM works in its own context. In Java memory can be exchanged between processes pretty easily without the kernel being notified ever. There is a reason why just starting the VM takes up several hundred MiB of memory.
>>
>>57173438
>Network protocol implementation was ONE example when to constantly check if you are still within your buffer
But there is absolutely no need to use unsigned integers for that.
upper_bound - cursor > delta
works just as well with signed types.
>>
>>57173460
>Have a syntax similar to Ruby
> without having to specify the type of variables or method arguments.
>COMPILE-TIME EVALUATION AND GENERATION OF CODE, TO AVOID BOILERPLATE CODE.

Do you even know what Go is?
>>
>>57173516
It's a meme language from google.
That's all there is to know.
>>
>>57173496
>stackoverflow.com/questions/16188263/

tl; dr; for C and C++ signed integer overflow is still undefined behavior. You might work around that with compiler builtins which know more about the overflow management on those machines, but just doing the check for i + x < i on signed values like this is UB.
>>
>>57173535
>but just doing the check for i + x < i on signed values like this is UB.
Apparently you can't read. There is no + in my post.
>>
>>57173520
Not funny. Crystal being in any way similar to Go is the stupidest thing I've read in a long time.
>>
>>57173535
In reality land, most machines use the two's complement, that's true. But UB does not only mean UB - it means that the compiler CAN, and in the case of GCC also HAS REMOVED those checks from the code, because "it was UB and therefore lost to the will of the optimizer".
>>
Which do you prefer ES6 or ES5?

function msgAfterTimeout (msg, who, timeout) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(`${msg} Hello ${who}!`), timeout)
})
}
msgAfterTimeout("", "Foo", 100).then((msg) =>
msgAfterTimeout(msg, "Bar", 200)
).then((msg) => {
console.log(`done after 300ms:${msg}`)
})


OR

function msgAfterTimeout (msg, who, timeout, onDone) {
setTimeout(function () {
onDone(msg + " Hello " + who + "!");
}, timeout);
}
msgAfterTimeout("", "Foo", 100, function (msg) {
msgAfterTimeout(msg, "Bar", 200, function (msg) {
console.log("done after 300ms:" + msg);
});
});
>>
>>57170125
>>57170138
>>57170209
http://bbs.progrider.org/prog/
>>
>>57173545
i + x < i is just another way to write upper_bound - cursor > delta, because cursor can be bigger than upper_bound. You have exchanged your overflow for an underflow. The fact remains that it's UB.
>>
>>57173561


-- declare BinTree a to be an instance of Show
instance (Show a) => Show (BinTree a) where
-- will start by a '<' before the root
-- and put a : a begining of line
show t = "< " ++ replace '\n' "\n: " (treeshow "" t)
where
-- treeshow pref Tree
-- shows a tree and starts each line with pref
-- We don't display the Empty tree
treeshow pref Empty = ""
-- Leaf
treeshow pref (Node x Empty Empty) =
(pshow pref x)

-- Right branch is empty
treeshow pref (Node x left Empty) =
(pshow pref x) ++ "\n" ++
(showSon pref "`--" " " left)

-- Left branch is empty
treeshow pref (Node x Empty right) =
(pshow pref x) ++ "\n" ++
(showSon pref "`--" " " right)

-- Tree with left and right children non empty
treeshow pref (Node x left right) =
(pshow pref x) ++ "\n" ++
(showSon pref "|--" "| " left) ++ "\n" ++
(showSon pref "`--" " " right)

-- shows a tree using some prefixes to make it nice
showSon pref before next t =
pref ++ before ++ treeshow (pref ++ next) t

-- pshow replaces "\n" by "\n"++pref
pshow pref x = replace '\n' ("\n"++pref) (show x)

-- replaces one char by another string
replace c new string =
concatMap (change c new) string
where
change c new x
| x == c = new
| otherwise = x:[] -- "x"



>pref pref pref pref

Is this what passes for good Haskell code? (Code is from Haskell Fast & Hard btw)
>>
>>57173227
Why would you want a syntax similar to the awful Ruby syntax?
>>
>>57173588
>because cursor can be bigger than upper_bound
No, it cannot unless there is a bug in your code.
>>
does js have range based array initializer, sort of like matlab? i want to write something like
 range = [n : n+m]
>>
>>57173595
>my opinion is objective truth
Acting like an autist is still a thing I see.
>>
>>57173380
>>57173269
>>57173336

https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/libsupc%2B%2B/new_op.cc?view=markup
new seems to just call malloc unless that fails(malloc returns a nullpointer), in which case a handler is called if defined, if not an exception is thrown.
>>57173459
>since the standard demands particular performance characteristics
since when do standards care about implementation details like performance?
>>
>>57173516
The syntax isn't similar to ruby I'll give you that. And you do have to specify the types of method arguments.

>COMPILE-TIME EVALUATION AND GENERATION OF CODE, TO AVOID BOILERPLATE CODE.
Literally any compiler does this. Unless it's badly stated and they meant something else.
>>
>>57173263
>for Android there's no substitute for Java

>he actually believes this
>>
>>57173623
>since when do standards care about implementation details like performance?
R U Sirius?
>>
>>57173611
>baww I wasted so much time learning an awful syntax so it must be good
>>
>>57173603
... as well as x cannot become large enough to trigger an overflow unless there is a bug. I am not willing to take that risk when it's that low-cost to avoid a security hole.
>>
>>57173659
Real smooth, you sound just like James Bond! I bet you get all the ladies too!
>>
>>57173670
Are you fucking retarded? You cannot control the value of x (delta) but you can easily control the invariant that the cursor always points below the upper bound of the buffer.
>>
>>57173659
>so much time learning
>Ruby syntax

Are you retarded?
>>
>>57173684
yes
>>
>>57173623
>new seems to just call malloc unless that fails(malloc returns a nullpointer)

Depends on the implementation. There is a reason why you are not supposed to get dynamic memory with malloc() and free it with delete. Even if they do the same internally they wanted to make sure you are in UB land if you dare to do so.
>>
>>57173652
yeah, i'd be happy to be proven wrong though.
standards have to be very general, i can come up with my own special snowflake ISA where you, say, can't do addition in hardware, meaning that performance of everything involving addition becomes terrible. A better example might be branching, i believe there are plenty of architectures where branching is extremely slow.
>>
>>57173675
If by ladies you mean Ruby fuccbois then yes.

>>57173684
Time goes so much slower when you learn awful languages.
>>
>>57173642
if you're going to act like an ass, at least be constructive about it
>>
daily tip: coding isn't the same as programming
>>
>>57173761
coding == programming == scripting
>>
>>57173711
>Even if they do the same internally they wanted to make sure you are in UB land if you dare to do so.
of course, the point was that performance should be similiar, not that they're equivalent.
>>
>>57173766
>delusional codemonkey
>>
>>57173712
It depends on the aim of the standard, doesn't it? If you want a language that has certain performance guarantees across implementations, how would you approach the problem? In any case, this isn't up for debate in the case of C++. Look up the <algorithm> specification, sometimes it even provides different guarantees for the same function template, based on the iterators you pass to them.

>>57173724
We get it, you hate Ruby, mommy didn't love you, no one cares, fuck off to tumblr if you want attention.
>>
>>57173761
I agree. Coding means using secret codes to pass messages to your treehouse buddies. Programming is the real stuff, like HTML.
>>
>>57173777
computer scientist == script kiddie == coder == programmer == architect == cuck
>>
>>57173683
Unless delta becomes negative, in which case upper_bound - cursor can substitute a negative value (and even with upper_bound and/or cursor being unsigned that generates a big value). If delta is an even bigger value or even signed it can easily cause the check to be bypassed.
>>
>>57173803
woah.... we got a HTML programmer in here.

let me guess you're a 4 spaces tag indentation type of guy.
>>
Should I be using jquery if all im doing is DOM manipulation and event listeners?
>>
>>57173811
delta does not become negative.
>>
>>57173830
I don't see why not, as long as you use a CDN. Most people probably have it in their caches already.
>>
>>57173008
would this be
8, 12, 10
12, 8, 10
12, 10, 8

assuming that order() function is a two value sort of some kind
>>
Technically, coding == writing
>>
>>57173854
thats true. Thanks kind anon.
>>
>>57173869
NO, THAT'S FUCKING WRONG! CODING IS TYPING, WHO THE FUCK IS STILL USING PEN & PAPER TO WRITE CODE?
>>
>>57170821
Local or online multiplayer ?
>>
>>57173805
I agree because I'm chemist
>>
>>57173903
cucks in here be 100% NaCl
>>
Is APL worth learning? even just for education?
>>
>>57173842
How do you know? Didn't you just say before that you cannot control delta? Didn't I say that this scenario even works with cursor being bigger than upper_bound, because it can cause an underflow that is still within the range of delta (all being unsigned values there)?

You need to have some sort of overflow/underflow check there, and that check is done either with builtins which may or may not be available everywhere, or manually. And if you need to do it manually - and that's everywhere there's no GCC - you wanna use unsigned types.

Anyways, why not using unsigned types? Is there any valid reason not to, other than being a lazy ass? Some CPUs are even faster with unsigned calculations only, because the carry flag can slow down the CPU.
>>
>>57173915
Go for J instead, imo. APL's charset choice is painful to get used to.
>>
>>57173898
both
>>
>>57173930
>How do you know?
Because you either sanitize your inputs or have a precondition that delta is not negative.
>>
>>57173930
>Is there any valid reason not to, other than being a lazy ass? Some CPUs are even faster with unsigned calculations only, because the carry flag can slow down the CPU.
Signed integers are obviously much faster because the compiler has more freedom to optimize.
>>
>>57173937
what if I like being a masochist and a memer?

(I'll look at J anyway)
>>
>>57173948
>Because you either sanitize your inputs
>which is totally not more complicated than just using unsigned types and use simple overflow checks

I rest my case.
>>
>>57173898
I would shoot for it.
>>
>>57173859
?
>>
>>57173954
>the compiler has more freedom to optimize.
how so?
>>
File: Problem 2.png (44KB, 487x311px) Image search: [Google]
Problem 2.png
44KB, 487x311px
>>57172847
I got close but I'll ask the professor later. I'm just gonna try to figure out how to do this problem and call it a day.
>>
>>57173990
Because it does not have to guarantee fix width wrapping behavior wtf.
>>
>>57173956
Not him, J is more than enough memey

For example:
   ' *' {~ '1' = (- |."_1 [: ": 2 | !/~) i._16

should generate Sierpinski's triangle
>>
>>57174013
and that's likely not obfuscated, J just looks like that.
>>
>>57173956
APL and J are by the same author (J is newer). Go with whichever.

Disclaimer: My recommendations are informed by the priorities of common people and may not apply to each and every anonymous person on 4chan, depending on their gender, age, height, weight, beliefs, race, sexual preferences or various other criteria that may set them apart from general population.
>>
// Keyboard handling sucks


Is this appropriate language for a public GitHub repo or a professional environment?
>>
>>57173954
Not true. Even if we do not take the carry flag into account there are optimizations that can only be used if no negative values are allowed. One is multiplication/division by 2, 4, 8 ... and so on, those can be easily optimized into bit shifting operations. Others are really obscure number hacks (dividing by 10 by multiplying with 0xcccccccd, then left shifting the result).

And there were some Intel and AMD CPUs which actually had problems with carry-flag additions. Although I admit that was a long time ago.
>>
From my previous post: >>57168660

Here is a pseudo-code of my dream language:
axiom {
0, 1
S(0) -> 1 # Successor function
S(n) -> n + 1
n = n
n < S(n)
}

set N{
a + 0 -> a
a + 1 -> S(a)
a + b -> a [+ 1]b
}

set [0, b[ of N {
x >= 0
x < b
}

set Color {
(r, g, b) in [0, 256[
red := (255, 0, 0)
}

import IO.Canvas
Canvas(x, y) := Color.red #Color everything in red, just an example
>>
>>57174048
s#left shifting the result#right shifting the result#
>fix'd
>>
>>57174045
Only as long as you don't spell it as 'suxxx'
>>
>>57174065
what if i spell it with just one x?
>>
>>57174060
There is a reason why mathematicians shouldn't touch code.
>>
>>57173227

Crystal is cool, if they will make it into industry I will join it. But at the moment there are many jobs for Python/Ruby/wahtever devellopers and zero jobs for Crystal devs.
>>
>>57174083
What do you mean?
>>
Been toying around with Selenium for some stuff at work in Python using Firefox. It was working exceptionally well and I actually wanted to make a small automation thing for it but I accidentally updated Firefox. Apparently Mozilla is kicking up dirt with version 49 with marionette and geckodriver, there are a couple of flagged issues and a SO answer that pretty much says "they fucked it". Is chromedriver less fucky?
>>
>>57174013
>>57174026
>J is newer
that sells

so, any good physical tutorial books? or are they all in pdf format
>>
>>57174048
>Not true.
Oh really.

unsigned char f(unsigned char *p, unsigned i)
{
unsigned char res = 0;
res += p[i + 0];
res += p[i + 1];
res += p[i + 2];
res += p[i + 3];
res += p[i + 4];
res += p[i + 5];
res += p[i + 6];
res += p[i + 7];
return res;
}

unsigned char g(char *p, int i)
{
unsigned char res = 0;
res += p[i + 0];
res += p[i + 1];
res += p[i + 2];
res += p[i + 3];
res += p[i + 4];
res += p[i + 5];
res += p[i + 6];
res += p[i + 7];
return res;
}


f:
leal 2(%rsi), %eax
leal 1(%rsi), %edx
movzbl (%rdi,%rax), %eax
addb (%rdi,%rdx), %al
movl %esi, %edx
addb (%rdi,%rdx), %al
leal 3(%rsi), %edx
addb (%rdi,%rdx), %al
leal 4(%rsi), %edx
addb (%rdi,%rdx), %al
leal 5(%rsi), %edx
addb (%rdi,%rdx), %al
leal 6(%rsi), %edx
addb (%rdi,%rdx), %al
leal 7(%rsi), %edx
addb (%rdi,%rdx), %al
ret

g:
movslq %esi, %rsi
movzbl 2(%rdi,%rsi), %eax
addb 1(%rdi,%rsi), %al
addb (%rdi,%rsi), %al
addb 3(%rdi,%rsi), %al
addb 4(%rdi,%rsi), %al
addb 5(%rdi,%rsi), %al
addb 6(%rdi,%rsi), %al
addb 7(%rdi,%rsi), %al
ret


Hmm would you look at that.
>>
I'm new to git.
How do i check if it's safe to push my commits?
>>
>>57174149
If it's not "safe", because someone pushed before you, then git will reject your push.
>>
>>57174045
>sucks
>sexual innuendos
You're gonna get banned from github, you know?
>>
What do you think about Elixir?
>>
>>57174137
https://www.youtube.com/watch?v=yG1OZ69H_-o

unsgined intergers with undefined overflows when?
>>
>>57174112
I have seen lots of mathematicians writing code, and "Ragnarok" does not even begin to describe the quality of such code. And then I often hear that computers are so strict with their rules, and they wish that everything was much less strict.

And your code reminded me of that attitude.
>>
>>57174208
Wtf don't link that. Now I can no longer claim that I came up with this myself.
>>
>>57174199
elixir is a cool guy.
>>
>>57174168
In that case how do i handle the conflict?
How does 'pull' handle the conflict?
>>
>>57174199
Sounds like the name of an anime girl.
>>
>>57174236
cherry picking.
>>
>>57174137
Doesn't prove anything. A division by 10 is several times shorter and several times slower than the aforementioned hack.

Make a benchmark of your codes and show me which one requires more cycles, THEN we can talk.
>>
>>57174236
git pull?
>>
>>57174246
What?
>>
>>57174247
>Unsigned using twice as many instructions doesn't prove anything.
Hmm ok.
>>
>>57174250
no you idiot.
git pull doesn't solve conflicts.


>>57174261
git cherry picking. look it up.
>>
>>57174060
you can't make essentially lisp better than lisp, so just use lisp
>>
>>57174219
Those mathematicians forgot they're on a Turing machine.
>>
>>57174247
Also, when I compile the code with -O3, f is actually shorter than g.
>>
>>57174265
>git pull doesn't solve conflicts.
Of course it doesn't.
It tells you that you have confilct, you resolve them and then you can push.
>>
>>57174265
thanks
>>
>>57174264
>has no idea how CPUs work
Please go away.
>>
>>57174289
>>how do i resolve conflict?
>by checking if you have a conflict, and then resolving it
T-thanks?
>>
>>57174279
>implying they ever cared enough to actually forget about it
>>
What do you think of my table structure for simple todo list (pseudocode)

Task
- id
- Title (140 chars)
- Body (140+ chars)
- Due Date
- Date Created
- Date modified
- Status (0 - not done, 1 - done)

TaskList
- list_id
- task_id
- title (140 chars)



Also, whats your opinion of SQL ?
>>
>>57174267
Lisp defines lists, not sets and it doesn't give the opportunity to define operations between elements.
>>
>>57174311
It's literally the same number of addb instructions plus a bunch of useless leal instructions, of course it's slower.
>>
>>57174219

This.

>writing code for "graph algorithms" in groups of three
>team up with 2 physicists
>"hurr, coding is easy, we've once written a C programm"
>they keep on making stupid mistakes, using wrong/bad abstraction, wrong data structures and so on
>I end up doing the coding all by myself because they "have so much stuff to do at the moment" and can't be bothered with trivia like this

Bascially the more academic, the more experience, the better. There are people out there (without any programming experience) who unironically think they are better programmers than a web develloper with 10 years expereience, because they can prove some theorems.

But math and programming just aren't the same, in fact they are often contradicting each other. In math you need no testing, because there are no mistakes, no physical signals that can get lost and errors you need to handle. Programming is much more like engineering, it's not about about the 100% correct answer, it's more about the right questions.
>>
>>57174320
Oops wrong code

Task
- id
- Title (140 chars)
- Body (140+ chars)
- Due Date
- Date Created
- Date modified
- Status (0 - not done, 1 - done)
- list_id

TaskList
- list_id
- title (140 chars)
>>
>>57174311
http://lmgtfy.com/?q=resolving+git+conflicts
>>
>>57170056
>>57171034
>>57171642
>>57172066
>>57172148


How do you even get to levels like this - when 95% of my code is shitty if/then else statements and a few functions here or there.
>>
>>57174130
>Physical tutorial books for meme languages
I doubt there are even any good pdfs around

https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#j
>>
>>57174375
Practice, practice, practice.
And reading other people's code also helps.
>>
File: firefox_2016-10-21_16-45-38.png (17KB, 1209x274px) Image search: [Google]
firefox_2016-10-21_16-45-38.png
17KB, 1209x274px
>>57174064
no, see pic related
this is gcc 6.2, clang emits similiar, icc looks slightly different but isn't much shorter either
http://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,options:(colouriseAsm:'0',compileOnChange:'0'),source:'%23include+%3Cinttypes.h%3E%0A%0Auint32_t+mod(uint32_t+a)%0A%7B%0A%09return+a+%25+4%3B++%0A%7D%0A%0Aint32_t+modsigned(int32_t+a)%0A%7B%0A%09return+a+%25+4%3B++%0A%7D%0A'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g62,filters:(b:'0',commentOnly:'0',directives:'0',intel:'0'),options:'-O3'),l:'5',n:'0',o:'%231+with+x86-64+gcc+6.2',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4
>>
>>57174377
I found "play with J" on lulu
might try that
>>
>>57174341
>There are people without any programming experience who think they are better programmers than a web develloper with 10 years expereience
They're not wrong though.
>>
How can I make this simpler without writing any of my own functions? I know that I can write functions that make my task here easier but I don't think I'm allowed

http://pastebin.com/S2Y4N2D0

Input:
Amarillo 3 2 1 3 5 -7
Rochester 5 6 7 4 6 -2
Albuquerque 3 4 5 2 3 -9
Durham 9 8 7 9 9 8 -4
Boise 3 4 6 2 8 9 -1
Jacksonville 2 5 2 1 5 7 2 1 1 -3
Lexington 8 9 12 3 4 10 11 -6
Tulsa 8 2 9 5 6 11 8 4 2 9 -1
San_Francisco 1 1 2 1 1 0 0 1 -8
Washington -3


I took another anons advice here and stopped using std::endl; so much.
>>
>>57174355
Pretty basic stuff, I don't see any issues.

I was going to respond to your last post and call you a retard (constructively), but you fixed it.
>>
>>57174320
>>57174355

Try YAML

> SQL
A great computation model hidden underneath a hideous, poorly supported syntax (ie every implementation has its own dialect).
>>
>>57174401
Read my post:

> Others are really obscure number hacks (dividing by 10 by multiplying with 0xcccccccd, then left shifting the result).

This code:

uint32_t mod(uint32_t a)
{
return a / 10;
}

int32_t mod_signed(int32_t a)
{
return a / 10;
}


Results into:

<mod>:
mov eax,edi
mov edx,0xcccccccd
mul edx
mov eax,edx
shr eax,0x3
ret

<mod_signed>:

mov eax,edi
mov edx,0x66666667
sar edi,0x1f
imul edx
sar edx,0x2
mov eax,edx
sub eax,edi
ret


I fail to see your point.
>>
>>57174302
No that's you.
>>
>>57174479
YAML the config language?

>>57174464
Cool beans your stamp of approval gives me confidence.
>>
/!\ A L E R T /!\

New thread

>>57174526
>>57174526 >>57174526
>>57174526 >>57174526 >>57174526
>>57174526 >>57174526
>>57174526


/!\ A L E R T /!\
>>
File: file.png (56KB, 666x209px)
file.png
56KB, 666x209px
Anyone else use atom? Trying to run using the script package in atom, for python, but "py -2.7" to switch to python 2.7 isn't a... recognized command.

Sure thing, atom, sure thing. Just gonna fucking tie this noose, here.

Fuck you too, SDL2 and libtcod
>>
>>57174521
>YAML the config language?
spotted the pjaeet
>>
>>57174427

But they are wrong.

Software doesn't automatically jumps out of your ass just because you are smart. It's like a profession, like art.

Every painter (no matter how gifted) will create 1000 pictures that are shit before getting decent. No exceptions. Same rule applies for programming.
>>
>>57174558
>webdev
>>
>>57174060
your syntax is retarded.
>>
>>57174536
How do you query YAML flat-files, Sven?
>>
>toying around with evolution, watching little pixels learn to move as they think their inscrutable thoughts by writing to an array that is really just a ridiculously complicated way of deciding what action they take
>realise I can't think of any good way to decide which should reproduce

Maybe I should go for paper-scissors-rock and have three types of dots.
>>
>>57174320
org-mode
>>
>>57174533
>windows
>atom
kek
>>
>>57172033
it's not, it's a map to a list

the map is represented as a list of key-pairs
>>
>>57173626
They mean macros. The 'generation of code' they're referring to is not opcode but Crystal.
>>
File: 1430637301289.jpg (18KB, 500x375px) Image search: [Google]
1430637301289.jpg
18KB, 500x375px
>>57174341
>web develloper
>develloper
Still?
>>
>>57173579
I know about this place, it would be nice to have /prog/ and some other textboards on 4chan though.
>>
[code="Ada"]
Whatever'Image
X := 'w';
T := "wew"
[/code]
>>
>>57174322
you are actually a clueless moron/mathematics student who has never touched anything beyond MATLAB (it just werkz) in their life.

1. lists can be shoehorned into being sets. efficiently implementing sets is usually done through some sort of tree since O(n) membership checking is ass. most Lisp dialects support treating lists as sets.
2. define operations between elements? what does that mean.. do you mean infix operators or something?

reader macros can implement infix operators. the point of prefix notation is to make shit easier to parse, even if complex equations end up looking a bit ugly.

if you want to see some sort of computer algebra system that boils down to Lisp go look at Maxima or something
Thread posts: 370
Thread images: 16


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