[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 341
Thread images: 42

File: ada-lovelace-20825279-1-402.jpg (284KB, 1200x1200px) Image search: [Google]
ada-lovelace-20825279-1-402.jpg
284KB, 1200x1200px
Previous thread: >>60753596

What are you working on, /g/?
>>
File: 1496117242416.gif (384KB, 500x283px) Image search: [Google]
1496117242416.gif
384KB, 500x283px
>>60765457
Rewriting Rust in Presburger arithmetic.
>>
>>60765457
Second for both Rust and C suck
>>
>>60765457
How would ada feel about revisionist feminists disregarding her (dubious) contributions to mathematics and misrepresenting her as the inventor of programming?
>>
>>60765457
What does this image have to do with programming?
>>
>>60765536
Absolutely nothing. It's just some bitch.
>>
File: dlang_chan.jpg (70KB, 349x368px) Image search: [Google]
dlang_chan.jpg
70KB, 349x368px
Threadly reminder that dlang-chan has RAII; she's quite fast in execution and compilation; and she's super duper cute! Say something nice about her, /dpt/!
Also, Andrei's a cool guy.

>Tour
http://tour.dlang.org/
>Books
https://wiki.dlang.org/Books
>GC
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
https://wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes
>>
>>60765457
Working on that thicc ass, if you know what I mean
>>
haskell!
>>
Do you guys watch any programming YouTube channels?
>>
>>60765702
programming videos are boring
the ones made by people who actually have any skill run way too fast and you gain nothing.
>>
#include stdio


struct llist[T] {
//_ means it's only visible inside llist and doesn't affect identifier
struct _lnode {
T data;
lnode *next;
};
lnode* head;
void append(llist* this,T x) {
lnode *current = this.head;
while(current.next)
current++;
lnode *temp = new lnode;
*temp = x,nil;
current.next = temp;
}
T operator[](llist* this, int at) {
//muh unsafe, don't care
lnode *current = this.head;
for(int i = 0; i < at; i++, current++)
;
return current.data;
}
lnode *operator++(lnode *n) {
n = n.next;
return n;
}
};
//it would be more readable to keep everything out of struct, but I wanted to remark the type relation of polymorphic type between //llist[T] and llist::append(T)

void main() {

llist[int] x;
x.append(1);
//equivalent to append(&x, 1);
x.append(7);
x.append(10);
int y = x[2]; //y = 10;

}


Give me feedback, /dpt/. I'm looking for simplest and most elegant possible form. It's meant to be a C-like language.
>>
I have a problem that I am trying to solve:

>10 columns of varying height
>30 pieces make up those 10 columns
>find the order of those pieces to fill those columns

This is not homework, it's for my house. At the moment I am doing this by randomising the pieces and just checking if they fit. But is there a better system?

My code is here:
https://pastebin.com/Y3gjiDp
>>
C++: When to use pointers over references and vice-versa for passing stuff around between functions?
>>
>>60765785
Pointers only useful when passing arrays/objects across.
>>
>>60765785
Reference is cleaner but you don't have pointer arithmetic.
>>
>>60765457
Im thinking of making a simple launcher for some of my games. Whats the easiest way of launching an exe on Windows with java or C#?
>>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
char *wires[3] = {"blue", "red", "white"};

int index = 2;
int swap_index;
char *tmp = NULL;

/* Fisher-Yates shuffle algorhitm */
while(index > 0) {
/* Seed the pseudo-random number generator
* with processor time used by the program */
srand(clock());
swap_index = rand() % (index + 1);

if(swap_index != index) {
tmp = wires[index];
wires[index] = wires[swap_index];
wires[swap_index] = tmp;
}

index--;
}

char *buffer = NULL;
int read;
size_t len;
int i = 0, j = 0;

/* Game narative :) */
printf("\nA terrorist has planted a bomb, and your mission is to defuse it!\n");
printf("As you study the bomb you conclude that there are three wires to cut: red, blue and white.\n");
printf("Cutting them in the right order only will it defuse the bomb.\nGood luck!\n\n");

while(i < 3) {

read = getline(&buffer, &len, stdin);

/* Because getline takes the newline character into the buffer,
* it's cleaner to remove it from our string when comparing it
* with the values in the array */
while(buffer[j] != '\n')
j++;
buffer[j] = '\0';
j = 0;

if(strcmp(buffer, wires[i]) == 0) {
if(i == 0)
printf("Wheew.. cut the next wire?\n\n");
if(i == 1)
printf("Whoow.. one more wire left!\n\n");
if(i == 2)
printf("THE BOMB WAS DEFUSED AND YOU ARE THE HERO OF THE DAY!\n\n");
i++;
continue;
} else {
printf("\nBOOM! (the bomb explodes with massive blast radius and many victims...)\n\n");
break;
}
}

return 0;
}

You may compile it on a gnu/linux system using the gcc compiler
also https://www.youtube.com/watch?v=xxcZRrpicGU
>>
>>60765766
>https://pastebin.com/Y3gjiDp

Page is removed.
>>
>>60765766
paste no workie
>>
>>60765870
>>60765766
>>60765879
Shit sorry guys, missed an i!

https://pastebin.com/Y3gjiiDp
>>
>>60765457
You started the thread without anime again, god bless my friend.
>>
File: TFpsJOx.webm (2MB, 800x600px) Image search: [Google]
TFpsJOx.webm
2MB, 800x600px
Messing with raymarching in GLSL
>>
File: 1472874369123.jpg (24KB, 540x533px) Image search: [Google]
1472874369123.jpg
24KB, 540x533px
name that site

>how do I do X in this language?

