[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: 330
Thread images: 38

File: S-1228080-www.kaifineart.com-3.jpg (124KB, 700x913px) Image search: [Google]
S-1228080-www.kaifineart.com-3.jpg
124KB, 700x913px
Old thread: >>57635912

Javascript best language edition
>>
File: functional programming.jpg (64KB, 440x389px) Image search: [Google]
functional programming.jpg
64KB, 440x389px
>>
>>57639069

Exactly. It's insanity.
>>
First for if you're not using c++ you're wasting you're time
>>
guys please. I need a good answer here.
pick one option:
C -> C#
or
C# -> C
>>
>>57639092

C# -> C#
>>
>>57639092
They only share syntax, they're both very different from one another so it doesn't matter
>>
File: mi.gif (247KB, 640x640px) Image search: [Google]
mi.gif
247KB, 640x640px
post a screenshot of your programming environment
>>
>>57639104
that isn't an option
or you could look it at another way - it's a logical conclusion of any of these choices
>>57639110
but wouldn't some languages be naturally better for learning first compared to another "similar" one?
>>
>What happens if i do this?
>What result will that give?
>Will this compile?

I always end up doing trial and error programming. Is this really how it should be?
I can't help but feel i'm doing it wrong.
>>
File: 1464763565326.png (56KB, 782x790px) Image search: [Google]
1464763565326.png
56KB, 782x790px
>>57639137
i really like this gif
can i save it
>>
>>57639164
ye
>>
File: 0_Screenshot_20161122-183500.png (117KB, 1440x2560px) Image search: [Google]
0_Screenshot_20161122-183500.png
117KB, 1440x2560px
>>57639137
> he's not programming on his phone
>>
>>57639137
just jerked off
>>
please guys
Need an answer on this one. >>57639092
>>
File: penguin.jpg (41KB, 600x424px) Image search: [Google]
penguin.jpg
41KB, 600x424px
Are there non-assembler cache-aware programming languages?
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Computational Conjurer is okay
Information Systems Sorcerer is okay
Purveyor of Programs is okay
Code Guru is questionable

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
>>57639212
Assembly
>>
File: trump-wink.gif (3MB, 498x280px) Image search: [Google]
trump-wink.gif
3MB, 498x280px
What is O-Auth good for?
I just used a POST request to the endpoint and that was it. Everything worked and I didn't use any O-Auth library
>>
>>57639227
Threadly encouragement to fuck off.
>>
>>57639092
Can anyone please be so kind as to answer this?
>>
Any beginners guide for embedded programming with C or asm ?
>>
>>57639051
so python question
I have the following code but want to know if there's a way to make each value save if that makes sense
repeat = input("Enter how many times you would like the script to repeat")
for i in range(repeat)
number = input("Enter your number")

so if the user makes the script repeat five times I want to be able to add up all the five numbers he enters (for example) the key aspect is the user can pick how many times the script repeats and only enters one number each time it repeats

this isn't homework just looking to improve a script I'm making
>>
>>57639141
>that isn't an option

something something prepositional logic
>>
>>57639267
in Haskell this is just replicateM

request :: Read a => String -> IO a
request s = do
putStrLn s
readLn

results :: Read a => IO [a]
results = do
repeat <- request "Enter how many times you would like the script to repeat"
replicateM repeat (request "Enter your number")
>>
I'm writing a programming tutorial for young kids
>>
>>57639304
So do you love working with young kids?
>>
>>57639304
are you writing a tutorial for yourself?
LMAO
>>
File: chris-hansen.jpg (26KB, 352x707px) Image search: [Google]
chris-hansen.jpg
26KB, 352x707px
>>57639314
>>
>>57639315
How would I write a tutorial for myself

>>57639314
No but I am interested in how people learn how to program
>>
>>57639342
Answer this god damn question then.
Just pretend i'm a young kid >>57639092
>>
>>57639348
Neither you retard
>>
>>57639364
What? WHY?!
>>
>>57639342
>No but I am interested in how people learn how to program
Kek. It varies by people. Depends on talent and innate ability too.

Also, look at Colobot/Ceebot. The idea is cool.


>>57639348
C then C#. Honestly in a way C is simpler and teaches you some under the hood stuff which languages like C# / Java don't push that much or even abstract it away totally.

It's enough to get good grounds in C then you can move on to something else.
However I would be interested to know why?
C and C# has nothing to do with each other, so why?
>>
File: 1477339240066[2].jpg (73KB, 784x534px) Image search: [Google]
1477339240066[2].jpg
73KB, 784x534px
>>57639314
>tfw unironically love working with kids
>tfw not a degenerate just want the kids to have a wonderful childhood
>>
>>57639348
Learn scripting shit like ruby

it's the easiest way to actually get useful programs going so you'll stick with programming
>>
>>57639390
>>tfw unironically love working with kids
I hope you aren't a porn actor.
>>
>>57639348
C first any day

http://www.di.unipi.it/~nids/docs/why_you_should_learn_c_but_probably_never_use_it.html

>>57639390
literally this famala
>>
>>57639051
finally finished my course completion work (is that how it's said in english?)

It was a small nightmare but most things went well

I had to make an C# application, an SQL database and a windows phone app

the entire work was basically:
database
C# program
Java program
asp.net website
android app
windows phone app

the rest of these things were made by the rest of my group
>>
Having to write a bunch of unit tests for this codebase for a class. No documentation on the code, so no idea what it's actually supposed to be doing in a few places.
>>
>Cfags will defend this
#include <stdio.h>
#include <stdlib.h>

int main(){
float the_measured_angle;

puts("Addition");
for(the_measured_angle = -360.0; the_measured_angle < 360.0; the_measured_angle+=0.001){
printf(" %7.3f\n", the_measured_angle);
}

puts("Multiply and Divide");
the_measured_angle = 3.0;
for(int i = 1; i <= 100; i++){
printf(" %7.3f\n", the_measured_angle);
the_measured_angle = the_measured_angle * 1.001;
}

}

with Ada.Text_IO; use Ada.Text_IO;

procedure Fixed_Point is
type Angle is delta 0.001 range -360.0..360.0 with Small=>0.001;
package Angle_IO is new Ada.Text_IO.Fixed_IO(Angle);
The_Measured_Angle : Angle;

begin
Put_Line("Addition");
The_Measured_Angle := -360.0;
while The_Measured_Angle < Angle'Last loop
Angle_IO.Put(The_Measured_Angle); New_Line(1);
The_Measured_Angle := Angle'Succ(The_Measured_Angle);
end loop;

Put_Line("Multiply and Divide");
The_Measured_Angle := 3.0;
for I in 1..100 loop
Angle_IO.Put(The_Measured_Angle); New_Line(1);
The_Measured_Angle := The_Measured_Angle * 1.001;
end loop;

end Fixed_Point;
>>
>>57639427
>a windows phone app
What third world country is this?
>>
>>57639265
It'd be platform specific wouldn't it? Try an arduino
>>
>>57639389
Can you define good grounds in C?
What do you mean by why? I don't get it.
>>57639403
But I'm not scared of anything and I don't care about scripting. I just want to know the answer. I don't need something to make my stick with programming since I'm already pretty interested.
>>57639410
Thanks mate I'll read it right now after masturbating
>>
>>57639448
What kind of programs are you currently thinking of writing? :^)
>>
>>57639448
>Can you define good grounds in C?
It's late, sorry. I meant that it's enough to get good in C then you can move on. You don't need to do everything in C, but knowing it at a somewhat competent level is helpful. Unless of course you want to work with that kind of shit.

It would help if could explain what is your background, how much do you know about programming and why did you make that C->C#/C#->C post.
>>
>>57639439
brazil

it was basically to inflate the work, it was supposed to be a windows phone 7.1 app, so we had some experience with xaml basically
>>
>>57639474
*answers this question*
>>57639476
I see. That's what I'll do I guess.
*answers the question about my background*
>>57639092
Anyone else willing to answer this?
>>
>>57639092
C# -> C

you'll get bored way too fast with C first
just learn C#, make some programs and shit, and when you feel you're ready, go to C, it'll be less painfull
>>
>>57639141
C# is better for learning first because it's easier
>>
>>57639512
at what point should I get bored?
>>57639522
0_0
>>
>>57639534
when you're trying to make simple stuff and failing miserably because of simple details

always go from the easy language to the hard language, not the opposite
>>
>>57639534
>0_0
C# handles memory allocation by itself with garbage collection and some other stuff. You gotta do all that stuff yourself in C. You'll get bored with C because instead of doing programming that results directly in the stuff you want to do, you have to handle a lot of the intermediary stuff behind the scenes which can get tedious
>>
Anyone care to help me out with some geometry?

This method is intended to create a grid of hexagons, but the results are bonkers. I must be doing something fundamentally wrong. Any ideas?

http://pastebin.com/ZKxCv7bX
>>
>>57639559
anyone willing to offer counterpoints to this?
would it hurt in the long term if im not retarded and I can adapt to harder stuff/concepts over time?
>>57639572
I guess that makes sense as well.
>>
>>57639578
>anyone willing to offer counterpoints to this?

NO! NOW LEARN C# GOD DAMN IT!
>>
>>57639584
(゚∀゚) angry post!
>>
I'm making some hot chocolate
>>
>>57639593
i'll be making some soon too.
just ate a whole bunch of spicy food
>>
>>57639578
FIRST LEARN THE EASY STUFF, THEN LEARN THE HARD STUFF

IS THAT SO HARD TO UNDERSTAND?
>>
>>57639578
I think literally every CS program in the country will have you start on a language like C#, Java, or Python first, then you'll learn C or C++ in like, your 3rd year of college. You won't suffer for learning C# first. You have to learn to tie your laces before you learn to walk
>>
>>57639227
>Not knowing what a wizard is...
GTFO you fuck. Go and read the jargon file.
>>
>>57639604
but it's hard and easy at the same time
it's hard in that its literally hard
but it's easy in that it's more "basic" so to speak
>>57639614
i don't recognize university programs as legitimate
but your second/third point makes sense
>>
>>57639578
I'd say it depends on which features do you need in the language

but probably go with c#
>>
>>57639629
i wish I could answer this question mate but if you absolutely need an answer
*answers your question*
>>
>>57639626
first you learn how to use a pen, then you learn how to make a pen exactly how you want
>>
>>57639614
>>57639614
In Europe it's the other way around, at least here, for both CE/CS. You start with C in the first semester then Java + Assembly the next. After that C++.
>>
>>57639626
>I don't recognize university programs as legitimate

It's your choice. The other reason that they teach these languages is because it's easier to teach algorithms and data structures when you don't have to get lost in the details of memory management
>>
I'm considering writing a small access point and or router from the ground up, no OS. It's not gonna be some major thing tons of people rely on so it's not that important that everything is super rigorous or anything. I know networking but I'm questioning I'm thinking through all the things I should.

So I'm just wondering if any of you know of any small open source embedded networking systems I could look at? Preferably very small. I can't imagine the entire piece I'm writing should be more than 10k SLOC at most. And I'd like to find something around that size.

Preferably in C.
>>
The amount of codemonkeys in this thread are astonishing.

Learn C first. Know the machine, then you can move on to C#.
>>
>>57639665
Does every college in Europe really have the same curriculum?
>>
>>57639665
why would anyone fucking care how universities teach shit? they aren't efficient in any way especially if we're talking about e*rope
>>57639675
i didn't say that particular choice was bad. i said that universities are not a legitimate source of choosing a learning method. they are literally shit
>>57639681
what would you define as learning c?
>>57639694
yeah it's probably mandated by the eu as well. nothing surprising it's fucking e*rope we're talking about
>>
>>57639092
what are your objectives?
what are you trying to accomplish?
what timelines are you working with and what's your prior knowledge?

are you trying to ruse me?
>>
>>57639675
>Algorithms and datastructures
Not that guy but I hear this so much I'm questioning what else you learn at university. Really those two are no big deal. Where's the code architecture courses, modern programming for modern computers, Principles for API design and such things?
>>
>>57639681

You're probably good at programming, but you probably don't know shit about teaching.
>>
>>57639681
>making useful things is less important than understanding every little thing about it

it's like saying:
>hurr durr why don't you grow your own vegetables instead of buying them??
>>
>>57639706
*answers every single on of your questions except the last one*
no i'm not. i just want an answer!
>>
>>57639438
>-359.930 + 0.001 = -359.928
Thanks C
>>
Since some people can be really finnicky about how input is done, what's the best way to handle input in Javascript?
I'm doing WebGL stuff, and I've made a pretty good WebGL engine, but I've not once made Javascript that can take input.
>>
>>57639681
Learn intel micropts first. Know the machine, they you can move on to C.
>>
>>57639702
>learning C
Learn the basic hello world stuff, control flow, loops and simple memory management (malloc, free and a few pointers on how you could use it). And pointers.

It's a small language, should deal with that much in maybe 3 weeks or so to know it fairly well.

Don't bother learning the entire standard library.
>>
>>57639727
lmao
i already have a good enough grasp of all of that
this can't be all, right?
i haven't built anything complex with it though.
>>
>>57639694
No. Not at all. Varies a lot university to university. The legitimacy of a degree region to region is an issue solved by external agencies usually.
>>
>>57639745
i would have to learn a little more about pointers though but i'm doing that right now as we speak, i was anyway before righting these posts.
i'm sure this can't be all there is to learn to say you know even the basics of C. or am I wrong?
>>
>>57639694
No, that's why I said "around here".

Although there is ECTS so you can transfer credits.
Most CE/CS courses in my country do focus on knowing the underlying shit though. You will probably know Java by the time you reach Algorithms and Data Structures I.

On the other hand, it's not that good in some ways. Those who can't do it will either get rekted in their first year - time to retry next year - (pass rate is 30% in some subjects) or they will simply drop the fuck out.

>>57639702
>why would anyone fucking care how universities teach shit? they aren't efficient in any way especially if we're talking about e*rope
What? Please don't be angry, but American universities started out in the early 20th century by modeling European universities. For example MIT. Don't spout shit about stuff you don't know.
All I was doing is making a counterpoint to anons university example.
>>
>>57639745
Well try and imagine something you couldn't do. What you probably end up with is specific OS interfacing things like networking and graphics. Knowing that amount of C lets you appreciate when other things become a burden. It lets you understand there's a path outside of OOP for instance. Which many OOP programmers struggle with.
>>
>>57639710
Whether you can grasp C on first time when you get introduced to programming is a major breaking point. It decides whether you are more of a code-monkey or real programmer kind of guy with possible interests in CE/EE.

On the other hand I do know about teaching programming.

If the guy is a pleb then I would start with either Python or Java.

However if you're all by yourself, then it's ok to try out your limits.
>>
>>57639765
Well its deceptive in how simple it is, just being imperative language. But interfacing with computers isn't all that hard so it's to be expected.

I was just saying that when you're done with that you can decide to make something or you can decide to learn more in other areas.
>>
>>57639709
Have you ever gone to university? Here's how it goes in America:

>1st year:
>Some social science class like Gender Studies
>Stupid University 101 course
>English 1
>Math pre-requisites depending on how you did in highschool
>electives
>two basic java/python classes

>2nd year:
>more social sciences
>more math
>more electives
>algos/data structures and computer organization and architecture

>3rd year
>more math
>general science requirements, like physics or biology
>Systems programming, software design, maybe 2 or 3 cs classes

>4th year
>more cs classes
>maybe some higher math
>maybe 1 or 2 electives

Social science departments get their budgets by leaching off of engineering majors. We have to take english and shit but do they have to take CS? Noooo
>>
>>57639715
Knowing C is nowhere near that level. Honestly if you can't grasp pointers and C then you're a codemonkey.

It's an effective way to kill of idiots. Maybe you learn it first, but you should definitely do.

On the other hand, most people who come from a very high-level language are usually utter shit in a lot of programming/computer concepts.
>>
What should I work with in OpenGL: Pixels or clipspace?
>>
>>57639773
>Well try and imagine something you couldn't do
well that isn't hard lol
pretty much anything besides what I can do.
> What you probably end up with is specific OS interfacing things like networking and graphics.
yeah I guess.

so in your opinion I should get better with C and then move on to C#? or is now the time?
You could say I know all of the shit in >>57639727
I will definitely in a few days.

>>57639806
Yeah. It can't be this simple. Haven't really encountered any major thing I couldn't grasp by thinking about if for a while.
didn't really understand your second line though.
>>
>>57639824
Ehhh

at least it makes people well rounded or something
>>
>>57639838
>second line
Well I'm just saying. Computers are just machines that take some numbers, does some math on them and then places them in memory somewhere. That's really all computers do. Audio is just a bunch of numbers the sound card takes care of to make the speakers vibrate. You just have to do whatever you wanted to do with them and then move them to the right place. Usually you have an operating system between you and the sound card. Which just means you ask the OS where to put your numbers.

The basics isn't really hard at all. So because C is relatively low level just doing things becomes pretty easy.

See handmadehero.org for instance. They do a game from scratch. It's probably pretty interesting for a new programmer like you to look at the first few videos. Because he very quickly gets far while doing the very basics.
>>
>>57639948
Why don't art majors have to be well rounded
>>
>>57639948
ah, you've tracked down america's obesity problem.
>>
>>57639985
So universities can make money

it would be pretty good for them to at least take some physics and math but it will never happen
>>
what's the best way to get gcc or clang on windows these days
>>
>>57640124
>gcc

mingw
>>
>>57639715
if you don't know C, there's a good chance you don't know your program works
>>
>>57640124
doesn't windows have bash now?
>>
>>57639838
>so in your opinion I should get better with C and then move on to C#?
I prefer C. So if I were you I'd stick more with C. It makes you more unique either way.

But you're not me. It really depends. The objective of most languages beyond the low level languages like C is to alleviate the programmer of responsibilities and burdens. So if you're in C you have to write a lot of stuff like saying what types you have, integer float etc etc, when you want something allocated so it stays in memory regardless of if you move out of scope or not and more.

If you take other languages they often avoid these things. C# and Java use garbage collection, so you don't call malloc/new or free/delete, the environment handles your memory for you. In Python they also do that but you don't have to write out stuff like int before your types. You just use them and pretend they're what you want them to be. If you do it wrong it gives you errors but you don't have to think so much about types you just pass things around.

All of these things have cost usually. Garbage collection is objectively never the most performance optimal way to do things but it often does good enough for a lot of applications.

Pythons dynamic typing (not having to say what your types are) is comfortable for some, for me it's not.

It's hard to tell what you really should do. It might be a good idea to try to learn C# and compare it to C. Maybe it's more enjoyable.

You should probably also compare how much people are paid to how much experience is needed. As mentioned by people in the thread some people can't understand pointers. These people can understand a lot of things in higher level languages. But the less people are competing with you the better chances are that you get paid more. If that's your motivation then check how much developers are paid for different languages where you live/plan to live.

And knowing more is never bad obviously.
>>
>>57640138
>>57639829
look at these idiots who never made something more complex than fizzbuzz
>>
>>57640124
clang piggy backs on msvc libs/headers so you'll need to install the windows 7 sdk or vc2015 compilers if you don't want a full visual studio install
>>
>>57640164
It's important to remember that when you're using other peoples code you're not making something more complex. You're interfacing with something simpler than the 'complex' thing you're building.

For instance if you're doing a user interface in Qt you're piggybacking off Qt. Their programs may be well more complex than what you've written even if your application looks flashy.

And if they choose to use Qt they can also do that thing and more. If it were the case they're better programmers because they didn't skip school like you did.
>>
File: 1426639544144.jpg (20KB, 261x317px) Image search: [Google]
1426639544144.jpg
20KB, 261x317px
>>57640164
I maintain a 500k LOC pure C codebase at work

If you don't know C you're a fucking Pajeet loser
>>
>>57639973
Thanks. I'll check out the videos.
>>57640162
Yeah. I think I'll do just that. I'll learn a little more C and then get into C# to compare them.
>>
>>57640192

Not an argument.
>>
>>57640164
Why? Why would that imply anything like that?
So writing programs for an MCU is lower than writing fizzbuzz now?

Or maybe, just maybe, you couldn't grasp C on a level to be able to use it for large projects (many software use C) so you project it on everyone else?

Don't misunderstand me: the right decision is always using the right language for the right job. You don't need to be an elitist C faggot to value C though.
Honestly everyone who programmed something actually complex knows C at least on a basic level. Also how do you define complex? As in architectural complexity? Or as in writing a multi-domain FEM software? They have areas where the definition complexity differs greatly and not really about architecture.

TL;DR
Your post is nothing more than a primitive trolls attempt at emotional pressure.
>>
>>57639723
>not using long double
>>
>>57640229
>Not an argument.
The same to you?

Makes me wonder what would be an argument
>>
>>57640215
>500 KLoC

At that length, could it POSSIBLY do anything useful? You aren't hitting true usefulness in C until you're in the 1-2 MLoC range.
>>
>>57640249

Using a GUI library has nothing to do with how complex your program actually is. It means nothing, really.
>>
>>57640151
Damn, this is awesome. I just had to enable Windows subsystem for Linux in programs and features and apt-get install gcc.

Finally no more of that mingw bullshit.
>>
>>57639723
>Thanks C
Thanks floating point arithmetic rather.
Just do your calculations in integers if you want to manage that yourself.
Or use higher precision if that's appropriate.
>>
>>57640246
Is long double 96 bits or 128?
>>
>>57640250
Pretty much every utility company in the country is using it
>>
>>57640261
Yeah. I was talking down to you though.

A lot of people derive success from the results and not the work they did to get there.
Someone who belittles C programmers certainly seems to fit that category.
>>
>>57640250
Nice one.
Filtered. ;)
>>
>>57640274
I think it is 80, but GCC has a 128-bit floating point (depending on the arch)
>>
>>57639723
It's called IEEE-754. It's a standard followed by the hardware inside your computer.

