[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 28
File: prog.png (486 KB, 473x496) Image search: [Google]
prog.png
486 KB, 473x496
Old: >>52480962
What are you working on, /g/?
>>
>>52485487
All useful programs are I/O. Yes.

And all useful Functional programs ultimately provide I/O, just with a different conceptualisation of how to represent I/O in the codebase.

>>52485498
It's a function of an I/O of X to an I/O of Y. It is up to the external environment to "perform" those I/O actions.
>>
FP is shit
>>
there is no inherent advantage to FP and FP users are needlessly smug about using it
>>
Imperative programming makes gains when it finds a way to restrict programs (i.e. letting compilers do certain optimizations or safety checks).

Functional programming makes gains when it finds a way to express more programs (i.e. letting programmers work with new effects).
>>
>>52485516
>>52485516
>>52485516
>>
>>52485550
The biggest advantage is when doing highly parallel programming because immutable and thus shareable data.

Also side-effect-free code is far most testable.

It's not like a magic replacement that does things imperative CAN'T do. It just does almost everything better. I say almost because there are a few inherently imperative algorithms, but they are FEW and far between.
>>
>>52485578
yeah right

for games at the very least most algorithms are inherently imperative
>>
>>52485601
>games
I give zero fucks, those are not critical systems and they don't matter.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>52485608
ok
>>
>>52485516
>unless the compiler is super clever you're doing a lot of needless data copying
The compiler doesn't need to be super clever to do this when you have linearity.

You're pointing out Haskell's flaws as if they're somehow inherent flaws of FP. Which is something a lot of anti-FP people seem to do. There are lots of horrible, horrible imperative languages but you don't see people talking about Brainfuck as if it somehow reflects on everything else.

>>52485601
Games are basically just state to state functions (not the entire state at once, all the time, mind you), which can be optimized to be mutation with linearity, plus rendering. Which on the application side is just building lists of commands and writing shaders, which are best expressed as pure functions anyways (plus specific effects like image load/store).
>>
File: 1444589415464.jpg (165 KB, 439x550) Image search: [Google]
1444589415464.jpg
165 KB, 439x550
>>
>>52485532
Kill yourself

You're literally a memetier code monkey
>>
import std.stdio;

void main(string[] args)
{
writeln("D!");
}
>>
>>52485655
and you are such an enlightened atheist for following a particular programming paradigm
>>
>>52485647
What language would you consider the shining paradigm of FP then?
>>
>>52485682
I recognize that all paradigms have their flaws and benefits
>>
damn you faggots are useless
>>
>>52485675
>\n{
You disappoint me anon
>>
>>52485700
No they don't you fucking retard
>hurr durr they're all equal
>>
>>52485693
There isn't one, not yet. Idris has the most potential, but I don't think it's differentiating itself from Haskell enough (and it chose the relatively weak uniqueness over proper linearity).

I'm trying, though.
>>
>>52485700
any possible benefits of FP get wiped away as soon as you wrap too much state as input.

like i said, using functions in your program is okay. basing your entire program around functions is stupid.
>>
File: 1452215124352.gif (208 KB, 354x534) Image search: [Google]
1452215124352.gif
208 KB, 354x534
semicolons aren't necessary in javascript, right?
>>
>>52485725
I didn't say they are equal. Learn to read.
>>
>>52485693
>>52485737
The relevant pieces are scattered around various academic papers and experimental languages, in any case.
>>
>>52485717
>>\n{

Allman braces are the greatest of all time. Of all time.
>>
>>52485742
right? javascript isn't necessary;
>>
>>52485717
i think it's okay for functions.
>>
>>52485740
Why?
>>
>>52485743
You said they have their own advantages and disadvantages

Prove that, retard
>>
Name a better character for terminating statements than the semicolon
Protip: you can't
>>
>>52485740
>omg monads are so confusing
>I'm a grill btw ;)
>>
>>52485625
I enjoy games as a player. As a programmer, I am not interested in them in the least. They aren't important.
>>
File: 1452465650049.jpg (38 KB, 351x352) Image search: [Google]
1452465650049.jpg
38 KB, 351x352
>>52485763
what if i want to run code in someone's browser?
>>
>>52485742
The interpreter will attempt to guess where they should if if they are omitted and insert them.

And basically all JS coding standards/conventions use them. Do not omit them.
>>
>>52485780
Why would I waste my time on a rused JavaPajeet?
>>
>>52485774
like in this example: >>52485471
>gameState: Game
you're wrapping pretty much the entire program's state as an input just so you can say that it doesn't have state. it's unnecessary. it's obvious that the game loop would have access to the game's state, it doesn't need to be a function parameter everywhere.
>>
>>52485759
>>52485737
cool - what made you say Haskell is shit? I've been programing in it for a bit and love the semantics. I haven't run into any performance problems, either.
>>
>>52485782

It's impossible to suggest one now, because the semicolon is burned into everyone's mind. As Julian Lennon once said, "It's much too late for goodbye." and so too for the semicolon.

>>52485773

If you're using K&R, then it is. There you use BSD style for functions.

That said, I cannot fucking believe people actually use GNU or Whitesmiths.

I can understand the benefits of Allman & K&R, but GNU and Whitesmiths are fucking diabolically ugly.
>>
>>52485784
>be girl
>write haskell
>imperativefag trolls
>they get associated with my gender

MAKE THIS STOP
>>
>>52485790
ok
>>
>>52485819
>I'm a grill btw :))
>>
>>52485809
All paradigms have their advantages and disadvantages, even Java paradigms
>>
>>52485790
This. So much THIS
>>
>>52485842
Java isn't a paradigm Pajeet
>>
>>52485849
ok
>>
>>52485804
but if it has no effect on speed, why does it matter?

semicolons are just a meme to be fair.
>>
>>52485854
>Java paradigms
>Java the paradigm
Learn to read

You said the paradigms of Java had their advantages and disadvantages. So prove it.
>>
>>52485742
until you spend 16 hours searching for a bug that would have been prevented if you added a ;
>>
>>52485870
Java is good for getting a code monkey job

Java is bad at everything else, basically

This is largely due to the faux-OOP paradigm Java uses
>>
>>52485742
use them please

also use === please

also don't use javascript please
>>
>>52485811
>it doesn't need to be a function parameter everywhere
It isn't a parameter everywhere. It's a parameter at the top level, and then it gets split up when "smaller" subfunctions are called at many levels.

Even in imperative languages, it's good to package up the state into a big structure (and have the update be a state->state function) because of things like fixed timestep with interpolation, delta encoding for networking, buffering between the game thread and render thread, etc.

>>52485815
It's not a bad language, but it's not a good example of the power of functional programming, at least not any more. Forced laziness everywhere is bad for reasoning about performance, and its type system is a bunch of features tacked together haphazardly ending up with "system F-omega modulo everything but dependent types or linearity".
>>
what is your favorite programming language
what about it do you like
>>
>>52485917
Not a JS coder but why not just go all the way and use ====?
>>
>>52485868
Consistency when working with others, clarity, and ensuring that they are placed correctly at all times, and not "guessed wrong" by the interpreter.
>>
>>52485915

>Good for getting a code monkey job
That's not an advantage of the paradigms of Java

Explain to us, oh wise one, what the advantages of every paradigm used in Java are
>>
File: 1452325453364.png (248 KB, 737x583) Image search: [Google]
1452325453364.png
248 KB, 737x583
>>52485917
>also use === please

what if i want to take advantage of type conversion?

do i have to convert it myself?
>>
>>52485921
java

it's simple and consistent while still being highly expressive and suitable for making large applications
>>
File: utter horror.jpg (91 KB, 1278x720) Image search: [Google]
utter horror.jpg
91 KB, 1278x720
>>52485996
>what if i want to take advantage of type conversion?
>advantage
>>
>>52485996
then use it obviously

many people starting out don't know about the gotchas involved
>>
>>52485949
That's an advantage you dumb NEET
>>
>OOP
>games
Are we being raided?
>>
>>52485996
>type conversion
>advantage
doopie poopiedy
>>
>>52486024
>FP
>games
are we being raided?
>>
>>52485941
It doesn't guess though, they are placed logically, and if you understand that logic it is not necessary to include semicolons.
>>
>>52486023
>Java
>the paradigms of Java
retard
>>
>>52486038
just write it with proper style and then use a minifier if you need to
>>
>>52486037
fampai, we talk about FP occasionally here, games? nah, what's going on, there's /vg/agdg for that
>>
>>52486054
not him but why not just use google if you want to find out about oop? is there some kind of point you are trying to make?
>>
>tfw I started this FP discussion
>tfw it proved yet again that anti-FP people just don't have any idea what they're talking about
>>
>>52486038
Obviously there are rules and an algorithm. But the kind of person who lazily omits them likely doesn't know the rules.
>>
I am learning FP in Scala

because it's actually useful in industry

how does that make you feel?
>>
working on teaching myself java for stupid AP computer science class >teacher likes to fucking suck the cock of his custom built computer that he doesn't even know the specs of

Working on learning HTML to make that fancy ass custom start page all you cool fags have

Planning on learning some form of C to make my own damn video game like the idea guy I am.
>>
>>52486071
>implying FP isn't pointless
>implying FP has any advantage besides making you feel smug about using it
sure convinced me
>>
>>52486070
He said every paradigm had its advantages and disadvantages

I'm waiting for him to prove it
>>
>>52486082
I think a lot of advantages were brought up
>>
>>52486095
literally what advantages?
>hurr no state
>except for this state right here that i pass as input
>>
https://dorey.github.io/JavaScript-Equality-Table/
only use i've found for == is checking for both null and undefined in one go
if (optional == null) { ... }
>>
>>52486100
>literally
>hurr
>misinformation
>overuse of greentext
>>>/v/
>>
Holy shit the maths involved in machine learning is some shit. Wish I had done more previously but I guess no time like the present.
>>
>>52486115
>sure convinced me
>>
>>52486122
> >
>>
File: 1452037061036.jpg (55 KB, 379x528) Image search: [Google]
1452037061036.jpg
55 KB, 379x528
>>52486058
honestly though, I hate the "best practices" meme.

just be yourself.
>>
>>52486137
kill yourself weeb
>>
$ cat o.nim 
proc test(n): auto =
if n == 0:
return 0
else:
return 1
echo test(9)
$ nim c o.nim
Hint: system [Processing]
Hint: o [Processing]
o.nim(1, 11) Warning: '(n): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
CC: o
Hint: [Link]
Hint: operation successful (9859 lines compiled; 0.131 sec total; 14.148MB; Debug Build) [SuccessX]
$ ./o
1
$ cat s.nim
proc test(n): auto =
if n == 0:
return 0
else:
return "fuck"
echo test(9)
$ nim c s.nim
Hint: system [Processing]
Hint: s [Processing]
s.nim(1, 11) Warning: '(n): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
s.nim(6, 10) template/generic instantiation from here
s.nim(5, 12) Error: type mismatch: got (string) but expected 'int literal(0)'
$

what is this
Can I not mix return types?
>>
What are some good uses of XOR apart from encrypting and cancelling itself out?
>>
>>52485782
periods or exclamation marks would make sense for terminating statements. historically (before C), semicolons were not for _terminating_ statements, but for continuing to the next one. ALGOL-likes usually used syntax roughly equivalent to the following:
BEGIN
DO_FIRST_THING;
DO_SECOND_THING;
DO_FINAL_THING
END

notice that the final thing has no semicolon, since it is the result of the block. this is more similar to the semicolon's use in human language than what C-like languages use it for.
>>52485737
yeah, my experience working with Idris brings me closer to feeling that it's just trying to clean up Haskell's act, but it's not really creating something totally new. the feeling of programming in Idris is very similar to programming in Haskell, but even if i'm not fully taking advantage of the type system it feels a lot cleaner.
I'm really interested in trying out your language when the time comes because I think you're one of the few people that is interested in making a good general-purpose dependently typed language that isn't just a slightly modified version of Haskell.
>>
>>52486152
>what is static typing
>>
>>52486152
Why the fuck would you be able to mix return types? It's not goddamn python
>>
>>52486158
xor with 1 to flip from 0 to 1 and from 1 to 0
>>
>>52486152
It's got shitty static typing m8
>>
>>52486158
String comp
int cmp(const char *str1, const char *str2)
{
while(*str1 && !(*str1 ^ *str2)) { ++str1; ++str2; }
return !(*str1 ^ *str2);
}
>>
>3+4+5+6*7+8+9
3 4 5 6 7 * 8 9 + + + + +

or
>3+4+5+6*7+8+9
3 4 + 5 + 6 7 * + 8 + 9 +


(I decided to try and write a program to convert to reverse polish notation, but I don't actually know what reverse polish notation is)
>>
>>52486196
oh that's actually cool, will save me some time switching state in chip8 assembly

>>52486213
Oh I was thinking in regards to 0s and 1s, but that's useful too
>>
>>52486158
You can use it to add things together.

101 (5)
010 (2)
= 111 (7)
>>
>>52486175
This is probably something really simple, but then how would something like this be implemented?
http://nedbatchelder.com/blog/200712.html#e20071211T054956
>>
>>52486217
https://en.wikipedia.org/wiki/Shunting-yard_algorithm
>>
>>52486224
>Oh I was thinking in regards to 0s and 1s, but that's useful too
Don't actually use it, it's just something another anon shit out the other day
>>
>>52486230
It doesn't seem to work with all though (5+3 returns 6)
>>
File: 1437719391990.jpg (7 KB, 261x191) Image search: [Google]
1437719391990.jpg
7 KB, 261x191
>>52486204
>shitty static typing
>>
>>52486247
You need to carry bits over. Look at this to learn more.
https://www.youtube.com/watch?v=VPw9vPN-3ac
>>
>>52486078
Like I hope you're reading Rúnar's book.
>>
>>52486230
yep it's like an add without carry

0 ^ 0 = 0 + 0 = 0
0 ^ 1 = 0 + 1 = 1
1 ^ 1 = (1 + 1) % 2 = 0
>>
>>52486233

Return an option type or an error type
(Not sure what these are in nim, but you could implement them)
An option type:

Some i
(Succeeded, value is int i)
None
(Failed)

Error type:

Success i
(Succeeded, value is int i)
Error "could not parse"
(Failed, error string is "could not parse")
>>
Was reading some lecture notes.
There was a function for determining prime numbers.

bool isPrimeNumber(int x);
typedef enum {false, true} bool;
int i=2;
while(i<=x-1){
if (x %% i != 0) {
return true;
}
else {
i++;
}
return false;
}


for the while statement, wouldn't it be more efficient to do while (i<=x/2) ? because given you are searching for a prime number, there exists no divisor greater half the dividend for a prime number? or am i just crazy and stupid here?
>>
>>52486213
Saw that in a thread a day or so ago and now just wrapped my head around how that function actually works.

Thats pretty neat not gonna lie.
>>
>>52486347
>wouldn't it be more efficient to do while (i<=x/2)
yes

you can check up to as little as sqrt(x)
>>
>>52486255
I've got an add function already, but that's interesting
>>
>>52486347
>, there exists no divisor greater half the dividend for a prime number? or am i just crazy and stupid here?
None greater than the root.
>>
>>52486347
None greater than the root famalam
def isPrime(x):return len(i for i in range(2, int(x ** 0.5) + 1) if not x % i) == 0
>>
>>52486255
nand2tetris had me build something like this, it was pretty fun, though somewhat tedious
>>
>>52485537
>No advantages to immutable data structures
No race conditions
>No advantages for pure functions
No need to implement locks when writing multithreaded programs.
The overhead for locks nullifies the functional programming is inherently slower meme.
By the time you realized, that your code inherently sucks you could have written code that was easier to reason about.
>No advantages to functional programming
K
>>
>>52486530
>immutable data structures are exclusive to FP
TOP KEK
>>
>>52486530
KILL YOURSELF TARD
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [Google]
1451683583776.gif
2 MB, 400x600
Stopping Pong in CHIP-8 because I don't like the way I've written conditionals and the way I've repeated lines because I'm ignoring subroutines, as well as touching up my assembler to accommodate labels.

I think I know a way to go about fitting Nokia Snake in chip-8's 4kb ram. Instead of having a byte to store the x and y positions of each node, I just store the relative position of each node using 2 bits. The first is 1 if down, the second is 1 if right, so 10 is down and left. To fill the 2048 pixel screen would only take half the ram, 1/8 if I were to fit 4 2-bits in each byte.

As for drawing, should just be a simple matter of drawing onto the tail to cancel it out and then drawing on the new head, rather than re-drawing everything.

It's going to be a fun project lads
>>
>collaborator on a project recommended I use PyCharm to me.
>philosophy is clearly "OO or fuckoff" and doesn't have navigation for functional heirarchy in the file - you know how the code is actually, physically run.
>line numbers not being on by default should tell you enough.
>the tics are completely useless and wrong, you have to ignore a
>default character limit is 120 instead of 79 which is pep8 standard.
>this in an IDE that has pep8 tics on by default.
>(as far as I can tell) console doesn't allow to run sections/cells of partial code.

I'd be more productive writing code in fucking CLI editor I swear to christ.
>>
>>52486635
what if it's dead-right, ie, there's no up-down component? 2 bits only allows 4 states, and on a 3x3 grid when you're at the center there are 8 other states.
>>
>>52486152
Why would you even need to differentiate between types on return if you didn't actually need to return a particular type?

The nerve of some people!
>>
How do I become the very best programmer in the world ever?
>>
>>52486700
>using any python editor that isn't IDLE

>>52486726
>dead-right
Ah thanks for that, it would be 4 bits then (even if you could squeeze it into 3 bits, I'm not hardcore enough). So assuming up-down-left-right, dead-right would be 0001. I will have to take great care in making sure 11xx or xx11 never happens, but at least now I can fit all my nodes in half a byte rather than 2 bytes (or1.5 bytes if I squeezed it more)
>>
>>52486213
is that like a !contains and concat function?
>>
>>52486748
Well, unless you're adding diagonal, you can still fit it in 2 bits, like an enum for LEFT RIGHT UP and DOWN. You would need an additional way of saying "this is the end of the list" as well, mind.
>>
>>52486738
Anyone who's asked that question has not become the best programmer in the world, so you're off to a bad start
>>
>>52486748
>IDLE
this is trash
Tried using it to write Vapoursynth scripts, and I'm like, "does this thing really only have autocomplete?"
What a trash IDE.

From a guy used to using Visual Studio everything else seems to pale in comparison.
>>
File: i feel so naughty.png (84 KB, 648x857) Image search: [Google]
i feel so naughty.png
84 KB, 648x857
Sometimes I wonder if D makes using templates too easy
>>
>>52486782
Fuck off please!
>>
>>52486777
>Well, unless you're adding diagonal
not for nokia snake, or for any chip-8 game
>enum
I'd still need an extra bit to show if it's going horizontal or vertical. Even if I keep that information in a separate list, it's still messy and if I can fit something simpler in 4k ram with my code, I'd rather do that.
>>
>>52486700
>79 which is pep8 standard
it's as if everything about python is intentionally retarded
>>
>>52486783
autocomplete is all you need for an IDE, even then if you know the language, it's not really necessary, and sometimes it can bog you down, for example in Notepad++

>VS
seriously hope
>>
>>52486824
kill yourself
>>
>>52486783
>IDLE
>IDE
It's an interactive development and learning environment. It's not trash as long as you use it as designed - a nice REPL with an editor tacked on the side for convenience.

>>52486805
surely you can identify the direction of the segment by looking at the node ahead and behind? If the element before is above, and the element after is right, you need an "L" shaped bit. f it was left and the next is right, you need "-". In any case, there are a lot of solutions.
>>
>>52486838
SHIGGERY DIGGERY DOO
>>
>>52486812
I think 80 is decent, I don't if it's actually 79 that's just what I've been told.

Anything more than 80 is crap though.

Yes, I get that you 6 screens, but it's easier to read stacked columns that are closer together.
>>
>>52486824
enjoy your no integrated debugger, definition peeking, and refactoring
seriously 80% of my gripes is that it has no debugger features.

And if I remember, it doesn't even syntax highlight.
At some point I started copying from IDLE to the Vapoursynth editor just so I could get definitions and syntax highlighting.
>>
>>52486764
Whoops just saw that there was no concatenation, it was just incrementing pointers. Please ignore me.
>>
>>52486700
Holy fuck. This piece of bloatwhare is using 0.7 GiB of RAM.
>>
>>52486914
>the moon lander couldn't run this text editor
>>
>>52486914
still less than google chrome
>>
>>52486987
the memory usage isn't half as annoying as the process count
>>
A generic LL(1) parser in C.
>>
Can /dpt/ average two strings in C?

char* average(char* a, char* b)
{
return ((a+b)/2);
}
>>
>>52486839
>surely you can identify the direction of the segment by looking at the node ahead and behind?
You can't read the screen, and storing the positions of nodes was the original issue using up too much RAM. Even if you were to draw on top of each tile to see if it sets the collision flag, it would not work if a snake node was adjacent to 3 different snake nodes.
>>
>>52487047
ah, fair. I thought you could store them in sort sort of stack.
>>
>>52487088
Oh to add, I remember why I thought 2 bits was a good idea. And it's pretty much your enum idea. I don't know why I thought I'd need an extra bit to see if I'm going horizontal or vertical. If I set it like 00-up, 01-down, 10-left, 11-right, I can do a shift right, and the remaining bit would determine if it's horizontal or vertical and the carry bit would determine if it's going towards upper-left or lower-right
>>
>>52487039
>can /dpt/ do my homework for me
>>
>>52487205
it's a meme you dip
>>
>>52487205
what?
>>
>>52487039
>off by a half
disgusting
>>
void Calculate(){
Calculate();
}
>>
>>52487285
void Calculate()
{
Calculate();
}
>>
>>52487294
ew that looks disgusting
>>
>>52487285
>>52487294
code blocks you animal
>>
>>52487294
void
Calculate(
)
{
Calculate(
);
}
>>
>>52485996
>advantage of type conversion
TRIGGERED
>>
>>52487294
void Calculate() { Calculate(); }
>>
let rec Calculate = Calculate
>>
>>52487389
void
Calculate
(
)
{
Calculate
(
)
;
}
>>
>>52487285
Now we're cooking!
>>
File: mfw.jpg (146 KB, 820x615) Image search: [Google]
mfw.jpg
146 KB, 820x615
Sometimes I almost don't believe how much of a fucking retard I am
>>
>>52486700
Use whatever you want.
>>
File: lmaodudweed.jpg (62 KB, 500x422) Image search: [Google]
lmaodudweed.jpg
62 KB, 500x422
ok geniuses. Explain this
>>
>>52487490
Of course I use whatever I want, that doesn't mean I'm not allowed to try or critique other IDEs.
>>
>>52487494
Stupid Americans who can't even line up a projector properly.
Also that image is fake.
>>
> VB and C# code base
> majority logic in forms, rest of it in the database
> internal business forms app
> 200 users

How to migrate from omnipotent forms app to glorious n-tier architecture?
>>
>>52487494
20 / 5 (2 * 2)

Brackets before Division before Multiplication
20 / 5 * 4
Division before multiplication
4 * 4
16
>>
>>52487494
using / as an operator in that sense is extremely ambiguous and mathematically invalid.
>>
>>52487494
real common core would say that the old way is wrong
>>
>>52487524
>>52487526
both of these

real mathematicians just right it out as fractions
>>
>>52487523
>Division before Multiplication
They have the SAME precedence, but are left-associative.
>>
>>52487543
Division has higher precedence
>>
>>52487571
>american education
>>
>>52487571
>This is what Burgerclaps actually believe
Division and multiplication are the same operator. All division can be represented by multiplication and all multiplication can be represented by division.

x / y = x * (1 / y)

It makes no sense for either to have high precedence than the other.
>>
>>52487571
No. Division and Multiplaction have the same precedance, and are done left to right.
>>
>>52487598
>>52487603
>>52487609

British education.
Division before multiplication.

Division and multiplication are not the same operator.
>>
>>52487686
That doesn't make you any less retarded.
I was educated in New Zealand of all fucking places, and they very clearly stated that multiplication and division, as well as addition and subtraction are the same precedence, and is done left to right,
>>
>>52487686
kill yourself you can easily check it for yourself just plug an expression into google or whatever

it doesn't even really matter since you get the same result but it's still left to right. if anything it would be that multiplication takes precedence but they have equal precedence, same with addition and subtraction.

semi-related: http://en.cppreference.com/w/cpp/language/operator_precedence
>>
>>52487686
>These mnemonics may be misleading when written this way,[7] especially if the user is not aware that multiplication and division are of equal precedence, as are addition and subtraction.
https://en.wikipedia.org/wiki/Order_of_operations
>>
>>52486792
The dark side of the force can be more seductive, but it is not more powerful.
>>
So does anyone else agree with me about the problem?
>>
>>52487733
mnemonics are usually shit the concepts should just stick in your brain with your own mental model of how it works if you aren't retarded
>>
>>52487740
what problem?
>>
>>52487494
>infix notation
lel, peasants.
>>
>>52487755
You know.
>>
>>52487713
>>52487726

It is a custom, division before multiplication is how we do it. There's no "mathematical truth" to one way or the other, it's just a matter of syntax and convention.

One of the reasons we do it this way is because of how it looks when it's actually written. We don't write 1 / 2 we write ½.
>>
>>52487746
Apparently you can't read. This is the important part
>multiplication and division are of equal precedence, as are addition and subtraction
>>
>>52487765
>>52487686
>British education
>>
>>52487762
Needs a better logo
>>
>>52487765
So, to detractors, does

½ * 2 equal 1, or 1/4?
>>
>>52487765
>It is a custom
No, it's just incorrect. Being retarded isn't a reason to continue being retarded.
>>
>>52487765
god damnit you fucking tard

if it's written like this:
  1
____
5*5


you do 5*5 first so it's 1/(5*5)

½*(4*4) is the same as (1/2)*(4*4) so in that case you do divide first
>>
>>52487772
HOW FUCKING RETARDED CAN YOU GET

I FUCKING KNOW THAT AND I READ IT

MNEMONICS ARE STILL SHIT WITH YOUR SOHCAHTOA AND GAY SHIT FUCKING MURRICANS
>>
>>52487778
That will always and forever be one
>>52487805
Calm down faggot
>>
>>52487778
FUCK FUCK FUCKING RETARD I'LL RAPE YOU IN THE ASS

MULTIPLICATION AND DIVISION HAVE EQUAL PRECEDENCE AND IT GOES LEFT TO RIGHT SO OF COURSE IT'S 1 YOU FUCKING RETARD IT HAS NOTHING TO DO WITH 1/2 VS ½

PLUG IT INTO GOOGLE AND THERE'S YOUR ANSWER
>>
20 5 / 2 2 * *

there
perfectly unambiguous
>>
ONLY A FUCKING SPERG WOULD RATHER LEARN A STUPID FUCKING WORD THAN ACTUALLY UNDERSTAND THE MATH CONCEPT SO YOU DON'T HAVE TO "DECRYPT" THE MNEMONIC EVERY TIME BEFORE YOU USE IT
>>
To all the fags arguing over this

Left to right same precedence
and
division before multiplication

ARE THE SAME THING AND ALWAYS HAVE THE SAME RESULTS

jesus christ
>>
Congratulations /dpt/ you're as bad as /b/.
>>
>>52486530
>No race conditions

L
M
F
A
O
>>
why is the idris compiler so slow holy shit
>>
>>52487872
I KNOW THEY HAVE THE SAME RESULT (SEE >>52487726) BUT WHEN WRITTEN OUT IT'S LEFT TO RIGHT WITH EQUAL PRECEDENCE AND IT'S WHAT EVERY NON-TARD HAS AGREED UPON

ENTER A MATH EXPRESSION ON GOOGLE OR WOLFRAMALPHA OR WHATEVER AND YOU'LL SEE
>>
>>52487824
>>52487860
>>52487897
>being this physically upset
>>
>>52487897
>I KNOW A AND B ARE THE SAME
>BUT LET ME TELL YOU WHY A IS RIGHT AND B IS WRONG
ok man
>>
File: 1418782931646.jpg (50 KB, 500x500) Image search: [Google]
1418782931646.jpg
50 KB, 500x500
>tfw bf wakes you up with sex

now that I'm awake I'm working on finalising the design for my toy language :3
>>
File: I'LL READ THIS LATER.png (40 KB, 643x689) Image search: [Google]
I'LL READ THIS LATER.png
40 KB, 643x689
>>52487915
>>
Addition: A + B
Subtraction: A - B
Multiplication: A x B
Division: A / B
Exponentiation: A ^ B

Logarithm: Log B of A
Root: Root B of A

Why are these backwards?
Why don't they get symbols?
>>
>>52487954
Logs and roots are functions.
>>
>>52487980
>British Education
>>
>>52487954
Root B of A can be represented as A**(1/B) in some languages. So in that regard it does have a symbol.
>>
>>52487916
kill yourself, degenerate
>>
File: 1411940731193.jpg (13 KB, 400x449) Image search: [Google]
1411940731193.jpg
13 KB, 400x449
>>52487995
>I'm American
ok
>>
>>52487916
That's gay
>>
>>52487997
same as A^(1/B)

and logx and ln are kinda symbols too just not a single character in length

>>52487980
also this
>>
>>52487997
But why do you have to say (1/B)
Why does the written version go
B (radical) A
>>
>>52487980
Everything is functions. What's your point?
>>
>>52488024
nigga this is basic math

2^2=4
2^1=2
2^0.5=sqrt(2)
2^0=1
2^-1=1/2
2^-2=1/4
>>
>>52488047
I know that shit you absolute fucking retarded cunt

You apparently don't fucking realise there's a goddamn symbol called the radical fucking symbol, I guess it's too fucking radical and cool for you you stupid autistic piece of shit

a√b = b^(1/a)

holy
fucking
shit

what i'm asking you, you son of a bitch, is why the symbol is fucking backwards and why there isn't one for logarithms

thanks
>>
>>52488063
WHAT THE FUCK YOU FUCKING TARD

of course i know the radical fucking symbol

how is the symbol "backwards", what the fuck?

log, ln works perfectly fine
>>
File: USo7bEN.png (120 KB, 1541x719) Image search: [Google]
USo7bEN.png
120 KB, 1541x719
shit gettin real bois
>>
>>52488063
>a√b = b^(1/a)
no it doesn't, a√b = √a*a*b
>>
>>52488074
>>52488063
Anons stop, we're getting worried
>>
>>52488090
he's talking about the ath root, not a*sqrt(b)
>>
>>52488090
i meant [sup]a[/sup] but there's no [sup]
>>
There is a very booty-bothered anon in our midst
>>
>>52487872
>division before multiplication
Only if the identity rule applies.
>>
>>52488105
You just answered your own question as to why there's no operators for sqrt or log. It gets convoluted really quickly when you try to shoehorn every operator into a character set. Just include the basic arithmetic as single character operators and use sqrt(), log(), for more complicated operations.
>>
Programming test for employment to write a script that combines CSV files.

I coded it up procedurally, but I'm wondering if I should OOP instead.

What does /dpt/ think? Written in PHP.
>>
>>52488128
Your code is very compact.
>>
>>52488127
No I didn't
That's like saying that the argument earlier is proof that / should be a function and not an operator
>>
>>52488128
Did you remember to check the file exists?
>>
>>52488141
S P E R G
P
E
R
G
>>
Holy fuck you guys, not being Asian is suffering right?

kill yourselves
>>
>>52488141
You could argue that / should be implemented as a function and not as an operator. Too bad for you the ASCII character set is already established and '/' was included.
>>
your education sucks apparently or you're dumb as shit

these get special symbols:

https://en.wikipedia.org/wiki/Elementary_arithmetic
>>
>>52488171
b-but, every esoteric math function should get its own symbol on the keyboard. simplicity be damned!
>>
What does 'i' get a key but sqrt doesn't? Makes no sense.
>>
File: primfuns_432x391.gif (74 KB, 432x391) Image search: [Google]
primfuns_432x391.gif
74 KB, 432x391
>2016
>not using APL
>>
Have you ever made a starry night simulation with random shooting stars and shit, /dpt/? Seems like it would be a fun, easy project.
>>
>>52488223
What are stars?
>>
>>52488228
taytay is a star
>>
why is there no one talking about programming here
>>
>>52488182
>>52488198

>root - esoteric
>log - esoteric

t. 3 year old
>>
File: OpenGL-ES-2_0-Reference-card.png (2 MB, 1944x1320) Image search: [Google]
OpenGL-ES-2_0-Reference-card.png
2 MB, 1944x1320
>>52488223
i haven't but it would be a cool thing to make using opengl
>>
>>52488240
it's /dpt/
>>
>>52488228
A fixed luminous point in the night sky which is a large, remote incandescent body like the sun.
>>
File: dpt in a nutshell.jpg (236 KB, 1624x626) Image search: [Google]
dpt in a nutshell.jpg
236 KB, 1624x626
>>52488201
best language
>>
>>
File: dynamic.png (593 KB, 1281x644) Image search: [Google]
dynamic.png
593 KB, 1281x644
Why would anyone want dynamic typing?
I don't see any reason to want dynamic typing other than "I am lazy and don't want to cast all the time" or "I am an artist and my variables should be as abstract as my paintings, casting detracts from my artistic direction"
>>
>>52488241
How often does the average person use log?
>>
>>52488261
It's all ones and zeroes anyway. The only difference is how it gets interpreted.
>>
>>52488261
if you want to write masculine code
>>
>>52488240
code monkeys go to wdg
>>
>>52488261
Why do you presume a variable wants to be an int or a char? Check your privilege.
>>
File: 1369359761327.jpg (25 KB, 221x221) Image search: [Google]
1369359761327.jpg
25 KB, 221x221
>>52488282
I'm so sorry, I hadn't realized.
My privilege is now fully checked.
>>
>>52488261
because they're stupid as shit and too lazy to learn programming
>>
>>52488262
The average person takes a log twice a day
>>
>>52488297
>average

Where on earth is that average?
Thread replies: 255
Thread images: 28

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.