>no you don't. You want to do Y. Use third party libraries A,B, and C.
>>
>>60765965
Stackexchange.
>>
>>60765457
>tfw no cute countess bae to fuck around with babbage machines
>>
holy shit john carmack replied to me on twitter
why am i being so fucking gay about this
>>
>>60766085
He's an idiot.
>here let me just violate software patents from my previous employer
>oops i got caught
>google "how do I format hard drive"
>defendant was caught GOOGLING "how do I format hard drive" before evidence was subpeona'd.
>>
File: 1483728530994.jpg (96KB, 1440x900px) Image search: [Google]
1483728530994.jpg
96KB, 1440x900px
>>60766111
he's worshiped for making games back when they could be made by two people and didn't require a team of dozens of professionals
what did you expect?
>>
>>60765965
dumb frogposter
>>
File: gamedev.png (30KB, 561x108px) Image search: [Google]
gamedev.png
30KB, 561x108px
>>60766085
tell him to join us at 4chan.org/g/dpt !
>>
How come when I do something stupid like
list(itertools.permutations('"insert 100 digit long str", 8))
and it starts eating up all my RAM and starts swapping, mashing Ctrl+c doesn't abort and it continues building the list and causes kernel panic?
>>
>>60766218
ctrl+\
>>
>>60765299
I don't really know what you mean by pieces but it sounds like it might be an instance of the knapsack problem:
>https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_algorithms_01_knapsack.htm

If so then one solution is:
1. Sort the objects by ratio of value to weight
2. Repeat until the knapsack overflows:
Remove highest value-to-weight object from set, and place entirely in knapsack.
3. Take out the last object placed in knapsack, and slice off just enough to fill
knapsack.
from P. 4 of the architecture of symbolic computers
>http://libgen.io/ads.php?md5=7B60D3F530EC04E64236BE737D706053

It also might be similar to the counting change program in SICP:
>https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.2
>>
>>60766135
>and didn't require a team of dozens of professionals
they still dont need this.
Croteam make AAA games at a fraction of the people.
>>
>>60766218
>why does it eat up my ram
you are trying to generate a list of length 7,503,063,898,176,000
>mashing Ctrl+c doesn't abort and it continues building the list and causes kernel panic?
kek, python sucks I guess?
>>
>>60766252
um
https://youtu.be/52sqUj6JEWc
>>
>>60766231
It is, and I'm aware of the knapsack problem. But I am not sure how to implement that in multiple instances.

I can not cut the pieces at all.

Effectively think of a column. That column is say 10 units high. I have a variety of pieces that are say, 2 units, 3 units, 4 units and 5 units.

I want to randomise those pieces and try and fit it. Maybe first time I take 2, 3, 4 which gets me 9, but the 5 unit piece will make it way too big. That 5 unit piece will become the first part in column 2.

So at the end, it'll be incorrect. So now I go ahead and randomise things round, this time getting 5, 2 and 3, which is correct for column 1, and unit 4 becomes the first part of column 2,

I have 11 columns though and 32 pieces that should make those columns.
>>
File: anonimous.jpg (46KB, 600x600px) Image search: [Google]
anonimous.jpg
46KB, 600x600px
>>60765457
Talking about our Lovely Countess, I asked myself some questions today, and I realized I couldn't answer them because I do not have enough knowledge of...
... the history of computers.
What's a good book or source to learn from?
>>
>>60765702
handmade hero

time to time i search for "postmortem game"

also like to watch dev timelapse. for example https://www.youtube.com/watch?v=N8elxpSu9pw
>>
>>60766306
Most of those are irrelevant to the core game. Their team is still smaller than most though.
>>
>>60766334
Seconding this
Any books anons?
>>
>>60765549
I preferred the old Dlang-chan.
>>
>>60766315
to cut down your search space, consider the following: every solution must have one column with length 285.5. how many ways are there to generate a column of length 285.5? when you're done with that, what pieces remain? how many ways are there to generate a column of length 281.5 from the remainder?

right now your search space is 30! = 265252859812191058636308480000000 which is rather large. oh by the way, ints cant ever become larger than 10000000000000, google "max int size"
>>
>>60766334
The Devil's Dictionary by Ambrose Bierce
>>
>>60766338
what I dont like about these videos is how fast they are and how no mistakes are made. they programer seems to have the implementation preplanned and essentially has a macro run to generate the text file
>>
>>60765536
She's on the Build Your Own Lisp cover.
>>
How do I write GTK applications without using an IDE?
>>
>>60766635
Using a text editor.
>>
>>60766489
>Lisp
What does that have to do with programming?
>>
>>60765785
Prefer references if possible. Only use pointers when somehow needed. Unlike pointers, references don't have a null value, which is a useful guarantee to have. If your object does have a natural 'null' or 'invalid' state, then pointers might be a better fit.
>>
>>60765735
>#include
>>
>>60766739
>object
And what if I'm not retarded?
>>
>>60766736
Lisp is the most powerful programming language.
>>
>>60765927
that's fucking awesome, i really need to learn GLSL
>>
>>60766772
First of all, what is a "powerful programming language"? And why is Lisp a "powerful programming language"?
>>
>>60766766
Are you saying only retards use 'objects'?
>>
>>60766842
I don't know, you tell me.
>>
>>60766813
Because programming is disgusting shit, programming languages range in quality from worse than shit to shit. Lisp is the most powerful programming language, which means that it is equal to shit quality. All other programming languages are worse than shit.
>>
>>60766842
Welcome to /dpt/ where hating on OOP makes you look cool and edgy.
>>
>>60766880
>hating on
>cool and edgy
>>>/v/
>>
>>60766870
>Lisp is the most powerful programming language, which means that it is equal to shit quality
Assuming being powerful is actually an indicator of quality.
And you didn't explain what it even means for something to be "powerful".
>>
>>60766918
Wrong.
>>
>>60766796

This is a great starting point for doing so, although is still being made.

https://thebookofshaders.com/
>>
programing challenge!

only using addition, subtraction, multiplication, and division, write a fucntion that can compute a square root to n decimal digits of accuracy

For example:
>sqrt(9, 0)
3.1
>sqrt(9, 1)
3.01
>sqrt(9,2)
3.001


please do it in your favorite programing language. thank you and have a good day!
>>
>>60766994
cheers
>>
File: 1495671485246.jpg (39KB, 800x800px) Image search: [Google]
1495671485246.jpg
39KB, 800x800px
>>60766955
Makes you wonder, eh?
>>
>>60767067
t. brainlet
>>
File: nani128.jpg (46KB, 600x600px) Image search: [Google]
nani128.jpg
46KB, 600x600px
What's it like reading programming materials and documentation in other languages?
Does your language have native equivalents for all those computing terms, or do they keep defaulting to english loanwords?
>>
>>60767236
Most mathematical terms come from French or German so it's not too hard translating the new ones. As for the more practical stuff, I could describe how the Linux OS works in French but probably would still use English terms in the mix since I'm not that used to use those from my language. So yeah, they have native equivalents but are not always used in non-formal settings.
>>
>>60767236
>have native equivalents for all those computing terms
for a lot of them, da
>>
>>60767017
your code is retarded. in your examples you input n as an argument and get n+1 decimal spaces... you tell it squareroot 9 with 2 decimal places and you get squareroot 9 with 3 decimal places.

Also, square root 9 is not greater than 3.

Easy solution in python
def OP_Is_Faggot(x,n):
return str(x**0.5)[:n+2]


>>> OP_Is_Faggot(3,3)
'1.732'
>>> OP_Is_Faggot(13,7)
'3.6055512'


>>
>>60767017
to be clear, you can be more accurate than n if you wish
>>
>>60767415
you need to be accurate to the nearest 10^n, so the first n digits must be accurate. There is no need to truncate after n+1 digits if you choose not to.

only using addition, subtraction, multiplication, and division please!
>>
>>60767415
You're not as smart as you think you are.
>>
>>60766389
Both of them are cute in my opinion. The benefit of dlang-chan v2.0 is that she's not from any copyright other than that of the author's implicit one.
>>
File: 1451750721293.png (593KB, 950x1335px) Image search: [Google]
1451750721293.png
593KB, 950x1335px
Is /dpt/ the last haven for cute anime girls on /g/?
>>
>>60767236
>Does your language have native equivalents for all those computing terms, or do they keep defaulting to english loanwords?
I wouldn't know. I don't read programming resources in it. Probably a lot of English loanwords though.
>>
File: 1490045214707.png (348KB, 593x670px) Image search: [Google]
1490045214707.png
348KB, 593x670px
>>60767484
I've started reading this book and it's shit desu

>>60767484
pic related
>>
File: 1496523251246.jpg (98KB, 640x368px) Image search: [Google]
1496523251246.jpg
98KB, 640x368px
>>60767484
As of right now, yes. But it will most certainly change after the anime coup.
>>
File: pee.png (48KB, 325x325px) Image search: [Google]
pee.png
48KB, 325x325px
>>60766306

>tfw tools are more complicated than the actual game, and the game is already a labyrinth beyond the comprehension of any single person.
>>
>>60765735
>this as explicit argument
no
>>
>>60765735
(((member functions)))
>>
>>60767017
algorithm blatantly ripped off from scip. please do not pass it negative numbers :)
sqrt x digit_accuracy = go (x/2) x digit_accuracy 
where
go guess x digit_accuracy
| is_good_enough guess x digit_accuracy = guess
| otherwise = go (improve guess x) x digit_accuracy

is_good_enough guess x acc = (abs (( pow guess 2 ) - x)) < 1 / (pow 10 acc)
improve guess x = (guess + ( x / guess )) / 2
pow a b | b == 0 = 1
| otherwise = a * pow a (b - 1)
>>
>>60765457
>ada was the first programmer
Someone explain this bullshit to me. How can you say with a straight face baggage made a machine couldn't actually use? How the fuck would he even know how to design it?
>>
>>60767462
>>60766389
>>60765549
What would it take for D to be anything but an interesting curiosity, bros? I feel like I am taking crazy pills whenever I hear people seriously say c/c++ is a better language.
>>
>>60767697
Money and manpower. The foundation behind dlang-chan does actually have some decent money according to Andrei, but you can never have enough. Languages like Rust, Golang, and Swift have big organizations behind them. dlang-chan needs one of her own to get more momentum. Once that happens, people will follow, and PRs and patches will come flooding in to help further dlang-chan's evolution. Sadly, this is a classic case of the chicken and the egg problem.
>>
>>60767650
The analytical engine was never actually built, and ada's claim to fame was some hobbyist stuff she did where she wrote a program for this theoretical machine, people claim this was the first computer program, and it casts this idea that babbage never knew how to use the machine that HE invented.
>>
File: thinking.png (66KB, 1000x1000px) Image search: [Google]
thinking.png
66KB, 1000x1000px
>>60767717
tell me anon, what's it like programming while illiterate?
>>
>>60767697
I'm a C/C++ shill but I'd say by just being a "better C++" it actually doesn't cater to any real demographic. People who need C++ need it for very specific purposes where D didn't have the occasion/ability to prove its superiority (game development, operating systems, etc...).
>>
File: aya_hatate_face1.png (83KB, 317x217px) Image search: [Google]
aya_hatate_face1.png
83KB, 317x217px
>>60767017
Babylonian approximation:
double sqrt_babby(double x,int n)
{
double y = x;
double y_temp = 1.0;
double tolerance = pow(10,-n);
while(fabs(y_temp - y) > tolerance)
{
y_temp = y;
y = 0.5 * (y_temp + y/y_temp);
}
return y;
}

Gaussian integral
double gamma(double x)
{
double sum = 0.0;
double ds = 0.0001;
int max = 10000;
double epsilon = 0.00000001;
if(x >= 1)
{
epsilon = 0;
}
for(n=0;n<max;n++)
{
double s = ds * m + epsilon;
sum += pow(s,x-1)*exp(-s) * ds;
}
return sum;
}

double sqrt_gauss(double x, int n)
{
double sum = 0.0;
double ds = pow(10,-n);
int max = pow(10,n);
for(int m=0;m<max;m++)
{
double s = ds * m;
sum += exp(-s*s *x) * ds;
}
return 2 * gamma(0.5) / sum;
}
>>
>>60767840
Also since it's so old now it didn't have a surge of popularity from the hipsters like Go or Rust did since back in the days, they weren't in the programming industry.
>>
>>60767822
There parenthesis are matched though.
>>
>>60767937
the compiler doesn't lie, anon-kun.
>>
>>60767455
anon only the multiplication operator twice:
>>60767415

that falls within guidlines
>>
File: 2017-06-05-193533_236x98_scrot.png (3KB, 236x98px) Image search: [Google]
2017-06-05-193533_236x98_scrot.png
3KB, 236x98px
>>60767976
>>
>>60765163
Bumping.
>>
>>60768021
your parenthesis-matching is the problem. vim detects the unmatched ending paren just fine, just pay attention to what the compiler says is wrong.
>>
>>60768065
Lmao this is how I'm supposed to detail the char "
(char "\"" 0)
>>
>>60767840
>I'm a C/C++ shill
NSA* shill
>>
File: 1458816261244.jpg (34KB, 493x533px) Image search: [Google]
1458816261244.jpg
34KB, 493x533px
Hmm, turns out Clang brings support to C++ modules.

Now I can peacefully(!) use C++ I suppose
>>
>>60768065
This is such a hack.
I refuse to believe SBCL is this crippled.
(let ((quote (char "\"" 0)))
(defconstant +ampersands+
`(("#039" . #\')
("quot" . ,quote)
("lt" . #\<)
("gt" . #\>)
("amp" . #\&))))
>>
>>60768188
>he still believes his toy language offers any safety compared to Coq
>>
>>60768308
Your point?
>>
>>60768308
>safety
>>
>>60767017

double retard_sqr(double x, int precision)
{
int p = precision + 1;
while(p > 1)
{
x = x * 100;
p--;
}
double t = 0;
while(t * t <= x)
{
t++;
}
t--;
p = precision + 1;
while(p > 1)
{
t = t / 10;
p--;
}
return t;
}
>>
>>60768312
The point being you don't know what you're talking about.
>>
>>60768302
it's entirely valid to use #\" to escape a double quote, your editor just doesn't highlight it correctly
>>
>>60768375
Where is your argument?
>>
File: chen_rape_face.png (54KB, 241x235px) Image search: [Google]
chen_rape_face.png
54KB, 241x235px
>>60768357
lol
>>
>>60768302
(defconstant +ampersands+
'(("#039" . #\')
("quot" . #\")
("lt" . #\<)
("gt" . #\>)
("amp" . #\&)))
>>
>>60768357
I like this!
>>
File: banner.jpg (111KB, 1280x284px) Image search: [Google]
banner.jpg
111KB, 1280x284px
Today I gave a new cyberpunk style to my imageboard, 4kev.org
>>
>>60768547
>register button
ctrl + w
>>
File: comfy.png (640KB, 3200x1080px) Image search: [Google]
comfy.png
640KB, 3200x1080px
I made Windows 7 surprisingly comfortable for programming while I'm too lazy to reboot.
>>
File: 1448840603790.gif (4MB, 270x263px) Image search: [Google]
1448840603790.gif
4MB, 270x263px
>do sparse arrays on hacker rank
>Use a hash table
>Solution just iterates through a list of strings
>Medium
>>
File: Screenshot_2017-06-05_17-23-43.png (25KB, 1018x214px) Image search: [Google]
Screenshot_2017-06-05_17-23-43.png
25KB, 1018x214px
Why is Project Euler so easy? No wonder /sci/ makes fun of CS - even codemonkeys can solve all the problems.
I literally came up with this in 1 minute, than deliberated for another 4 whether or not permutations were computationally feasible (I didn't know the unique character count yet). Then I realized the unique char count is at max 10, making only 10! = 3628800 permutations. The problem should have had a minimum 21 unique characters, making permutations too expensive.
import itertools

CHARACTERS = [
319, 680, 180, 690, 129, 620, 762, 689, 762, 318, 368, 710, 720, 710, 629,
168, 160, 689, 716, 731, 736, 729, 316, 729, 729, 710, 769, 290, 719, 680,
318, 389, 162, 289, 162, 718, 729, 319, 790, 680, 890, 362, 319, 760, 316,
729, 380, 319, 728, 716
]

def shortest_passcode():
characters = list(map(str, CHARACTERS))
unique_chars = {l for c in characters for l in c}
for perm in itertools.permutations(sorted(unique_chars)):
if all(perm.index(a) < perm.index(b) < perm.index(c)
for a, b, c in characters):
return "".join(perm)

print(shortest_passcode())
>>
>>60768813
>No wonder /sci/ makes fun of CS
Project Euler is mathematics, though. You just need to write a program to solve it.
>>
>>60768813
https://code.google.com/codejam/contest/7234486/dashboard

solve these in le 1 minute and we'll talk
>>
>>60768813
>import itertools
faggot
>>
>>60768871
fk that shit, i dont even understand what its talking about.
>>
>>60768813
>this contrived example should be arbitrarily harder
>so i can get my fee-fees

kys
>>
>>60768953
>Can't even do a simple regular expression problem
We should ban non-CS plebs from /g/.
>>
>>60768867
>You just need to write a program to solve it
How does that not make it programming? And the maths are all generally trivial stuff you can find on wikipedia. Furthermore, all problems are based around programming.
>>60768871
>codemonkey jam
No thanks.
>>60768938
What's the problem? Lexicographic permutations algorithm is trivial to implement, but it's tenfold slower than itertools, which is written in C.
>>
>>60768813
You can brute force pretty much all of Project Euler, doing it through pure permutation shows you never took a decent math class
>>
Is Rust good for games?
>>
>>60769027
>How does that not make it programming?
I never said it wasn't programming. I was really trying to say that you shouldn't conflate CS and programming.
>And the maths are all generally trivial stuff you can find on wikipedia
>Furthermore, all problems are based around programming
True, but a lot of the questions require you to understand the mathematics behind the problem before you can really solve it. Some of them are brute-forceable in reasonable time, though.
>>
How are you expected to make anything fast on the JVM when everything except primitives can only be stored as a reference to an object on the heap?

Want to have an array of paired ints? You can't! You must have an array of references to int pairs!
>>
>>60769089
EverythingIsAnObject :^)
>>
>>60769109
everythingIsAnObjectExceptTheThingsThatArent :^)*
FTFY
>>
>>60769109
Then why can't I have a List<int>? Huh? Huh?
>>
>>60769116
That's honestly really obnoxious about the defacto "oop language"
>>
>>60769035
An upper bound of 10! is easy to bruteforce. The actual bound is just 8!, however, making it even easier. There's no need to for tricks or thorough algorithms, so why bother with anything but the trivial solution when it's computationally inexpensive?
>You can brute force pretty much all of Project Euler
No, there are problems that cannot be brute forced on consumer hardware. And on the other hand, there are a couple problems that have no solution besides brute force, instead requiring effective memoization.
>>
>>60769160
>What's the point
The point is for you to come up with elegant solutions to the problems, not just solve them. You're only cheating yourself.
>>
>>60769139
You don't need that, anon!
Use List<Integer>, only needing 16 bytes per element, ignoring heap overhead.
>>
>>60769008
ima 3rd year SE major.
>>
>>60769182
but haskell is inefficient and c++ is too low-level, java is the practical and pragmatic choice for the real world, amirite?
>>
>>60769207
Ada's the best middle ground of abstractions but allows low level if you need it
>>
>>60769146
>the defacto "oop language"
that'd be smalltalk
>>
>>60769276
maybe in 1992
>>
>>60769027
If it's all so trivial and you insist on importing and brute forcing shit then why are you doing low difficulty problems?
>>
>>60769178
>analyze problem
>find lower bound
>lower bound and upper bound are probably one and the same
>bound is at most 10!
>problem solved
How is that not elegant? Going out of your way to implement an unnecessary, probably verbose algorithm is what's inelegant. And would you also sacrifice performance to remain "elegant"? Because in some problems I had to inline functions to reduce function call overhead. This created some ugly, but efficient code, vs hundreds of millions of function calls but "elegant" code.
>>
>>60769348
"Elegance" is not orthogonal to "performance".
>>
>>60769049

It's as good for games as you are at Rust and your knowledge of the necessary Rust dependencies required.
>>
>>60766635
glade + vim
glade is not an ide, just a UI designer
>>
>>60769207
no
use scala

functional dankness of haskell + portability and speed of java
>>
>>60769375
>orthogonal to
you think you're smart but you aren't
>>
>>60769348
Elegant code isnt inherently aesthetic code, dumb dumb
>>
>>60768813
Are you literally patting yourself on the back in public for solving a highschool problem? Mentally ill or trolling?
>>
>>60769455
I've used Scala, it has very many warts, and compilation takes ages
>>
>>60769480
then just be a real man and use asm
>>
File: smug37.png (179KB, 462x450px) Image search: [Google]
smug37.png
179KB, 462x450px
>>60769348
>How is that not elegant?
>>
Reminder that every self-respecting adult male must be fluent in at least 5 programming languages.
>>
>>60769497
I think I'll just use Rust famalam
>>
>>60769497

You may not be able to use asm depending on the circumstances. You may be told by your senior developers that Java should be used for the project.
>>
32 and 64 bit ints were a mistake

we should have had 31 and 63 bit ints
>>
what is the K&R book of python?
>>
>>60769547
they do not dignify python with an acknowledgment of its existence
>>
>>60769547
Python is literally psuedocode
>>
>>60769544
I don't even think you're trying anymore
>>
>>60769573
https://en.wikipedia.org/wiki/31-bit
>>
>>60769584
>Look! It existed.
So what?
>>
>>60769594
It was superior.
>>
>>60769603 (You)
Sure
>>
>>60769375
Right, I see what you now mean by "elegant solution" (I misinterpreted as "code"). But I still stand that that this is an elegant solution given the scope of the problem. Permutations are entirely applicable as a maths concept, and given that the solution has a bound and isn't just brute forcing blindly, it's more than adequate. I mean, if you need to find all the primes below 10, are you going to write a sieve or a primality test? No, why would you when you can simple list the primes off the top of your head, or trivially implement trial division. Overkill and excessive verbosity is not elegant when the time complexity of trial division is virtually non-applicable, the concept is simpler than any other solution, and the result is the same.
>>
>>60769479
Why wouldn't I be? The majority of the world's population cannot solve high school maths and logic. Have you seen the "sum the primes under 2 million" threads on /g/? People were having trouble with that.
>>
Can /g/ add two numbers in C?
>>
>>60769781
Are you literally patting yourself on the back in public for solving an abstract problem that has very little application in real life?
>>
>>60769781
>The majority of the world's population cannot solve high school maths and logic
What kind of argument is that
The majority of employed programmers or uni students can and that is the relevant group to compare your skills with, who bloody cares about "world's population"
>>
>>60769879
lol just no
>>
>>60769603

In what way?
>>
>>60769906
Flexibility.
>>
Serious question, what practical purpose do prime numbers serve outside of factoring polynomials?
>>
>>60769879
>The majority of employed programmers or uni students
The majority of working "professionals" cannot even do bubble sort on a whiteboard (Ruby on Rails creator comes to mind); uni students maybe can if they just did that class recently. Seasoned programmers have trouble with basic tasks; Linus once complained that he couldn't install Debian - doesn't that sound ridiculous?
>>
Can I get graded badly for including this in my homework assignment?
/* I really wish these names were less generic. If you absolutely must give a
function a name like "getParent" or "delMin," that's what C++ is for, with
features like namespaces, inheritance, and overloading. C has a similar but
less advanced feature that I really wish we were allowed to make use of
here. You know what it's called? An underscore. I know no assignment we
ever do in this class will ever be published as a library, but if we DID do
such a thing, I think the users of that library would be in for some
unpleasant surprises. Heck, it's probably for the best if any hypothetical
users of our code couldn't compile it due to name clashes, because if they
did get it working, their program would be full of memory leaks, due to the
ADT design pattern's God-forsaken pathological contempt of RAII. If this is
what theoretical computer science is like, it should really be kept
theoretical. I don't CARE if "this isn't an operating systems class." The
code we write will run ON an operating system no matter WHAT kind of class
this supposedly is, and we should be writing it as such. And by the way,
what's up with camel case? It's not an issue of efficiency or correctness,
but come on -- what is this, Germany? These four assignments have been the
ugliest, stupidest, least intuitive code I've written since high school --
and before you ask, no, NOT just because I kept trying to find little
tricks to shorten it or clean it up without changing anything essential.
I'm so mad right now that I actually took the time to type all that out. */
>>
>>60769964

https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
>>
>>60769991
>The majority of working "professionals" cannot even do bubble sort on a whiteboard
Why does this matter?
If you're suddenly required to figure out how to array items procedurally, give it some thought, and you'll invent bubble sort, even if you've never seen the code for it.
>>
>>60769834
>Are you literally patting yourself on the back
Patting myself? I'm stroking myself. I'm literally pacing around the room in excitement; the euphoria still hasn't died down, and it's like a drug. There is no greater feeling than solving a problem, no matter how trivial.
>>
>>60770009
You get referred to the councilor for autism
>>
>>60770009
see me after class anon
>>
>>60769937

I can maybe see flexibility in a 63 bit system, due to the fact that it has more prime factors than 64 (3 and 7 vs just 2), but 31 is itself a prime number, and thus cannot be evenly subdivided. By comparison, powers of 2 just work for a lot of things.
>>
>>60769964
Cryptography which you probably mentioned by "factoring polynomials" is already pretty big.
Finite fields over prime numbers and their powers are of interest for the study of group representations (applications in chemistry, for example crystals).
>>
>>60770024
*how to sort array items procedurally

>>60770037
Enjoy it while it lasts, that dizzying satisfaction becomes harder to attain the longer you go on.
>>
File: 1491247534244.png (140KB, 395x398px) Image search: [Google]
1491247534244.png
140KB, 395x398px
>>60770009
>what is this, Germany?
>>
>>60770009
You''ll have to apologize for oppressing your female (male) teacher.
>>
What is the usefulness of bit arrays.
>>
>>60770009

Depends who's grading it and how drunk they are.
>>
File: wew lad4.png (328KB, 672x706px) Image search: [Google]
wew lad4.png
328KB, 672x706px
>>60770009
If I was your instructor, I'd save it and show it to future classes so I can laugh at you, I'd probably just show it in the next class, this is fucking hilarious.

I don't even care if you go screaming to the dean that I embarrassed you in front of the whole class, you need to learn to pick your battles, you psuedo-intellectual cumstain.
>>
>>60769964
If you can efficiently generate prime numbers, you can make an open-addressing hash table that avoids predictable clustering.
>>
>>60770100

Storing large quantities of boolean variables in a small amount of memory. Example usage: Sieve of Eratosthenes.
>>
>>60770024
>durr I'm too dumb to remember simple algorithms but I can easily reinvent them
fuck off retard
>>
File: Sieve_of_Eratosthenes_animation.gif (154KB, 445x369px) Image search: [Google]
Sieve_of_Eratosthenes_animation.gif
154KB, 445x369px
>>60770157
>Sieve of Eratosthenes.
I have that
>>
>>60770158
Are you retarded?
grab first numbers, sort, grab next 2 numbers, sort, go through the whole list N times where N is the number of items in the list and you're done
>>
>>60770138
Embarrassed? Bitch please, I don't even come to class. I've already taken it anyway. (I have to retake it because I was unable to complete numerous assignments on time, because I was preoccupied with obsessing over how hideous the code we were required to use was.)
>>
>>60769826
/* easy */
int main()
{
sum = 1 + 1;
return sum;
}
>>
Does anyone have good references on sockets programming? I find the API really confusing.
>>
How the fuck do I get around the fact that 4chan takes a shit on me when trying to post a code with more than
suckcocks();
?
>>
>>60770177

Right, and if you wanted to do a sieve over the numbers 1..120, you'd want 120 booleans. As a bit vector, this would only be 15 bytes, 16 if we take into account alignment.
>>
File: nico nico okeeeeei.png (141KB, 502x502px) Image search: [Google]
nico nico okeeeeei.png
141KB, 502x502px
>>60770197
If I was you, and I really am glad that I'm not you, I would go to the instructor directly during office hours and say all this shit to his face, tell him what you think of his example code and his code style and his assignments.
Writing it in a comment that makes you sound deranged is just beta as fuck.

Also, you sound mentally retarded if you couldn't pass an entry level programming course because you hated the instructor's way of teaching.
Why would you even retake this class with the same professor?
Maybe you literally ARE retarded.
>>
>>60770224
>error: 'sum' was not declared in this scope
>>
File: smug22.jpg (850KB, 2481x2394px) Image search: [Google]
smug22.jpg
850KB, 2481x2394px
>>60770009
>>60770197
lol
>>
>>60770193
Sorry anon but you won't be going through to the next round of interviews. Thanks for your interest in this position though.
>>
>>60770257
fucking gay, I'm going back to python.
>>
Why is Ruby the comfiest programming language ever? Why don't other languages adopt some of the comfy features of Ruby?
>>
>>60770009
Save it for the anonymous class reviews you submit every semester.
>>
>>60770194

Have 2 dimensional array, call it a. Call row index r, column index c.

// This is how you access in row major:
a[r][c]
// This is how you access in column major:
a[c][r]
>>
>>60770282
>What makes ruby [generic millennial term to describe a mild sense of personal gratification]?
>>
>>60770243
Post snippets, not the entire thing.

>>60770250
Can you give a simple example of how that'd work? I don't understand how that'd work without using integers.
>>
>>60770253
>If I was you, and I really am glad that I'm not you, I would go to the instructor directly during office hours and say all this shit to his face, tell him what you think of his example code and his code style and his assignments.
>Writing it in a comment that makes you sound deranged is just beta as fuck.
Masculinity isn't really a concern of mine. Besides, writing it all in a comment that makes me sound deranged (and I'm not denying it does) is funnier.

>Also, you sound mentally retarded if you couldn't pass an entry level programming course because you hated the instructor's way of teaching.
No, just autistic. There are certain things I can't just put aside to do what needs to be done. I just can't deal. That doesn't make me stupid, just nuts.

>Why would you even retake this class with the same professor?
He's the only one who teaches it, and I need it. I shouldn't even need it, because I learned all this shit in high school, but whatever.

>Maybe you literally ARE retarded.
No, just autistic.
>>
>>60770282

>Why is Ruby the comfiest programming language ever?
Because it was designed to be comfy.

>Why don't other languages adopt some of the comfy features of Ruby?
Some of them have. But it's not so much a matter of what features it has, but how they are used, and how everything interconnects.

If you want a language very similar to Ruby, try Crystal. It's not very mature, however.
>>
>>60769557
why does 4chan dislike python so strongly?
>>
>>60770314
>i'm autistic
Your cognitive deficiencies have prevented you from performing on a level playing field with the rest of the class, namely, pass a piss basic programming prereq. course, and you'll probably fail it again at this rate.
You keep on telling yourself that you're not mentally retarded.
>>
>>60770327
What does Ruby offer anyway.
>>
>>60770360
How can a website dislike something?
>>
>>60770360
Because
It's not fast
It's not good at anything
It's used by every retard on the planet to pump out worthless applets that run like shit because of the aforementioned
Whitespace syntax is an affront to god
"BUT LOOK AT HOW EASY IT IS TO DO X!" as the author imports 16 modules and then string it together in an indecipherable one-liner mess
"It's fast because it saves time on development!" arguments are obnoxious from every python enthusiast because anybody who isnt completely retarded can write in a better language just as quickly
It's not fast, it's really really genuinely not fast and it ends up getting used in huge scaled projects that then run like total dogshit, and if you question the usage of python you're treated like an ANSI C purist weirdo
>>
>>60770360
Because Python is usually baby's first programming language and 4chan likes to belittle beginners. Also, Python doesn't really do anything new compare to other languages, other than the fact it forces you to style in a certain way.
>>
File: 1496131085373.gif (389KB, 500x281px) Image search: [Google]
1496131085373.gif
389KB, 500x281px
>>60765785
>C++
Sounds like you have AIDS anon. Sorry to tell you that.
>>
>>60770371
>Your cognitive deficiencies have prevented you from performing on a level playing field with the rest of the class, namely, pass a piss basic programming prereq. course,
Wrong, what prevented me from performing on a level playing field with the rest of the class was the sheer intensity of my distaste for the style we were being taught.

>and you'll probably fail it again at this rate.
Wrong, I currently have an A. I got here by slipping into depression and being too sad/tired/bored to care anymore.

>You keep on telling yourself that you're not mentally retarded.
No, just autistic.
>>
>>60770402
>the sheer intensity of my distaste for the style we were being taught.
You sound really immature and stupid.
I bet you won't say it to your prof's face because you can't string out 2 words together without stuttering and mumbling, fucking retard.
>>
typedef struct {
int x;
int y;
} point;

point p;


vs

struct point {
int x;
int y;
};

struct point p;


Can I do first one to eliminate verbosity or am I going to get yelled at for using typedef?

What looks nicer, /g/?
>>
>>60770312

Make an array of bytes or ints, or whatever so that you have at least 120 bits of data. Each bit represents "is the number with this index prime?" Then just do sieve as usual.

>>60770373

Ruby can't be said to have any must-have feature or library that can't be hacked together in some other language (except maybe Metasploit). What it offers is that it's pleasant to program in, and has comparable features to other scripting languages. I'd say it's really great for just arbitrary string or list processing tasks. Also, it makes fucking with its runtime extremely convenient (instance_eval and method_missing are exploitable as all hell), so many people use it for domain specific languages, like Rake.
>>
>>60770429
>You sound really immature
Yup.
>and stupid.
No, just autistic.

>I bet you won't say it to your prof's face because you can't string out 2 words together without stuttering and mumbling,
Yup.
>fucking retard.
No, just autistic.
>>
>>60770432
Use first. Worst case people might ask you to name it point_t instead of point.
>>
>>60770432
class Point {
public:
int x;
int y;
}

Point p;
>>
>>60770439
Why not use Lisp.
>>
>>60770432
You can use typedef when you feel it necessary to hide away some complexity from a library you wrote, especially when you're storing the entire state of a library instance within a single struct.

Just don't add pointers into the type name being redefined with typedef, this is really fucking irritating and people can't even figure out that you did it until it's too late.
>>
>>60770452
>i'm not retarded i just talk like a retard and i lash out at people behind their back and never to their face

I bet you're an men's rights activist.
>>
>>60765457

Rewriting a paper on Charles Babbage's invention in my own handwriting so I can get half the credit for it
>>
>>60770494
Lmao, she's still a cutie though.
>>
>>60770494
Same here.
>>
File: c.png (1KB, 175x125px) Image search: [Google]
c.png
1KB, 175x125px
>>60770432
You should really name the typedef in case you want your struct to hold an instance of itself.
>>
>>60770373
What makes Ruby different is that it feels like everything fits together. It combines OOP and functional style to create this unique and fun kind of programming style which is highly readable, almost like reading what it is doing. Since everything is an object in Ruby, you can do stuff like this:

5.times { puts "Hey" }
1.upto(4) do |i|
puts "I am at number #{i}"
end


And avoid things like off by one errors.
It also implements OOP so many nice things that other OOP languages lack, such as Java, like automatically specifying accessors and mutators. It encourages good design patterns such as Liskov's Substitution Principle by single inheritance and using mixins which are incredibly powerful and Bertrand Meyer's Uniform access principle with virtual instance variables. All in all, it is my favorite programming language because it is so fun and /comfy/ to program in.
>>
>>60770224
>Average C "enthusiast" of /g/
>>
>>60770492
>i'm not retarded
Nope, just autistic.

>i just talk like a retard
Or like someone with autism. The latter of which I am.

>and i lash out at people behind their back and never to their face
This has nothing to do with retardation or autism. Also, writing a strongly worded letter is not "lashing out."

>I bet you're an men's rights activist.
Nope, moderate third-wave feminist.
>>
Can /g/ program without GC?
>>
>>60770432
First is C style. Second is C++ style.
Keep in mind the first is performing two operations: Defining an anonymous struct, and aliasing that struct to 'point'.

C would historically have you do:
struct foo { int x; };
void func( struct foo *myFoo );


This compares to:
typedef struct { int x; } foo;
void func( foo *myFoo );


Which is demonstrated better by:
typedef struct realFoo { int x; } foo;
void func( foo *myFoo, struct realFoo *myRealFoo );

...which is the same type

C++ does away with this, allowing:
struct foo { int x; };
void func( foo *myFoo );

...because in C++, the only real difference between a struct and a class is the access-specifier (public, private respectively)

Yay backwards compatibility.
>>
File: 1495685723857.png (321KB, 372x539px) Image search: [Google]
1495685723857.png
321KB, 372x539px
>>60770529
>moderate third-wave feminist
How the heck were you brought up?
>>
>>60770193
>N times
hmm really makes you think
>>
>>60770538
Yes, I use Fortran.
>>
>>60770529
Could you stop replying maybe?

Consider getting a mental filter, this is why people like you are ridiculed, you don't know when to shut up and I can guarantee you do this everywhere.
>>
>>60770538
I kode directly in machine codes bro, up ur game
>>
>>60770432
I like doing it the way it's done in "The Practice of Programming" by Brian Kernighan and Rob Pike.

typedef struct point Point;
struct point {
int x;
int y;
};
>>
>>60770548
>How the heck were you brought up?
I kind of wasn't. My dad molested me and my mom is way too nice.
>>
>>60770529
Anon, please understand that you are probably coming across worse than you intend since /dpt/ is a text-only medium.

My advice? Suck it up, finish the course, and you won't have to deal with this specific bullshit again. Of course, there will be other bullshit in the future.
>>
>>60770473
That's the plan. I will not be hiding that something is a pointer. That's important to know. It's just that I got all these structs, and my functions and declarations get swamped with struct this and struct that.

>>60770522
Good call. I was probably going to run into that because I do have some linked lists.
>>
>>60770566
>I kind of wasn't
I can see. At least you won't reproduce.
>>
>>60770562
Note this is not standard compliant for enumerations.
>>
>>60770556
>Could you stop replying maybe?
On the contrary I think I'll see this one through.

>Consider getting a mental filter,
No. Mental filters are dishonest.

>this is why people like you are ridiculed,
Don't care.

>you don't know when to shut up
Only when someone hands me a keyboard.

>and I can guarantee you do this everywhere.
On the contrary, I hardly ever speak. It's the typing that's a problem. For everyone else, that is. For me, it's a barrel of laughs.
>>
I might attend 2017's suckless conf. What kind of autists will I meet there?
>>
>>60770606
In the last 3 posts, you revealed that you're bitter, you're immature, you have assburgers, you're a male feminist, and you got raped by your dad and are probably also a homosexual because that's how these things always turn out.

STOP REPLYING
>>
>>60770577
Good advice. Thanks. I've got the "finish the course" part in the bag, but the "suck it up" could use some work. Frankly I'm not convinced it's going anywhere.

>>60770594
I, too, enjoy replying in non sequiturs.
>>
>>60770632
Be nice, anon

/dpt/ is a welcoming family thread
>>
>>60770632
He has autism
>>
>>60770632
>In the last 3 posts, you revealed that you're bitter, you're immature, you have assburgers, you're a male feminist, and you got raped by your dad and are probably also a homosexual because that's how these things always turn out.
Quite.

>STOP REPLYING
Aww, but it's just getting good.
>>
>>60770656
I highly doubt that.
>>
>>60770523
haskell!
sequence (replicate 5 (putStrLn "Hey"))
for [1..4] (\i -> putStrLn ("I am at number " ++ (show i)))
>>
>>60765457
Android app for a shitty client
>>
>>60770682
Haskell can do most if not all the functional things Ruby can, but its way uglier to read
>>
>>60770682
>sequence (replicate 5 (putStrLn "Hey"))
VOMIT.webm
>>
>>60770465

Not as comfy.
>>
>>60770656
Feel free to include that angry comment in your homework and tell us how it went tomorrow, since you clearly don't care what people think of you.
>>
>>60770676
"Doubt" seems like a strange choice of words here. Do you mean "disagree?" Because what we're talking about here -- "it's just getting good" -- is both a matter of opinion and a statement about the present. Statements which can be doubted are usually neither of these things.
>>
>>60770682
Yeah, but that looks esoteric if you have never read Haskell before. The Ruby version is much easier for someone to read because it almost reads like a book and thus less likely to make a silly error.
>>
>>60770700
I like it!
>>
>>60770715
That's my fetish.
>>
>>60770682
That took 1000 seconds more
>>
>>60770718
No one else does.
>>
>>60770682
>sequence (replicate 5

replicateM from Control.Monad
also using sequence_ or replicateM_ will ignore the result
>>
>>60770682
Reminds me of a discussion I had with somebody, where you had to interleave two arrays with each other.

In ruby it's just
zippedArr = arr1.zip(arr2).flatten


in Haskell it was
altZip :: [a] -> [a] -> [a]
altZip first second = concat $ map (\(a,b) -> [a,b]) $ zip first second


Which, sure, its still one line, but it's so much unpleasant to look at
>>
>>60770750
thank you!
>>
>>60770725
>That's my fetish.
lood

>Feel free to include that angry comment in your homework and tell us how it went tomorrow, since you clearly don't care what people think of you.
I was going to anyway. Indeed I don't care what most people think of me, but if there were only one person whose opinion on me I didn't care about, it would have to be this guy. Ugh, this guy, let me tell you. I don't even know what he's doing teaching. He clearly hates it. And this isn't just my weird autistic opinion either, for once. Most of the rest of the class thinks so as well. Most people make it out of his class with something like a C minus.
>>
File: 1496523528696.jpg (31KB, 394x394px) Image search: [Google]
1496523528696.jpg
31KB, 394x394px
>>60770762
>concat $ map
>>
>>60770762
altZip = (concat .) . zipWith (\x y - > [x, y])
>>
>>60770791
Honestly I still don't understand the Haskell version.
That language is fucking baffling.
>>
>>60765851
>30 pieces make up those 10 columns
you are not supposed to seed inside that loop, just seed it once!
>>
>>60770762
zippedArr = concat (transpose [arr1, arr2])
>>
>>60770805
>concat (map (pair to list) (zip lists))
>don't understand
you're pretty dumb huh?
>>
File: 1489537689341.png (542KB, 811x710px) Image search: [Google]
1489537689341.png
542KB, 811x710px
>>60770805
It's a language for simpletons. You not being able to understand it is pretty sad.
>>
File: 1491182127356.jpg (17KB, 222x251px) Image search: [Google]
1491182127356.jpg
17KB, 222x251px
>>60770821
>>
>>60770821
>map (pair to list) (zip lists)
makes sense so far
>concat
why do you need this
wouldn't the result of concatenating a single list together just be the same list
>>
>>60770834
>>60770762

using parallel list comp

altZip a b = 
concat
[ [x, y]
| x <- a
| y <- b ]
>>
>>60770829
Wow, that is a really hideous drawing.
>>
shit programmers: when did it dawn on you that you were a shit programmer?
>>
>>60770861
>why do you need to concat
Because you want one interleaved list, not a list of 2-length-lists of zipped elements
>>
>>60770762
import interleave
interleave.flatten(list1, list2)

lmao
>>
>>60770885
>import
PYTHON, EVERYONE
>>
>>60770884
wouldn't that be apply concat though
>>
>>60770861
zip [1,2,3] [7,8,9] = [(1,7), (2,8), (3,9)] 
map pairToList [(1,7), (2,8), (3,9)] = [[1,7], [2,8], [3,9]]
concat [[1,7], [2,8], [3,9]] = [1, 7, 2, 8, 3, 9]
>>
>>60770893
>Implying there is anything wrong with importing
Are you against diversity?
>>
interleave (x:xs) (y:ys) = x : y : interleave xs ys
interleave xs ys = xs ++ ys

>>60770905
what
>>
>>60770911
>concat [[1,7], [2,8], [3,9]] = [1, 7, 2, 8, 3, 9]
i won't deny this is true, but if it is, haskell sucks
>>
File: 1493062782294.jpg (76KB, 733x672px) Image search: [Google]
1493062782294.jpg
76KB, 733x672px
>>60770918
>>
>>60770762
(defun arr-zip (xs ys)
(loop for x across xs
for y across ys
do collect `(,x ,y)))

Lisp wins again with actual readability and with actual vectors.
>>
>>60770924
concat :: [[a]] -> [a]

would you prefer
]concat :: [a] -> [a] -> [a]
?
because that would be awful
>>
File: 1496064255553.jpg (11KB, 177x184px) Image search: [Google]
1496064255553.jpg
11KB, 177x184px
>>60765457
Right now I'm searching for the cutest girl.
>>
>>60770951
Madoka is cute.
>>
>>60770951
me~
>>
>>60770957
>>60770964
Homura is cuter.
>>
>>60770941
lmao that doesn't even solve the problem
>>
>>60770941
>arr1.zip(arr2).flatten
>less readable than that
That's magnitudes better than Haskell but you cant beat rubys simplicity here
>>
>>60770941
>defun
Why would you want to "de" "fun"? Don't you like fun?
>>
>>60770947
>concat :: [a] -> [a] -> [a]
naw man it should be
>concat :: [a] -> ... -> [a]
>>
File: futo_ahegao.png (148KB, 675x351px) Image search: [Google]
futo_ahegao.png
148KB, 675x351px
>>60770762
In Mathematica this is just
Flatten[Table[{u[[i]],v[[i]]},{i,1,Length[u]}]];[/math]
Yes arrays start at 1 in Mathematica lol.
>>
>>60770977
>arr1.zip(arr2).flatten
This is unreadable.
>>
>>60770941
moron, stop embarassing lisp
(defun interleave-vectors (xs ys)
(loop for x across xs
for y across ys
appending `(,x ,y)))
>>
>>60770994
Too unreadable for me.
>>
>>60770984
Fun is for normies.
You're not a normie, are you?
>>
>>60771033
Holy shit I confused math tags on /sci/ with code tags here.
This
Flatten[Table[{u[[i]],v[[i]]},{i,1,Length[u]}]];

should be what it looks like.
>>
>>60770964
>>>/gif/10702876
>>
>>60770991
that doesnt work with currying. let's say there was concat' with that type signature.

y = concat' [1] [2] [3] 
z = y [4] // is this applying concat to 4 arguments or a type error?
>>
>>60771047
I would prefer it if we all used the term normalfag instead of "normie".
The term "normie" came about because faggots were too afraid to use the word fag as they thought it would offend people.
>>
>>60771067
what the fuck man
>>
Can you somehow connect F# Interactive to your project to make it actually useful?
I know I can load libraries manually, but this isn't comfy enough.
>>
>>60771014
>in lisp
>using loop
nek urself
(defun interleave (&rest lists)
(apply #'append
(apply #'mapcar
(cons #'list lists))))

>>
You can express most things with foldMap
>>
>>60771069
Too long, "normans" is better.
>>
>>60771052
Protip: alt+c automatically inserts code tags if you're on 4chanx
>>
>>60771068
>not using type classes to make polyvariadic functions
>>
>>60771094
What does it even do.
>>
>>60771074
>>>/gif/10705744
>>
File: tfw_cactus.png (50KB, 323x215px) Image search: [Google]
tfw_cactus.png
50KB, 323x215px
>>60771102
Thanks anon.
>>
>>60771110
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m 
>>
>>60771131
Give example, that's too vague.
>>
>>60770893
What's wrong with this? I can't even import my own code?
>>
>>60771093
Unreadable.
>>
>>60771135
I don't understand, anon.
>>
>>60771135
>>60771110
it maps using the function you give it and then folds using mappend (the monoid append)

you can compare mappend to + but on a more conceptual level, e.g. mappend for lists is append, mappend for sets and maps is union, etc
>>
File: gps-system-for-car-best-buy.jpg (115KB, 1200x801px) Image search: [Google]
gps-system-for-car-best-buy.jpg
115KB, 1200x801px
>>60771093
>#'mapcar
>>
>>60771138
The fact he imported an entire library to do a trivial task that should be handled in the standard library is indicative of what makes Python such a fucking awful language.
>>
File: doobmcfroob.jpg (3KB, 373x550px) Image search: [Google]
doobmcfroob.jpg
3KB, 373x550px
>>60771140
>he cannot brain enough
>>
>>60771155
t. masochist
the loop macro is super readable
functional programming is for schemers
remember that common lisp is imperative
>>
>>60771131
foldMap (\(x, y) -> [x, y]) (zip [1,2,3] [4,5,6])
>>
>>60771215
>tfw no ListSections
>>
>>60771155
dumb frogposter
>>
>>60771093
Wasteful dumbfag.
Use nconc, moran.
>>
>>60771155
stupid frogposter
>>
>>60771225
dumb dumbfrogposterposter
>>
>>60771245
his post wasn't dumb at all and nor was he
go back to ribbit you filthy frogposter
>>
NEW THREAD!!

>>60771252
>>60771252
>>
>>60771154
You have no argument. You import the module if you need it, what's the actual problem?
And if the two arrays are of equal lengths, you can just:
[j for pair in zip(lst1, lst2) for j in pair]
>>
>>60771262
>if the arrays are equal
oh im laffin
Thread posts: 341
Thread images: 42


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