Stop blaming C for something totally unrelated.
>>
File: 1476024898381[1].png (264KB, 570x683px) Image search: [Google]
1476024898381[1].png
264KB, 570x683px
>>57640250
>defining usefulness in terms of LOC

hmmmmm
>>
>>57640283

I never belittled C programmers, though. You must be talking about the guy you originally replied to.

Learn to read.

>>57640278

Interesting.

>>57640284

Sent ;)
>>
>>57640317

There's some basis for it. If you've got a C program that's 10-20 LoC, chances are it doesn't do much of anything. Even around 200-500 LoC you're still in the range of toy programs.
>>
>>57640318
>"if you don't know C, there's a good chance you don't know your program works"
>responds negatively to this
Well clearly you're belittling C programmers here if you consider them on par with the average programmer.

Shitter.
>>
>>57640329
>decided to check current project
>3.7K cpp files
>1.6K header files
I have some work to do
>>
>>57640314
>Peruse c data types
>Can't find fixed point
I think I can blame c for this
>>
>>57639727
that's fucking nothing, even C#onlybabbies know that shit
>>
>>57640382
If i'm not mistaken, it is fixed point as long as the value of the digits doesn't exceed 2^63 for long double, since the exponent just shifts the 64-bit segment along. That gives you just under 19 digits (18.96). If you need more precision than that, you should be using GMP (or __float128)
>>
>>57640338
>Well clearly you're belittling C programmers here if you consider them on par with the average programmer.

This level of smug pretension is what lost liberals the election.
>>
>>57639681
>Calls others code monkeys
>Parrots the old (false) "learning C is learning how the computer actually works!" adage
Irony.

C is like the Loomis of programming.
>>
>>57640382
>>57640456
The same logic can apply to 128-bit floats (quadruple-precision)
log(2^111) = 33
>>
>>57640456
What if your cpu doesn't have a floating point ALU?
>>
Programming in Assembly has gone well for me so far, but it's quite high level. Is there a lower level language I can use?
>>
>>57640494
That depends on the architecture.
>>
>>57640531
Maybe you want to design hardware or increase the specificity of the assembly you're writing?
>>
Guys how do i make a pointer that points to pointers that point to functions that point to pointers that point to the first pointer?
>>
>>57640494
software emulation
>>
>>57640549
thanks for catching that, but 16 is still pretty good
>>
>>57640548
>pointers that point to functions that point to pointers
Doesn't exist.
Functions can't point to pointers. You can have a function pointer that points to a pointer but that wouldn't be a function that points to a pointer. A function pointing at something doesn't make much sense unless you explain what it means when a function points to something.
>>
>>57640544
>>57640570
Thanks C
>>
File: 5157b8f06e.png (197KB, 1023x766px) Image search: [Google]
5157b8f06e.png
197KB, 1023x766px
Working on my terminal emulator, just managed to finally render something on macOS not going through XQuartz.

Feels glorious.
>>
>>57640580
No normal computer made in the past 30 years doesn't have the ability to use floating point natively. The only ones I can think of are old or bare ARM and PIC chips, and the alternative is using assembly.
>>
>>57640465
Honestly, if he can actually program in C then that statement is true.More and more programmers can't write a sorting algorithm, because they always use the built-in one in their language.

>>57640468
It is certainly closer to assembly than other higher level languages.
If we disregard (or practically disable) compiler optimizations then C has an easy mapping to assembly code. Even with optimizations an experienced programmer can follow what's going on.
It's a simple language in many ways.
Plus lots of infrastructure and low-level stuff uses C so C is at least the gateway to that kind of stuff.

Let's not get into digital electronics design, logic synthesis, etc. Lot of very good programmers who know from a lot about computers from a software standpoint don't care for it. Most people on /dpt/ won't either and there is a large amount of cases where it doesn't matter.

So yes, C is a milestone at least on the way to learning how your computer works. Learning C teaches you a lot about how your computer works especially if you learn about os stuff later. There is really no reason to learn about virtual mapping, mmu, etc. without knowing C (and assembly) first.

Having a basic knowledge of various stuff at least broadens your knowledge enough to be able to look up what you need later.

I haven't even talked about security, exploits, etc.

So guess what, the argument is while not the best, it's strong enough.

Maybe you should learn your shit instead of trying to emotionally trigger people or write a better bait.
>>
>>57640573
>>57640549
There are two different precisions
double precision (double) uses 53-bit (64 total)
extended precision (long double) uses 63-bit (80 total)
>>
>>57639182
>software keyboard
>>
>>57640610
>It's not that badâ„¢
>>
Made an accurate ln, exp and pow function. Been fucking with infinite series lately so I figured why not. Next I might work on trig functions.
>>
File: 9999999999%FURRYIOUS.gif (495KB, 618x648px) Image search: [Google]
9999999999%FURRYIOUS.gif
495KB, 618x648px
>scale matrix works
>rotation matrix works
>translation matrix does nothing and I can't find out why because you can't print in GLSL
reeeeeeeeeeeeeee
>>
>>57640682
It is the best programming language
>>
i have to code something but i can't stop shitposting
>>
>>57640682
Point to something that does better.
>>
>>57640684
So you derived the series and calculated it to the nth element to approximate the values? Nice

If you're also interested in computing stuff like pi or e you could take a look at these too:

https://en.wikipedia.org/wiki/Spigot_algorithm
https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula

>>57640697
If you use a math library which works close to glsl or if you're writing your own stuff you could try doing the same stuff on the cpu side to test it.
>>
>>57640682
Reminder that the V virtual machine is one huge abstraction that doesn't at all accurately represent any individual modern computer and is trailing behind in its big-net approach (which was never that big a net) and that

C
IS
A
HIGH
LEVEL
LANGUAGE
>>
>>57640710
No you don't have to code something. Just kill yourself.
You're a shit programmer and a shit human being. That's why you shitpost. It's not just procrastination.
>>
>>57640633
>write a better bait
seems like a bretty gud bait tbqh considering how much you just typed
>>
>>57640712
Well...>>57639438
>>
>>57640738
Wow rude, now who's shitposting? :^)
>>
>>57640744
It doesn't do better.
>>
>>57640756
It literally does
>>
File: V.jpg (16KB, 191x274px) Image search: [Google]
V.jpg
16KB, 191x274px
>>57640737
>>
Would a python script that could tell you most/all subdomains of a given domain be useful i.e if you ran it on 4chan.org it'd output /g/ /int/ etc. thinking of doing it as my next project
>>
>>57640766
Your implementation in ada suits you better than your implementation in C.

Ada doesn't come with magically appearing floating point units that does the math well for you.
>>
>>57639051
You have good taste OP

>tfw JS has native support for SIMD operations
>tfw your numerical processing code will get JIT'ed into native parallel SIMD operations that are competitive with C in terms of performance
>tfw still has the comfy scripting language syntax everywhere else where performance isn't crucial
>>
>>57640783
How would it handle domains that return fuck offs when you try to access non-public subdomains?
>>
How to rotate a 2d array so something like:

[ ][ ][*][ ]
[ ][ ][*][ ]
[ ][ ][*][ ]
[ ][ ][*][ ]

to
[ ][ ][ ][ ]
[ ][ ][ ][ ]
[*][*][*][*]
[ ][ ][ ][ ]
>>
File: Capture.png (3KB, 469x64px) Image search: [Google]
Capture.png
3KB, 469x64px
>>57640724
I wrote my own matrix multiplication function, and it seems to work fine.
The translation matrix is:
1, 0, 0
0, 1, 0
x, y, 1
though and I think that might be at fault.
The WebGL tutorial I was reading suggested that, but a translation matrix should affect a vertex even at 0,0,0: but multiplying a transformation matrix by 0 is just going to give 0.
I really don't know how to do a translation matrix.
>>
>>57640789
>Ada doesn't come with magically appearing floating point units that does the math well for you.
Can you reword that
>>
>>57640814
a[c][b] := a[b][c]
>>
>>57640824
Both ada and C can do software emulation.
Ada doesn't do any better with a native solution than C does.
>>
>>57640830
he said rotate, that would be transposition
>>
>>57640817
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
>>
File: 1479811586363.jpg (146KB, 960x758px) Image search: [Google]
1479811586363.jpg
146KB, 960x758px
I'm trying to write some protocol on top of TCP sockets and implementing a client and server. I'm wondering how to go about automating testing for implementations. It seems like a nightmare since you have to check all kinds of scenarios and then check them again trying to induce failure on purpose with things like timeouts, packet loss, etc. at different points, it seems like so much to account for just to prove that failures actually fail gracefully and don't pollute or interfere with other operations.

I probably should have just used something existing but this was for fun.
>>
>>57640836
C can't do it as cleanly or as powerfully as Ada.
>>
>>57640817
it should be:
1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
x, y, 0, 1

a,b,c,1 becomes a*1 + 1*x,b*1 + 1*y, c*1 + 0, 1*1
>>
>>57640899
>powerfully
Untrue.
>cleanly
Subjective.
>>
>>57640817
>>57640903
or multiply a,b,1 with
1, 0, 0
0, 1, 0
x, y, 1

you need the 1 at the end
>>
>>57640911
Sure thing
>>
Oh, I just found out what was wrong with my translation matrix!
My vectors were x,y,0 when they should have been x,y,1.
But for some reason I have to do x,y,0.99 because if I actually do 1, everything vanishes.
Making sure it's a float by doing 1.0 doesn't help either.
>>
>>57640804
it would just list them as any other if it manages to get any response that isn't 404 it would output it to a text file, it's up to the user to sort through it
>>
>>57640927
Debatable.
>>
>>57639410
I feel like the article over sells C as most of the low level stuff done in C is just manual memory management, control flow like function calls and while loops are all done for you.

Also the fact that you know C won't mean that you will
be able to understand how a operating system written in
C will work. You could probably get a better understanding by reading a high level overview of the OS rather than reading the code.
>>
>>57640948
>One has language defined behavior and constructs
>The other doesn't
Pretty debatable
>>
>>57639390
>posting fotm /r9k/-girl
>not a degenerate
I'm pretty sure you're lying to us here.
>>
>>57640940
Also, if it's above 1, it won't draw anything.
-1 will allow stuff to be drawn, but -1.1 won't.
Why on earth would a transformation matrix cause nothing to be drawn if the last number in the vertex vector is not in the range of -1 to 0.999?
>>
>>57639410
>http://www.di.unipi.it/~nids/docs/why_you_should_learn_c_but_probably_never_use_it.html
What an absolute asshat.

I hate how these people use the word abstraction too. It gets them nothing yet they praise it to no end.
>>
>>57641016
You speculating loosely like this is fine but nobody is gonna have a clue without more complete code examples. I'm not gonna go down the replies and try to follow what you've done to produce what you have.
>>
Guys, is Python good for generally scripting? What about javascript?

What do you guys think of pypy?
>>
Does your language support generic programming?
>>
>>57641049
The number having to be between -1 and 0.999 sounds like a very specfic type of error though.
Doesn't the range of signed numbers have one more more negative value than positive values?
It sounds like a range is being exceeded, but I'd expect that to not happen with a float.
>>
>>57641093
Use bash.
>>
>>57641099
#define generic programming
>>
File: SS5.jpg (896KB, 1920x1080px) Image search: [Google]
SS5.jpg
896KB, 1920x1080px
>be "wow he is so smart" kid in school
>learn C#, javascript, and ASP in highschool
>think programming is easy and decide to study software engineering in technion
>first semester study algebra, calc, C, and binary-logic-thing course
>barely get mediocre scores
>second semester C++ course where you have to write 10,000+ lines of memory leaking horror code
>also an assembly course where the fucking code itself changes while running
>"this semen slurping degree ain't for me"
>drop out and get into a pure math degree in another university
>i have ok grades and i will be able to get into masters degree, but i have been dragging for 5 years now (i should have finished in 3 years)
>realize i will never get a job with a pure math degree, and i don't have mental strength to actually get a masters
>i also hate teaching so i don't want to get into that

guys i think i have made a huge mistake. i am 26 now, in debt, barely getting by tutoring math to spoiled brats. what should i do programmer friends?
>>
>>57641125
I meant for non-performance critical software, more complex stuff than what you would do in a shell script, but still simple stuff. Some network stuff.
Generic scripting basically. So I need something "above" bash.
>>
>>57641121
Ah, maybe the problem was that I forgot to make sure that the depth wasn't being affected.
I was meaning to draw in 2D.
Once I made sure the vertex shader caused all vertices to have a z of 0, it worked fine.
>>
>>57641147
>i will never get a job with a pure math degree
a maths degree is amazing
get it
>>
>>57641147
CS has little to do with software development. Maybe that's more your thing?
Either way it sounds like you'd be the best programmer in some places. It's a living.
>>
>>57641147
If you wanted to be a codemonkey, you could have gotten a job without ever touching university.
>>
>>57641126
Map.Entry<A, B> is basically the same as Tuple<A, B> is basically the same as your own class definition containing an A and a B. I don't want to have to write three lots of code telling the compiler how to store them in a database or whatever, I want to be able to write a general rule for "data types that are basically an A and a B".
>>
>>57641155
What are you most comfortable in?
Likely whatever you're intended to have the scripting interface with. Just use that and have a clear interface boundary to the rest of the code.
>>
>>57641169
300k starting right?

>>57641147
Get into webdev, that's the way everything is going unfortunately
>>
>>57641169
>>57641198
note that i am taking pure math degree. next to zero programming courses.
also i am dragging the degree for 5 years, i can't make myself to study topology and calc 3 so i failed them 4 times in a row.

>>57641205
i look everywhere on the internet for jobs and there is basically nothing for someone like me.
>>
>>57639092
Follow evolution of C...

C => ObjC => C++ => C#
>>
>>57641225
C -> C++ -> ML -> Haskell -> Idris -> JavaScript
>>
>>57641237
C -> Python
Done
>>
>>57641254
If you want to miss all the fun, yes.
>>
>>57641208
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generic (Generic)

data MyDataType ...
deriving (Generic)

You have no idea how great this is.
>>
>>57641262
I wish I could write Haskell at work.
>>
Can I put down C++ on my resume and then write strictly C with Classes?
I don't like C++ one bit.
>>
>>57641274
C++ is a fantastic language. Why don't you like it?

RAII is a godsend compared to doing it manually in C.
>>
File: 1425954257873.webm (208KB, 507x953px) Image search: [Google]
1425954257873.webm
208KB, 507x953px
>>57641259
Python is a blast
>>
>>57641274
you could do a half-measure and have C (fluent), C++ (proficient) in your language list
>>57641285
C++ has static method selection
>>
File: ads.jpg (145KB, 670x424px) Image search: [Google]
ads.jpg
145KB, 670x424px
Who /node.js/ here?
>>
>>57641274
People are hiring you to do the fucking job, not to be a little primadonna about which langs you 'like' and 'dislike' - here's a tip, you don't matter. You're a number on a balance sheet, and if you're not earning your keep, you'll be replaced.
>>
>>57641347
>t. Pajeet who holds back the rest of his team because he refuses to move on from basic Java
>>
File: neat.gif (429KB, 530x981px) Image search: [Google]
neat.gif
429KB, 530x981px
>>57641291

Never forget that I, master tripfag, invented this.
>>
>>57641380
C# is useless
>>
>>57641390
So transitively, C# is Haskell?
>>
>>57641398
No, Haskell is useful
>>
Hey /dpt/, implement this in your favorite language:

traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () 
-- Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results.
>>
>>57641418
even it's creator Simon Peter James says Haskell is useless

https://www.youtube.com/watch?v=iSmkqocn0oQ
>>
>>57639302
>putStrLn s
>not putStr (s++": ")

request = putStr (s++": ") *> readLn
>>
>>57641429
void (*eeee)();
while (1)
eeee();
eeee = eeee + sizeof(void *);
>>
>>57639302
>>57641444
request = putStr (s++": ") *> readLn
results = request msg >>= flip replicateM (request "enter ur number"
where msg = "enter how many times you'd like the script to repeat"
>>
>>57639390
>browses this place
>there's nothing wrong with him
pick one
>>
>>57641444
>>57641476

Wow, you've managed to take some lovely looking Haskell code and turn it into a mess
>>
>>57641474
BASIC might be a better language for you, friend.
>>
File: 1440961540115.jpg (67KB, 633x758px) Image search: [Google]
1440961540115.jpg
67KB, 633x758px
Alright Java is being a cunt AND I'm retarded.

I'm trying to end the loop but I can't add a break statement after the print statement

I know this is basically a stupid question but this thread is moving faster, sorry.

import java.util.Scanner;
public class lab5 {

public static void main(String[] args)
{

//data types
double num1 =0;
double num2=0;
char operator = 0;
boolean answer;

Scanner input = new Scanner(System.in);

//the problem
while(true)
{
System.out.println("please enter a valid number");
num1=input.nextInt();
System.out.println("Please enter the second number");
num2=input.nextInt();
System.out.println("Please enter an operator");
operator=input.next().charAt(0);

if (operator == '+'){
System.out.println(num1+" "+operator+" "+num2+" "+" = "+(num1+num2));}
else if(operator == '-')
System.out.println(num1+" "+operator+" "+num2+" "+" = "+(num1-num2));
else if(operator=='/')
System.out.println(num1+" "+operator+" "+num2+" "+" = "+(num1/num2));
else if(operator=='*')
System.out.println(num1+" "+operator+" "+num2+" "+" = "+(num1*num2));
else if(operator=='%')
System.out.println(num1+" "+operator+" "+num2+" "+" = "+(num1%num2));
// Display the result*/
else if((num1==0)||(num2==0)||operator=='/')
System.out.println("Please try again");
else
System.out.println("please try again");

}
}
}
>>
>>57641274
it wont compile because the file extension is not cpp or hpp :^)
>>
Why is this python code always outputting 0 as the percentage?
import random
tails = 0
heads = 0
repeat = input("Enter how many times you would like the script to repeat")
for i in range(int(repeat)):
result = random.randint(0,1)
if result == 0:
heads=heads+1
else:
tails=tails+1
percentageofheads = (heads/int(repeat))*100
print(heads)
print(tails)
print(percentageofheads)


Enter how many times you would like the script to repeat10000
4992
5008
0
>>
>>57640215
use haskell, and the code will be at least a fifth and more readable and maintainable
>>
>>57641522
1. Your indentation is inconsistent.
2. You are mismatching comment styles.
3. Your spacing is inconsistent.
4. You're using Java.
5. You never close the Scanner.
>>
why isn't there a /dpt/ discord?
>>
>>57639267
sum += input
?
>>
>>57641558
because discord spys on you and mines userdata
there's an IRC on rizon I believe
>>
>>57641500
not really
anybody who ain't a haskell newfag can understand this
>>
>>57641558
discord is shit, fuck off gaymer
>>
>>57641558
>Why am i not slurping cocks while writing "haskell" with lipstick on my forehead.
>>
>>57641589
>>57641591
don't you faggots get ronery while coding

>>57641582
>IRC
it's not 1988 anymore
>>
>>57641522
If you want multiple statements to be executed in an if/else if/else block then you have to surround them with braces, e.g.

if (a) {
b();
c();
} else {
d();
e();
}


Alternatively you could set a flag to exit the loop, and check that in the loop.

Incidentally it might be clearer to use a switch statement instead of half a dozen if-else blocks.
>>
File: 1425336764112.webm (1MB, 799x956px) Image search: [Google]
1425336764112.webm
1MB, 799x956px
>>57641380
>>
>>57641598
>don't you faggots get ronery while coding
No?
>>
>>57641598
the internet is older than IRC does that mean we should stop using it?
>>
How does one get
 std::chrono::system_clock::now(); [/clock]
Into a string?

I'm trying to get today's date to be set in a string...
>>
>>57641640
>the Internet
populated by people from all walks of life
>IRC
populated only by balding losers and annoying autistic people
>>
>>57641652
>discord
populated by retards who can't figure out anything that's not warm diarrhea being spoonfed to them
>>
>>57641650
Wow I completely fucked up this post lmao...
>>
>>57641652
>populated only by balding losers and annoying autistic people
this

nothing but circlejerks of attention whores
>>
>>57641650
http://stackoverflow.com/questions/12835577/how-to-convert-stdchronotime-point-to-calendar-datetime-string-with-fraction
>>
>>57641652
at first the internet was populated only by balding losers and annoying autistic people, should it have not been used by people like you because of that?
>>
>>57641522
I'm a C# programmer, so this might not work 100%, but I think this (or something similar) is what you want:

bool running = true;

while (running)
{
System.out.println("Enter the first number: ");
num1=input.nextInt();
input.NextLine(); // There's a linefeed sitting on the stream
System.out.println("Enter the second number: ");
num2=input.nextInt();
input.NextLine(); // Same as above
System.out.println("Please enter an operator");
operator=input.next().charAt(0);

String output = null;

// Flip the running state - default will set it to true again on invalid input
running = false;
switch (operator)
{
case '+':
output = num1+" "+operator+" "+num2+" "+" = "+(num1+num2);
break;
case '-':
output = num1+" "+operator+" "+num2+" "+" = "+(num1-num2);
break;
case '*':
output = num1+" "+operator+" "+num2+" "+" = "+(num1*num2);
break;
case '%':
output = num1+" "+operator+" "+num2+" "+" = "+(num1%num2);
break;
case '/':
if (num2 != 0)
{
output = num1+" "+operator+" "+num2+" "+" = "+(num1/num2);
break;
}
default:
System.out.println("Please try again.");
running = true;
break;
}
}
>>
>>57641676
It shouldn't have and shouldn't be used by people like him, period.
>>
>>57641688
>only attention whores and people with mental disabilities should be allowed on the Internet
>>
>>57641710
Only people who can figure out IRC at a bare fucking minimum should be allowed on the internet.
>>
>>57641652
>populated only by balding losers and annoying autistic people
are you dense?
people who would join the discord channel would be from dpt, people who join the dpt IRC are people from dpt, so unless you can name some negatives of IRC or some stuff that makes discord better (voip isn't a pro) fuck off
>>
>>57641719
>"figure out IRC"
wow /connect is so hard amirite hurdur
that's the problem with IRC--it's full of literal retards who think they're special for using an ancient and obsolete medium which requires one or two commands to get into a channel
wow jeez you sure are intelligent, cream of the crop right here folks
>>
File: 1479198102613.png (46KB, 300x250px) Image search: [Google]
1479198102613.png
46KB, 300x250px
>>57641687
I'm going to plug this in (also fixing it to run with java)

the Switch statement that >>57641616
suggested is probably 100% more efficient. thanks for helping me get over my stubbornness.
>>
>>57641736
>this desperate attempt at misdirection
Face it, you'd be lost if you were trying to use a computer from 20 years ago. Now fuck off back to the Apple store.
>>
>>57641755
>get called out
>call it "misdirection"
k enjoy your chat room for losers
>>
>>57641759
It can hardly be a channel (it's not a chatroom, but of course you didn't know that) for losers if you're not in it.
>>
>>57641759
>chat room for losers
>CHAHAhahahahaAAA mad nerds in here CHAAAA
Fuck off normie
>>
>>57641536
int(repeat)
is setting your percentage variable to an integer so everything past the decimal is being truncated. so unless you're basically always doing 0*100.
>>
>IRC
lmao that's for teenies.

Real men leave each other notes on their FTP servers.
>>
File: angrypepe.png (138KB, 5000x5000px) Image search: [Google]
angrypepe.png
138KB, 5000x5000px
>>57641777
>>
Thoughts on scalaz?
>>
>>57641870
Scala is shit but scalaz seems to be an attempt to make Scala less like Java
>>
>>57641825
>not leaving encrypted text files on CTF servers
yeah, you're not a real man
>>
>>57641890
Yeah, it has a load of stuff from Haskell. Apparently this upset some people so they decided to make a worse version of the library instead.
>>
File: anime-girls.png (1MB, 1200x1800px) Image search: [Google]
anime-girls.png
1MB, 1200x1800px
why isn't haskell on here
>>
>>57641919
Haskell is too busy actually being useful
>>
>>57641919
lazy
>>
Hey /dpt/ I need someone who knows C++ to help me understand this code. It's performing a Radon/Hough transformation, and I'm trying to rewrite it in C#, but I don't understand what one of the lines is doing. I get that it's offsetting the nb_per_line by k and incrementing the value at that address, but I don't understand the purpose (and thus don't know how to implement it).

nb_per_line[k] += 1;


I've put (what I think are) the relevant code snippets on Pastebin:
C++ - http://pastebin.com/3hkb2nRm
C# - http://pastebin.com/3p78xi6d

Please excuse the awful variable names, I copied/pasted the C++ code and then reworked it (leaving most of the variable names intact).
>>
>>57641947
Holy shit just do it.
>>
>>57641919
Haskell is a trap so he can't be personified as an anime girl
>>
>>57641958
I'm not sure I understand what you mean, what am I supposed to do?
>>
>>57641994
increment the kth element of the array nb_per_line

do you want me to chew your food for you too?
>>
>>57641919
>Perl
Pretty accurate representation
>>
File: typing.png (41KB, 551x372px) Image search: [Google]
typing.png
41KB, 551x372px
>>57641979
Pretty sure that's C
>>
>>57642002
But what is nb_per_line? It isn't used within the scope of the projection method, but rather stored and passed on to a different method. Why is it being incremented in this manner?
>>
>>57642026
What editor/IDE is that?
>>
excuse the newfriend question, but I'm looking into ways to apply programming/scripting to windows. I want to be able to right click on a music album's folder and send it to my music library. super simple stuff. I can do this with python, then compile with py2exe, then add the relevant registry entries to add it to the context menus for right clicking on stuff.

What is a cleaner way of doing this? should I be learning powershell or batch or whatever windows shit there is? I mean, it just werks but I feel like I'm doing things in the complete opposite of "elegant" here.
>>
>>57642033
atom/firacode/onedark
>>
>>57642029
There are two possibilities:

1. It is necessary for the code to work correctly
2. It is an error in the original code
>>
>>57642036
>What is a cleaner way of doing this?
Due to the way context menus are integrated into the system, that's pretty much the only "way" to do it.

>py2exe
You don't need to do that part, you should be able to point the entries to batch scripts that will launch the python script from a cmd instance.
Alternatively if you're on W10 install WSL and just use Bash magic to do it
>>
>>57642040
thanks
>>
>>57642042
...Somehow I get the feeling you're being intentionally obtuse because you somehow feel above actually helping, but I also doubt you understand either due to the lack of insight in your responses. Although given this is /dpt/ I guess I'm lucky I got at least one (You).
>>
>>57642055
neat, thanks. I was hoping to stick with python to find other solutions, and I'm on w7
>>
>>57642076
Well, what did you expect? Probably very few of us care to try to understand the algorithm you're trying to implement. So all we can really say in response to "should I copy this line??" is "um, probably?".
>>
>>57642115
You could alternatively install Cygwin or MinGW
Either way you don't need to compile your python scripts into exe's, you can leave them as .py files and just call them with a batch script that literally just pops open cmd and calls the script
>>
>>57642119
I expected either someone to explain why storing the number of pixels per line is necessary for the Radon/Hough transformation, or no responses.

Considering I went to more trouble than 99% of people that come here asking for help by including both the original and my code reasonably well formatted, I kind of assumed someone would want to flaunt their knowledge. I assume you didn't even look at the code snippets given that you originally replied in less than a minute, so I don't know why you felt the need to post an unhelpful response.
>>
const range = (lower, upper) =>
[...Array(upper)].map((x,i) => lower + i)

console.log(
range(1, 10)
)


es6 is so beautiful
>>
>>57642167
why are you redeclaring range?
>>
>>57642135
I have cygwin, but how would that help if I want context menus?
>>
By 2020 all new code will be JavaScript.

Your OS will be written in it, your phone will run it natively, your CPU will have been designed in it.
>>
Is the cost of a function call in C-based languages anything meaningful? Going through SICP is great and all, but when i go back to C code, my first instinct is to create small functions, for example if i have some "if" code with a double negative that isn't very readable, i'd like to encapsulate that check in a function, but is it worth it? To encapsulate a single line of code in a function, to improve readability and code management.
If i make similar changes for trivial code, will i be sacrificing far too much at some point?
>>
>>57642366
>a double negative
That's just a positive.
>>
what's a nicer way of doing this?
#!/usr/bin/env python3
def other_value_by_key(dic, the_key):
""" given a dic with 2 keys, and the_key,
return the value in dic with the key that isn't the_key
"""
for key in dic:
if key != the_key:
return dic[key]
>>
>>57642414
bash
>>
>>57642419
nugger
>>
>>57642414
it's not really clear what you're doing, but i doubt that the for loop is doing what you want.
>>
>>57642430
it works fine, it just looks shit.
when you iter over a dict in python, you get the keys
>>
>>57642366
If you aren't writing for an embedded platform, odds are the extra readability will save you more in development time than the the two processor cycles wasted on extra calls will consume in your entire life.
>>
>>57642414
other_value_by_key :: Eq a => a -> [a] -> a
other_value_by_key x = head . delete x
>>
>>57642456
thanks, but no thanks
gotta python
>>
File: 1438314435385.png (179KB, 405x406px) Image search: [Google]
1438314435385.png
179KB, 405x406px
>>57641522
Anon were u able to solve this problem? I can solve it for you easily if you still need help. Respond back if you need help, im being srs
>>
>>57642456
>head
No.
>>
>>57642414
What's the use-case?
>>
/g/ what's the use-case of Bitraversable?

If it doesn't have one then it should be removed.
>>
/g/, what's the use-case of Tuple? It's just abstract and not useful, I don't get it, it doesn't belong in the language.
>>
/g/ why would you ever use an Int when you can use a Long? Also why would you ever use a Char when you could use a String of length 1? Int and Char are not practical.
>>
NEW THREAD:

>>57642567

>>57642567

>>57642567
>>
>>57642513
...
def __init__(self):
self.boards = {ID1: Board(id=ID1), ID2: Board(id=ID2)}

def get_opponent_from_board_id(self, board_id):
""" essentially just other_value_by_key() where dic is self.boards
and the_key is board_id.
this method should return a Board instance (a value of self.boards)
"""
>>
>>57642571
>Int when you can use a Long
Efficiency
>Char when you could use a String of length 1
Efficiency
>>
>>57642381
No shit, sherlock. Read the fucking text.
>>
>>57642441
ah, okay. your documentation is really unclear. just say "returns a value chosen randomly from a dictionary excluding dictionary[the_key]" or something.

and python3 lets you do type annotations. you shouldn't need to indicate this stuff in the docstring, especially if you use real ball busters like "dic".

some_dumb_example=dict(zip([1,2,3,4,5,6],'abcdef')) # {1:'a', ... }

def some_rando(dictionary:dict, bad_key):
if bad_key in dictionary:
del dictionary[bad_key]
return dictionary.popitem()[1] # popitem returns a key/value tuple (1,'a')


keep in mind that none of this is necessarily strictly right. here are a few alternative approaches:

- if you want this to work with dictionaries with more than 2 entries, you want a random choice. dictionaries are not implemented to provide random results. make a dict with integer keys (like above) and they'll magically always come back in order. you should use the random library to do `random.choice` on the values

- if you know you're just going to get a 2-entry dict, you could just delete the entry from the dictionary you're passed (it won't affect the object outside of the namespace), and return the only remaining entry when you call `dictionary.values()`
>>
File: 1479199475119.png (17KB, 882x758px) Image search: [Google]
1479199475119.png
17KB, 882x758px
>>57642477
...ok

I got frustrated, jerked off and started playing Vampire Masquerade Bloodlines.

I'll let you take over the code - show me your solution
>>
>>57639432
What do you use for the tests/what language is the codebase in?
>>
File: 1452234790855.jpg (8KB, 250x244px) Image search: [Google]
1452234790855.jpg
8KB, 250x244px
>>57642773
Here is a hint. Why are you even using a while loop if you want to exit the loop after getting 3 inputs from the user. You dont need a loop. Only if you want the program to restart if the user made an error do you need to use a while loop
>>
File: 1422081978150.jpg (51KB, 527x612px) Image search: [Google]
1422081978150.jpg
51KB, 527x612px
>>57643860
Well that's what it's supposed to do goy, otherwise I'd be done!

but now that I know it's a While loop with a switch statement I guess I should...turn off the hentai.
>>
File: 1452755022140.png (696KB, 633x758px) Image search: [Google]
1452755022140.png
696KB, 633x758px
>>57643891
ok give me 10 min. Ill give ya the answer.
>>
File: 1437471019636.jpg (43KB, 707x500px) Image search: [Google]
1437471019636.jpg
43KB, 707x500px
>>57643944
n-no please anon I must train myself. I need to stop procrastinating
>>
File: 1477536974087.png (461KB, 898x790px) Image search: [Google]
1477536974087.png
461KB, 898x790px
>>57644018
Here is the answer:
import java.util.Scanner;


public class Anon {
public static void main(String[] args){


Scanner scanner = new Scanner(System.in);
int result = 0;
boolean running = true;

while(running){
System.out.println("Enter number");
int firstEntry = scanner.nextInt();

System.out.println("Enter another number");
int secondEntry = scanner.nextInt();

System.out.println("Enter operation");
String op = scanner.next();

if(secondEntry == 0 && op.equals("/")){
System.out.println("Error: cant divide by 0, try again");
}

else if( op.equals("%") || op.equals("+") || op.equals("-") || op.equals("*") || op.equals("/")){
if(op.equals("%")) result = firstEntry%secondEntry;
if(op.equals("+")) result = firstEntry+secondEntry;
if(op.equals("-")) result = firstEntry-secondEntry;
if(op.equals("*")) result = firstEntry*secondEntry;
if(op.equals("/")) result = firstEntry/secondEntry;
System.out.println(result);
running = false;
}

else{
System.out.println("Please try again");
}

}


}

}
>>
File: 1474422089457.jpg (72KB, 640x640px) Image search: [Google]
1474422089457.jpg
72KB, 640x640px
>>57644214

>tfw using Java

th-thanks anyway.
>>
File: 1462076539066.jpg (24KB, 409x409px) Image search: [Google]
1462076539066.jpg
24KB, 409x409px
>>57644264
what do u mean using java? The code you posted was in java. The code i posted is in java
>>
File: 1461269430797.jpg (45KB, 570x487px) Image search: [Google]
1461269430797.jpg
45KB, 570x487px
>>57644214
REEEEgardless of the language, they do share siilar syntax and I'm learning a lot about the uses of Loops from this thread, so this has been a great help so far, many thanks anon!
>>
File: 1478485910906.gif (144KB, 340x340px) Image search: [Google]
1478485910906.gif
144KB, 340x340px
>>57644293
nvm I'm retarded thx
>>
>>57644299
U posted ur original solution in java. The solution i posted it in was java. Im confused, what do u mean same syntax? Its the same lanaguage
>>
>>57644360
Nah it works, I just wasn't picking it up in my mind and decided to post before testing
>>
>>57641380
>still 2Donly
>>
>>57641223
Yeah well if you're interested in programming as you clearly have been when you studied on your own time at a relatively young age. I'm just saying that it's not a long path to get somewhere with it.
Thread posts: 330
Thread images: 38


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