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

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>58020625

What are you working on /g/?
>>
What should I code? I want something to work on but I can never find or think of anything compelling to me. The farthest I've gotten recently is simply a script that pulls all the images from a 4chan thread. And that was probably last year or early this year. Ideally I'd be making things all the time and getting better but it's not working out
>>
>>58026257
create a starcraft AI
http://sscaitournament.com/index.php?action=tutorial
>>
>>58026292
any wrapper for PHP?
>>
how do I filter ports with iptables in a way that nmap cannot detect?
everything I filter shows up as "filtered" and I want it to seem "closed"
>>
>>58026672
nevermind it's -j REJECT --reject-with tcp-reset
>>
I'm just a fucking stupid code monkey. I hate myself.
>>
>>58026741
You're responsible for your own learning.
>>
>>58026766
I'm trying to learn and failing. That's why I hate myself.
>>
Is bioinformatics a good field to get into if I want to solve interesting programming problems?
>>
>>58026774
You can't learn if you're too busy hating yourself.

The important part is to have FUN.
>>
>>58026789
Programming isn't fun anymore. I tried waiting to see whether the fun could come back on its own but it didn't. The only thing left I can do is force myself.
>>
>>58026223
i wanna fuck her
>>
>>58026821
Forcing yourself to do something you don't enjoy is not going to help you solve burnout. At all.

Find something else that's fun to do, related to programming or not, and then come back.
>>
>>58026821
learn Haskell
>>
Ok /g/, nntpchan sucks. Let's make a real p2p imageboard

What would it look like?
>>
>>58026861
is this the equivalent of "install gentoo"?
if so, is it actually as good as gentoo?
>>
>>58026821
Just do something else for a while.
I "rotate" between 3 or 4 different hobbies on a regular basis, and it keeps them fresh and more interesting when you get around to doing them.
>>
>>58026865
the world needs something that allows you to host static website content on ipfs and and dynamic stuff centralized
I have no idea how a truly distributed chan clone could work however because of post numbers getting reordered, people inserting posts back in time and whatnot

>>58026866
no its actually not a meme
haskell is really fun to learn
http://learnyouahaskell.com/
>>
>>58026866
It IS the equivalent of gentoo
You need to be extremely autistic and capable of understanding the most esoteric of memes in order to use it
>>
>>58026866
>>58026885
but if you do become a code autician like us, you will understand just how much nicer haskell is
>>
File: image.png (88KB, 1680x1050px) Image search: [Google]
image.png
88KB, 1680x1050px
>>58026821
Only a minor elite is able to program over a long time; Not everyone is made to be a programmer.

>>58026223
>What are you working on /g/?

Exploring the deepest, darkest corners of Racket by doing Advent of Code 2016.
>>
>>58026899
Are you telling me that >>58025783 was lying?
>>
>>58026885
this isn't true
it just gives you a whole new way of viewing programming by the virtue of being a declarative language
it literally has no variables and all functions are merely transformations on input that produce an output
>>
>>58026916
t. extreme autist fluent in esoteric memes
>>
>>58026916
well it has IORefs but they're hacks

>>58026924
I plan on learning prolog as well
only then will I be the most autistic man alive
>>
>>58026885
but this doesn't describe gentoo in any way lmao
your level of autism has to be about the same as mine to use gentoo, which is to say "bordering on neurotypical/sperg"
>>
>>58026941
i don't use gentoo so i wouldn't know
what's it like being autistic?
>>
>>58026934
it's got pointers too
>>
>>58026942
i'm not as autistic as some other posters but sometimes i sperg out and go on 12-18 hour shitposting sprees
>>
>>58026780
Pretty good.

It's also one of the few fields which values C performance autists like me because problems routinely take hundreds of thousands of CPU hours and hog terabytes of RAM
>>
>>58026223

A week ago I asked for help here because biased HR department was hiring women "because yes" as backend developers. After two of my friends got finned because they complained that those women only go to smoke to the roof (which is true) I got fired today for not be able to carry the job of the new employees and teach them basic data structures and algorithms.

So, what am I working on? on migrating out of Italy.
>>
>>58026884
Bitcoin solve this exact issue but at the price of lots of wasted cpu cycles.
I don't think we need to keep track of post numbers though. Just use a hash of its data
>>
>>58026884
>no its actually not a meme
neither is gentoo.
>>
Why isn't this more popular and why does it have to suck?
https://btlive.tv/
>>
File: 1469147402618.gif (1MB, 264x264px) Image search: [Google]
1469147402618.gif
1MB, 264x264px
>>58027013
>>
Holy shit VHDL is so fucking awful. Does anyone know how to actually use a component at a useful time? You can't have them in case statements or processes. But maybe I'm wrong because the syntax is so strict and shitty
>>
Fug I feel ronery. It's easy to make a chatbot and feed it with 4chan posts?
>>
>>58027060
Yeah I have done that and got my 4chan pass banned
>>
>>58026884
>meme
>le got tired from le reddit, so I'm le here again! XD
>>
i am working on learning python and hopefully I can transfer the knowledge into Java for next Semester's project.

Also, I have seen this humble bundle, you think it is actually useful? I want to concentrate on python and java for now.
What can I use as source in order to progress?
>>
>>58027082
Because of the webscraping, or because you let the bot post like a madman?
>>
>>58027114
>let the bot post like a madman
Also, you don't need a scrapper
https://github.com/4chan/4chan-API
>>
>>58027111
https://www.humblebundle.com/books/code-your-own-games-book-bundle
>>
>>58027111
one of the books from the 15$ package is actually available for free

Program Arcade Games: With Python and Pygame

http://programarcadegames.com/
>>
File: anal beads.png (49KB, 713x715px) Image search: [Google]
anal beads.png
49KB, 713x715px
>>58027060
If you can make the output more englishy, have at it.

The API is bretty easy to use.

Markov Chains are kinda fun, but they're shit and I don't know where to go from here.
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
What does a software consultant do?


can't seem to find a good answer on this
>>
File: 1464361606104.gif (397KB, 400x418px) Image search: [Google]
1464361606104.gif
397KB, 400x418px
>"Abstract base classes complement duck-typing by providing a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods)."
>mfw ducks
>mfw magic methods
>mfw why is it "subtly wrong"
>>
>>58027462
You go join a company for a couple months, shit all over their projects and tell them why everything their did is wrong, all of that at obscene hour rates.
>>
>>58027470
If it wasn't subtle, you'd be able to understand. That's the point.
>>
>>58027462
Sell bullshit like OOP to innocents who don't know any better
>>
>>58027556
OBSESSED
>>
>>58027556
>Sell bullshit like OOP

what's the best paradign then?
>>
If your favorite language doesn't error out when you try to subtract a string from an integer, your favorite language is gay.
>>
File: rouge.jpg (70KB, 1280x800px) Image search: [Google]
rouge.jpg
70KB, 1280x800px
I'm back again because apparently I have a learning disability.
I'm the guy that was using Lua the other day.

Put straight I am trying to translate this,
[i.split('\t') for i in open('assets/lvls/test.lvl')]

into Lua.
I am currently here.
function csvEntry( str )
-- extract a table of columns
-- split into lines/rows
local tmp = 0
local dat = {}
for i in string.gfind(str, '[^\n]+') do
-- ignore comments
i = string.gsub(i, '[^%#.*\n]-', '')
table.insert(dat, {})
for j in string.gfind(i, '%d+') do
table.insert( dat[i], tonumber(j) )
end
end
return dat
end
[\code]
>>
>>58027620
not OOP
>>
>>58027632
Sweet mother of god.

Is Lua really so shit that you can't figure out how to replicate that simple line?
>>
>>58027622
but muh pointer arithmetic, don't call C gay :(
>>
>>58027716
What does that have to do with the post you're responding to?

C doesn't even have strings.
>>
>>58027184
>Markov Chains are kinda fun, but they're shit and I don't know where to go from here.
word2vec and LSTM networks
>>
>>58027684
http://stackoverflow.com/questions/14672350/lua-language-how-use-something-similar-to-python-list-comprehensions

Lua is garbage
>>
>>58027771
Jesus.

C#, Java, C++, Python, etc. all have easy list comprehensions. Is Lua mostly legacy stuff, or is there new active development with it?

Assuming Python's 'open' returns something with a set of lines:
ReadAllLines("assets/lvls/test.lvl").Select(i => i.Split('\t'));
>>
>>58027728
>C doesn't even have strings.
False.
>>
>>58027684
>>58027771
The issue is that Lua is so light that they have to cut so many features and library functions from the standard that it feels like a sketch of a skilled designer sometimes.

It does the job and you can work with it but you have to think about the implementation a lot more than you would with say, Python's "batteries included" mindset.

According to the official "Programming in Lua" book the SLoC for all of the combined standard libraries comes to less than 4000. Yes. That small.
>>
>>58027632
So something like this?
local f = io.open('assets/lvls/test.lvl', 'r')
local contents = f:read('*all')
f:close()

local data = {}
for chunk in contents:gmatch('([^\t]+)') do
table.insert(data, chunk)
end
>>
>>58027807
Lua isn't in the same league as C#, Java, C++ and Python, it serves a completely different purpose and the standard "library" is kept very minimal intentionally.
>>
>>58027861
What is the purpose of Lua?
>>
>>58027868
Lua is an embedded scripting language. You can just add
#include <lua.h>
to your C source file and your program suddenly becomes scriptable with lua.
>>
>>58027868
It's mostly used as embedded platform to extend existing software written in lower level languages (essentially a plugin/addon platform). You build the library yourself by creating functions in C/C++ (bindings also available in languages like D, Rust etc) and expose the functionality to the Lua VM.
>>
>>58026899
>deepest darkest corners of Racket
you said this like 2-3 days ago and all you showed was a bunch of switch statements
now its just basic looping
only thing dark here is that theme
>>
>>58027912
>you said this like 2-3 days ago

He's been saying that for at least two months now but it's the benchmark shitposter from last year so move along and don't argue.
>>
>>58027912
>you said this like 2-3 days ago
literally every day
>>
>>58027829
actually, true.
C does not have a proper string type.
C only has a pointer to a region of memory and a null-terminator.
>>
>>58027922
>>58027931
I only check in once every couple days sometimes after a week
>>
>>58027829
retard
>>
>>58027949
Stop moving goalposts. You said "strings", not a "proper" (whatever that means) string type.

C definitely has strings and has string handling functions in the standard library.
>>
>>58028028
Clarifying a term isn't moving a goalpost; when I said "string" initially, I was referring to what you apparently may call "proper strings".

C doesn't have strings.

C has """strings""".
>>
>>58028028
actually, not true.
C does not have a proper string type.
C only has a pointer to a region of memory and a null-terminator.
>>
What's it like using a language that can't print the character '\0'?
>>
>>58028028
I wasn't the person you were responding to but you're still wrong.
C doesn't have strings despite how much you want it to be true.
>>
>>58028062
Covering your ears and repeating yourself is not an argument.

>>58028059
>what you apparently may call "proper strings".
You used the term, I only threw your sloppy language back at you.

A string is a finite sequence of encoded characters and C has those.
>>
>>58028065
>He thinks that's not possible
>>
>>58028062
>C only has a pointer to a region of memory and a null-terminator.
That's an implementation detail, just one you have access to in C because it's a relatively low level language.

How do you think "proper string types" in higher-lever languages are implemented?
>>
>>58028127
>he needs a workaround
>>
>>58028152
>He thinks I need a workaround
>>
>>58028152
>He still thinks that's not possible
>>
>>58028113
>I only threw your sloppy language back at you.
autism speaks
>>58028128
>he thinks native string types are all represented with a null terminator
>>
>>58028113
>A string is a finite sequence of encoded characters
Maybe in your world.

You're talking to two separate anons, by the way.
>>
How long is an instance of string?
>>
>>58028200
About 20 nanoseconds
>>
>>58028200
len(num_of_char(string))
>>
>>58028211
you can't measure string in units of time retard. That's makes no fucking sense.

A string is generally about 20 nanometers or so.
>>
>>58028261
No, you're talking about lightyears, strings are measured in nanoseconds
>>
>>58028167
>Maybe in your world.
In the world of computer science. I'm sorry you lack the capacity to abstract such basic concepts away from the jargon and implementation specific to your favourite programming language.

>>58028165
>>he thinks native string types are all represented with a null terminator
I have said no such thing. I have merely said strings in any language will have implementations specific to that language (or just implementation itself...), so you can always say that it only has "null-terminated character arrays" or "length-prefixed character arrays" or some more sophisticated construct instead of a "proper string type".

The C implementation is merely plain to see and easily available to fiddle with, but the language still defines and handles *strings* in a special way. If it didn't you wouldn't be able to use string literals, would have to handle encoding yourself, you wouldn't have string manipulation functions in the standard library and so on. Therefore, C has strings.
>>
>>58028261
Time is distance
>>
>>58028290
prove it
>>
>>58028313
Wait 5 meters
>>
>>58028290
Time is wasted neurons
>>
File: 1469566086769_1455095239453.jpg (1MB, 2736x3648px) Image search: [Google]
1469566086769_1455095239453.jpg
1MB, 2736x3648px
>>58027807
Yes. Python's open can be used as an iterator over the lines of said file.

>>58027854
Fuck. Finally. Thanks man. I didn't realise that gmatch returned the captures to iterate over. Now it's sort of working at least. Only tweaking to go.

>>58027868
>>58027889
>>58027898
>>58027861
Lua, to me, is just a tool that writes a little like python but works at the speeds that are needed for a video game. I don't want to use C because I tend to get stuck on premature optimisation and using a language that doesn't block out with curly braces helps my mind flow.

I'll post here and in /agdg/ once I have something I'd consider worth sharing. (Early Jan)
(Damn I love art)
(I'm using LÖVE btw)
>>
File: 973267.png (78KB, 193x240px) Image search: [Google]
973267.png
78KB, 193x240px
>>58028313
The speed of light c is just a constant that has a particular value in our current system of units. If you take a system of units such that c = 1, then the relation t * v = d becomes t = d when considering the case of the speed of light, so it appears that in this system of units (which is just as valid as ours) times are equivalent to distances.

Furthermore if you take the value ct, which is really just t with our units, (x, y, z, t) becomes a valid vector in 4 dimensional space, making time on axis of distance in that space.

And so, as you can see, time is distance.
>>
>>58028384
Haskell is much faster than Lua and also not shit like Python
>>
The guy at the interview today said i should get a job as software consultant.
>>
>>58028421
He meant that you're unemployable and shouldn't bother applying again.
>>
>>58028384
>Lua, to me, is just a tool that writes a little like python but works at the speeds that are needed for a video game. I don't want to use C because I tend to get stuck on premature optimisation and using a language that doesn't block out with curly braces helps my mind flow.

I used to write my game in Love2D but then I rewrote it in C++ with SFML and added a Lua layer on top of it but if your scope is small enough then you're good to go.

>>58028402
Haskell is essentially Python of the FP world, just import all the things.
>>
>>58026223
which distro would you say it's the best for programming?
>>
>>58028439
Not debian/debian derivatives.
>>
>>58028429
Really?
I showed him my android apps and all.

He went on a 10 minute rant of how his Software Dept. slowly merged with RRHH and he was stuck doing paperwork somehow.
>>
>>58028439
It makes no difference so stop procrastinating and start writing code
>>
>>58028457
Nah I'm just messing with you, could mean anything
>>
>>58028384

source on the sculpture?
>>
What are some fun ways to learn programming like Penjee.com? Is there something like it with nice grafix?
>>
>>58028491
Code In Game?
>>
>>58028481
author's name is Fred Fichet
>>
File: 1387057071712.jpg (50KB, 300x309px) Image search: [Google]
1387057071712.jpg
50KB, 300x309px
>>58028498
>>58028500

thanks anons
>>
>>58027728
>C doesn't even have strings.
>>58027949
>C does not have a proper string type.
>>58028059
>C doesn't have strings.
>>58028062
>C does not have a proper string type.
>>58028103
>C doesn't have strings
get a load of these webshits
>>
>>58028436
>import all the things
>loads of errors eliminated by static typing
>amazing polymorphism and type inference
>competes with many imperative languages for performance
>>
File: 1347485012842.jpg (465KB, 1061x1600px) Image search: [Google]
1347485012842.jpg
465KB, 1061x1600px
>>58028402
Sadly using a functional only lang would make game programming a nightmare. I'd like to learn that shit though.
>>58028436
Are you the guy who made that rougelike with those delicious sliding animations in /agdg/?

(Yes mods, This is sfw. Tits does not equal porn.)
>>
>>58028566
C does not have strings, given one particular generally accepted definition of the term 'string'.

C has strings, given another particular generally accepted definition of the term 'string'.
>>
>>58028566
>#include <strings>

kek
>>
>>58028587
>would make game programming a nightmare
[citation absent]
>>
>>58028587
>Sadly using a functional only lang would make game programming a nightmare.
Learn a langugae that can do functional and imperative comfortably together and is great for games programming.

F#
>>
>>58028589
>muh mental illness
>>58028597
>I'm literally retarded
>>
File: AHAHAHA.gif (491KB, 500x220px) Image search: [Google]
AHAHAHA.gif
491KB, 500x220px
>>58028601
>F#
>>
>>58028600
massive amounts of garbage collection are generally not things you want in game dev.
>>
>>58028629
>laughing with joy
Yes, it's pretty great :)
>>
>>58028589
>C does not have strings, given one particular generally accepted definition of the term 'string'.

No, that's just in your head, and perhaps in the heads of other sloppy thinkers without a clear understanding of the terminology they use.
>>
>>58028587
>Are you the guy who made that rougelike with those delicious sliding animations in /agdg/?

No, I don't go to agdg.
>>
>>58028665
care to explain why?

don't you like the culture / shitpost / progress?
>>
>>58028670
Yeah it's just a bunch of shitty memes spouted around, some stale shitposting about the tools of your choice, nothing gets classified as progress unless it's "juicy" visuals and so on.
>>
Need a little help here.

I'm working on a system that matches users based on location. One user enters zip code, the other enters their address. The user with the address specifies a distance they're willing to go.

I need an algorithm that will match up the distance from the address to the zip code. However, since zip codes have a large area, one tiny area of the zip code would be within radius, but the actual address would be outside of it. How can I make sure that the address will be in range of the user's preference based on zip code only?
>>
>>58028676
yeah that

plus, people might steal your idea.

i usually go there to see what people are working one and steal dsome ideas

nothing more
>>
Guys I finally decided on something to code. It only took me all day thinking about it
>>
>>58028710
What is it?
>>
>>58028692
>retards stealing from other retards
>>
>>58028632
yeah and i'm sure you only write C and C++ and the games you write totally need it
>>
>>58028589
The difference being the former definition is wrong (or rather it is jargon, slang, idiolect, or - dare I say it - Hindi), while the latter is correct.
>>
>>58028718
I'm just going to write a script to sort all my loose chinese cartoons into folders. Nothing spectacular but it's going to be useful as fuck
>>
>>58028725
there are some pretty good idea there, shlomo
>>
>>58028754
>right-click mouse-button
>sort by date
>sort by type
>sort by size
>>
>>58028754
>Downloading anime
>>
>>58028769
It's going to strip the shit in brackets and the episode name and put them all under the same folder. Easier than doing that by hand

>>58028770
>not
>>
>>58028738
Nope, C# F# mostly
>>
>>58028784
Then you have no excuse.
>>
>Report bug to project on Github
>Maintainer says he doesn't have enough time to investigate and asks you to create a pull request
I DON'T HAVE THE REQUIRED KNOWLEDGE
>>
https://github.com/opal/opal/issues/941
>>
>>58028794
For what? I can avoid garbage collection easily in those langugaes.
>>
>>58028632
for large enough systems the overhead of garbage collection tends to be largely equivalent to the overhead of malloc bookkeeping
>>
How do you print the address an iterator points to in gdb? p iter just returns the value the iterator points to, and I want the actual address.
>>
>>58028821
>Game Dev
yeah, we're talking about the kinds of systems you'd typically be building a game to run on at 60fps.
>>
>>58028825
https://gcc.gnu.org/ml/libstdc++/2010-03/msg00057.html
>>
>>58028821
...which is why you don't rely on malloc and make a custom allocator.
>>
>>58028848
Which brings us to the original point: GC might not be acceptable for video games.
>>
>>58028843
Thanks amigo.
>>
>>58028867
>GC might not be acceptable for video games.
eh, yeah. That's my point. Too much GC is shitty for game dev. Which makes purely functional langugaes a big problem.
>>
>>58028807
I'm so glad Trump won
>>
>>58028807
OLD
>>
Is there a way in Python where I could count the items in a list that are within a certain percentage of each other?

For example, with a 10% +/- set a list like
[1, 2, 3, 3.1, 2.9]
would say it has three 3s. I've thought about rounding but all my data points are floats and I don't know how finely I'd have to round everything to get useful results

I already have code that just loops over each element then loops over each element again and checks if it's larger or smaller than the element it's checking, but it takes however many elements I have squared iterations to finish, and the list I'm testing is 62000 elements long and the program takes a half hour to run

Any advise is appreciated
>>
File: IMG_3386.jpg (1MB, 3000x2000px) Image search: [Google]
IMG_3386.jpg
1MB, 3000x2000px
Muh canon eos 700d remote is workin :-)
Now just gotta make a nice PCB for it
>>
>>58025664
You can always use cx_Freeze to make an executable out of it. That way they won't need to install Python.
>>
>>58028973
What if you had
[1, 1.1, 2, 3, 3.1, 2.9, 3.5, 3.4]
?
>>
>>58029020
It would return that I had one 1, one 2, three 3s, and one 3.5
>>
>>58029073
I have no idea what you're trying to determine, then.

That doesn't make sense.

Why is there a 3.5? Why is the 3.4 not included?
>>
>>58026789
and when you stuck , dont understand something , how can you move on ...
>>
>>58029107
Don't, but no need to be hard on yourself, that won't get you unstuck.

Try to find an explanation from somewhere else, try to understand things from first principles, and don't give up.
>>
Woah, that was a blast from the past.
Writing Haskell and I just wrote () to call a function.
The nostalgia!
>>
>>58029093
I meant two 3.5s, sorry about that
>>
>>58029138
Why aren't there two 1's?

Why are there two 3.5s and not two 3.4s? Are you only caring about .5 increments? Is this configurable?

What the actual fuck are you trying to do?
>>
>>58028973
seems like a separate rounding function to map onto the list would suffice, if the results are not fine grained enough just adjust the function
>>
>>58028973
Why are you rounding? If you're looking to group elements within a specific (relative or absolute - this is also an important distinction to make, since you specified a percentage implying relative difference) it would make more sense to average them.
>>
>>58027912
>>58027931
>>58027960
Advent of Code is daily
>>
>>58029149
I reread your list, it would two 1s, one 2, three 3s, and two 3.5s. I really should have read closer. Yes, it's configurable

My code right now is
if current[len(current) - 1][0] > pattern[len(pattern) - 1][0] * (1 - req_sim) and \
current[len(current) - 1][0] < pattern[len(pattern) - 1][0] * (1 + req_sim):
similar.append([pattern, current])
>>
>>58029186
What if you have the following list:
[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9]
?

What is your output then?
>>
>>58027620
That's just it though.
OOP isn't a paradigm. It's an engineering principle.
Just like MVC. It's a simple intuitive idea, formalized into a solid principle backed by data.

And then consultants run away with it and ruins more or less everything.

You have no idea how much pain I want to inflict on my next fellow consultant who use the term "Big Data" to mean "semi-structured data". It makes me angry.
>>
I'm writing a simple lottery program and I want to compare two arrays for similar integers (one array is with user inputed numbers, the other with randomly generated). I created this algorithm but it doesn't seem to work properly - sometimes it works, but sometimes it just gives me a random or wrong result.
int [] lotarr=lottery.getlotArr();
for (int i=0; i<plyarr.length; i++){
for (int j=0; j<lotarr.length; j++)
if ( plyarr[i]==lotarr[j])
count++;

}
return count;
}
>>
>>58029138
What determines what number they get rounded by? The order of the list?
>>
>>58027843
>>>58027771
>The issue is that Lua is so light that they have to cut so many features and library functions from the standard that it feels like a sketch of a skilled designer sometimes.
>It does the job and you can work with it but you have to think about the implementation a lot more than you would with say, Python's "batteries included" mindset.
>According to the official "Programming in Lua" book the SLoC for all of the combined standard libraries comes to less than 4000. Yes. That small.

I have seen SQL procedures that are longer than 4000 lines of code.
It is not a pretty sight, but I've seen it.
>>
>>58029073
Covert each float to a an int but using a round up or round down. Look up float rounnding precision on py
>>
>>58029263
>I have seen SQL procedures that are longer than 4000 lines of code.
;_;

Kill me now
>>
>>58028867
That kind of depends on how much memory you have available.

If you know that you'll never need to stop to collect until you get to a loading screen, well, then that loading screen is about to pull double duty, isn't it?

People have built real-time trading systems in Java, by using carefully crafted object pools.
The gaming industry just have too much inertia put into C++ to ever go use anything else, unless that thing could use C++ libraries.
>>
>>58029246
First, fix your braces.

Second, your algorithm is double counting. If you have two 3s in plyarr and two 3s in lotarr, count will be incremented four times. Is that what you want? Probably not, in which case you should have a break after the if statement.
>>
>>58029246
so if the numbers from the lottery are 1,2,3 and I guessed 3,1,2 I still win?
I thought you had to get it exactly right to win the lottery
>>
How did you guys start with C++ data structures? Any suggestions?
>>
>>58028885

SJWism lost, and that's the biggest victory of all.
>>
>>58028973
I suspect that this is a much more difficult problem to solve than you might think.
>>
>>58029380
wear a skirt
>>
>>58029394
I'm afraid I don't know what I'm capable of to learn to sort linked lists without messing up the pointers.
>>
>>58029380
Read a language neutral textbook like CLRS and practice implementing the algorithms in C++. Use valgrind to unit tests to make sure you aren't fucking anything up.
>>
>>58029417
>>58029380
Read up on the structures involved and the algorithms used to manipulate them, then implement them yourself in C. It doesn't have to be particularly good or a re-usable code, more a matter of what's actually going on inside.

Armed with that understanding use the more mature C++ implementations.

What you cannot create, you do not understand.
>>
>>58029325
I added a break after the if and it seemed to work much better now though it still bugs out from time to time
>>58029379
it's supposed to make you guess 5 numbers from 0-49 and computer generates random numbers from 0-49. It's supposed to count how many of your numbers match to the computers.

Now I have to fix the problem of randomly generating numbers repeating.
>>
>>58029417
probably easier to sort an array of node pointers and then go over it and remake all the internal pointers
I don't know if that's optimal tho
>>
File: 110float.png (56KB, 1115x665px) Image search: [Google]
110float.png
56KB, 1115x665px
>>58029227
I get quite a few that it deems to be similar

>>58029247
Yes

>>58029284
I was thinking about that, sounds like a good idea
>>
>>58029472
I'm not asking what your algorithm does; I'm asking what you WANT it to do.
>>
File: 1480717773917.jpg (252KB, 1484x989px) Image search: [Google]
1480717773917.jpg
252KB, 1484x989px
>tfw going to fail my CS class because I didn't study for shit the whole semester and now I have to write 3 different programs at the end of the week
>>
>>58029456
Linked list of numbers, remove number from index.
It's just 5 numbers so the performance is more than okay.
Just generate numbers from 0-length of string minus 1.
>>
>>58029487
I've got a CS final in an hour and I'm shitposting instead of reviewing.

Please end my life
>>
>>58029455
True, but I have about 0 leads to learn about data structure and their algorithmic implementations. I hoped that I could find a book that was talking about pointer manipulation, but with little luck so far. Anyhow, I'll try to get them done in C, hopefully there is material I can work with. Thanks, anon.
>>
>>58029478
I WANT it to give me a list of elements in a given array that are within a certain percentage of each other, and to do so quickly and efficiently
>>
>>58029517
>give me a list of elements in a given array that are within a certain percentage of each other
That doesn't make any fucking sense, retard.

That's why I'm trying to figure out what your exactly range distinctions are, and if you're try to specifically group around .5 increments, and at what point a number belongs to the group above or below it.

Percentage closeness is relative, and if your set is nearly continuous, you must define the behavior.
>>
>>58029539
I'm trying to group around the first element it hits that is not within a certain percentage of another
>>
>>58029559
So the order of the set matters? If 3.4 comes before 3.5, you have two 3.4's?
>>
>>58029571
Yes
>>
>>58029442
Will look it up, thanks.
>>
Delicious tears of all the CS babbies with finals coming up
>>
>>58029571

I had the idea of diving the range into buckets and using a dict, but even that doesn't quite solve the issue of knowing WHAT the key is, given a data point. You'd still have to loop over the keys and check the range.
>>
>>58029578

What's the use case for this function anyway? What are you going to do with this data?
>>
>>58029559
Should the first number always be included in the list then?
>>
>>58029578
This function sucks bro. Think about taking another approach to your problem.
>>
File: java-vs-haskell.png (102KB, 2435x913px) Image search: [Google]
java-vs-haskell.png
102KB, 2435x913px
>>
>>58030025
now I understand what anon meant by white language
>>
>>58030025
delet this
>>
>>58030025
This is why you flee to JVM-based languages such as Scala or Kotlin if you really want to harness the power of Java based programming.
>>
>>58030084
[power needed]
>>
>>58030084
Scala is nightmarish garbage though. So the lesson is really avoid the JVM if at all possible.
>>
>>58030123
>>58030150

Exactly.
>>
>>58030163
are you under the impression haskell is jvm based?
>>
Analysis of my procrastination pattern suggests that the only thing more boring than programming is writing reports.
>>
>>58030238
you forgot your jokes
>>
>>58030025
what is this
>>
>>58030150
>Scala is nightmarish garbage though. So the lesson is really avoid the JVM if at all possible.

so why do companies use it extensively ?
>>
>>58030341
hackerrank submissions sorted by language

Java vs Haskell
>>
>>58030346
Scala? Because companies make bad decisions.

Twitter used it for ages, but abandoned it ages ago basically because they realised how utterly shit it is.

https://www.youtube.com/watch?v=uiJycy6dFSQ

JVM in general? Because Java is taught at every university, and java programmers are plentiful. So it suits large corporations who just want some dumb enterprise code written.
>>
>>58030379
so what is the best language to use in a company, say like, facebook or twitter, with millions of users?


how do we even know what language is the best?
>>
>>58030379
I think that guy has been single handedly responsible for Scala's drop in popularity.
>>
>>58030409
Tools in a toolbox.

There is no "best" language.

You can say a language is the "best" at a particular task, or for a particular (specific) scenario.
>>
>>58030409
purely functional ones. right now haskell's the only real option, companies are just stupid
>>
>>58030439
>companies are just stupid

/dpt/, ladies and gentlemen.
>>
>>58030430
so scala counts as one?
>>
>>58030457
Scala could be the best language to use at a company where 18/20 of the developers are primarily trained in the usage and deployment of Scala-based applications.

So, sure, Scala is the "best" language, given a specific situation.
>>
>>58030230
No, I'm just subtly saying that it is the best choice due to not relying on the JVM.
>>
>>58030439
>purely functional ones.

kys
>>
Can we just delete the time-span between today and 1990 and delete all the languages within and magically make a world where everything's built with 1950-1990 languages and frameworks?
>>
>>58030553
>kys
screenshott'd
>>
>>58030553
>tripfag shart in marter
>>
>>58030597
please don't acknowledge that a poster has a trip
>>
>>58030632
How else do we know who to shoot?
>>
>>58030409
>how do we even know what language is the best?
you assess each language by lots of criteria and see which is best for your particular problem.
>>
Implementing basic sorting functions for fun and profit.

Currently trying to figure out why my quicksort is 1) O(n^2); and 2) performs ~25x better sorting a 2 million element array compared to a 256k array.
>>
>>58030799
post code?
>>
>>58030737
what no you're supposed to completely hate everything and only suggest one language no matter what the situation is

otherwise your language fanboyism won't be validated
>>
File: image.png (133KB, 1680x1050px) Image search: [Google]
image.png
133KB, 1680x1050px
>>58026223
>What are you working on /g/?

Advent of Code 2016, day six.
>>
>>58030842
If you actually every worked in the industry, you'd realise you are completely correct.
>>
>>58030852
>he's still hiding FirstName LastName <[email protected]> to look like he's hiding his name
>>
New to coding here.
My school started me on Java so I have to learn it. What way did you guys practice when learning your first language? Was it particularly hard?
>>
>>58026719
Tcp resets often carry some information a clever user can use to figure out something. Drop the packets instead.
>>
As a learning project, I want to make a web app that will allow me and others to post their youtube links and play them for everyone to watch/listen, basically like plugdj. Basically, I want a project I'll be able to get up and running relatively quickly that will also have lots of room for improvements/optimization when I want to come back to it in the future.

What should I use for this? I've worked a bit with nodejs and php in the past, never used any modern frontend frameworks (just html/css/js). Note: I don't necessarily want the most efficient tool, I want something that might be useful if I ever try to find another job.
>>
File: 1463285950309.jpg (36KB, 600x564px) Image search: [Google]
1463285950309.jpg
36KB, 600x564px
somebody PLEASE invite me to the discord
>>
>>58031007
No.
>>
>>58030799
Also, why is std::sort a lot faster then qsort? C BTFO??

>>58030837
Sure
#pragma once

#include <algorithm>

namespace {
template <class Iter>
Iter partition(Iter begin, Iter end) {
auto pivot_value = *(end - 1);
auto left_end = begin;
for (auto it = begin; it != end - 1; ++it) {
if (*it <= pivot_value) {
std::iter_swap(left_end, it);
++left_end;
}
}
std::iter_swap(left_end, end - 1);
return left_end;
}
}

template <class Iter>
void quick_sort(Iter begin, Iter end) {
if (end - begin > 1) {
auto pivot = partition(begin, end);
quick_sort(begin, pivot);
quick_sort(pivot, end);
}
}


I think I found the bug though.
>>
>>58030919
I practiced simple console stuff because just doing that was amazing to me at the time, then I made small games and cool little projects to make my life easier.

But I'm self-taught, so maybe you're too old to find computers FUCKING AMAZING anymore.
>>
>>58031028
p-pls
>>
>>58031038
Mean to post this
>>
>>58031038
>Also, why is std::sort a lot faster then qsort? C BTFO??


because it uses Introsort
>>
>>58031038
qsort uses void pointers for generics which means indirection. That's part of it, at least.
>>
>>58031068
Why doesn't the C implementation do the same?
>>
>>58030881
Whatever. Are you doing AoC2016? If not, why?
>>
>>58031089
because its shit

i use codeForces
>>
>>58031089
I am, and I'm waiting on day 17
>>
>>58030852
>Day 6

You're quite behind and you should have chosen Python or Perl for those because these languages excel at the challenges that are present there.

For instance this is my solution to Day 6:
print(''.join([Counter(line).most_common()[0][0] for line in zip(*data)]))
>>
http://www.strawpoll.me/11889674
>>
File: i13544550026.jpg (179KB, 850x1015px) Image search: [Google]
i13544550026.jpg
179KB, 850x1015px
>>58031114
Please, don't say that. Doing AoC is for me a source of great joy.

>>58031118
Are you ranked?
Are you posting on r/adventofcode/?
>>
>>58031165
Not ranked even once, and I'm posting on that subreddit yes

I'm doing it to learn Python.
>>
>>58031165
Umaru is a cunt
>>
File: 1459876662096.png (58KB, 499x680px) Image search: [Google]
1459876662096.png
58KB, 499x680px
>>58031038
Does your quicksort algorithm even work?
You're supposed to have two ends
>>
File: ready_to_kill.png (176KB, 560x530px) Image search: [Google]
ready_to_kill.png
176KB, 560x530px
>>58031194
Picture

>>58031158
Maybe, but i am doing AoC to explore the deepest, darkest corners of Racket.
>>
>>58031158
>For instance this is my solution to Day 6:
And it's also much slower than a proper solution written in C.
>>
>>58031234
There were only a couple of challenges that would actually benefit from the speed of C, but for the most of them, you actually benefit from solving them quickly in Python and sacrificing the speed because you're gaining marginal advantage from C (like for solutions that run under a few seconds) and gain a lot from placing higher because you can solve these things quicker in the languages that are the right tool for the job.
>>
>>58031205
I ran unit tests, so I'm sure it works. I'm using Lomuto partitioning.
>>
File: 1468724811414.png (216KB, 504x529px) Image search: [Google]
1468724811414.png
216KB, 504x529px
>>58031223
>umaru
is that some kind of dirty 3d pig man whore?
>>
File: pi.png (319KB, 1920x1200px) Image search: [Google]
pi.png
319KB, 1920x1200px
Trying to redo SICP's linear pi procedure as iterative but all my variables remain constant despite my function working as I intend it to.

Can't figure out why say count isn't incrementing despite it stepping through the parentheses
>>
>>58031286
ur waifu a hot slut
>>
File: haskell.jpg (104KB, 768x1024px) Image search: [Google]
haskell.jpg
104KB, 768x1024px
>>58031331
>my waifu
>implying that's not me
>>
>>58031303
you if/else expressions are odds and probably wrong.
>>
>>58031388
oh
>>
>>58031374
well, if that's really you....
suck my dick
>>
File: regex.png (45KB, 354x166px) Image search: [Google]
regex.png
45KB, 354x166px
>>58031421
why would i be into you?
>>
>>58031234
>>58031263

And for the record, my solution takes half a millisecond to solve the problem, no matter how many times faster you'd get it in C, that's clearly no advantage.
>>
>>58031453
>my solution takes half a millisecond to solve the problem
Oh, so you're a liar now?
>>
File: too cozy.jpg (24KB, 409x409px) Image search: [Google]
too cozy.jpg
24KB, 409x409px
> make cup of hot cocoa
> sit down in my favorite armchair with my thinkpad
> put on wireless headphones
> listen to https://www.youtube.com/watch?v=fIuO3RpMvHg
> start programming on my own MUD written in pure portable C

life is wonderful thing :3
>>
>>58031460
>portable C
nice bait
>>
>>58031440
you are already into me tho
now be a good slut and suck my dick :3
>>
>>58031475
>shitty autistic dirty talk
you probably have a small penis
>>
>>58031459
No, you can time it yourself if you'd like with the timeit module.
>>
>>58030973
Anyone?
>>
>>58031492
every plane looks tiny from the grand canyon
now stop playing hard to get and suck me <3
>>
>>58031007
it's shit, avoid it.
>>
>>58031507
You want to make Synchtube?

Go with Node btw it has everything you need to build that (Websockets etc)
>>
>>58031540
didn't someone on /g/ make synchtube? I thought i recall a thread with them in in years ago..
>>
>>58031472
more portable than your mom lmao
>>
new thread when? :3
>>
>>58031588
After 310 posts
>>
File: 1465854616587.jpg (62KB, 1280x720px) Image search: [Google]
1465854616587.jpg
62KB, 1280x720px
>>58031223
WHO the fuck are you? I love racket too! And doing AoC in Racket, and have been using it as my main language for the last half year.
>>
>tfw exploring the corners of Racquet with CoC
>>
How do we destroy the Racket/Lisp menace?
>>
File: EW.png (323KB, 600x617px) Image search: [Google]
EW.png
323KB, 600x617px
>>58031713
>>58031742
>>
>>58031388

Did a rewrite using conditionals, correctly calculates the first one but the 'a' and 'count' simply aren't passed for whatever reason

(define (pi-get n)
(pi 0 1 n 0))

(define (pi sum a n count)
(cond ((= n 0) 0))
(cond ((= (modulo count 2) 1) (+ sum (/ 1.0 (+ a 2)))) (- sum (/ 1.0 (+ a 2))))
(+ count 1)
(cond ((= n count) sum))
(pi sum a n count))


I get the feeling I've misunderstood state variables in scheme
>>
>>58031934
plus use [ ] with cond
(cond <exp>
[<exp> <exp>]
[<exp> <exp>]
[else <exp>])
>>
>>58031934
(cond
(condition-a body-a)
(condition-b body-b)
...
(else body-else))
>>
>>58031742
>the Racket/Lisp menace
What do you mean?
>>
File: 2016-12-16-151813_435x78_scrot.png (3KB, 435x78px) Image search: [Google]
2016-12-16-151813_435x78_scrot.png
3KB, 435x78px
dont know how to design tic tac toe game

is picc related good enough?
>>
What are you working on /g/?
I'm making an assembly-like language and then basing an abstracted scripting language ontop of that language.
>>
File: Screenshot_2016-09-06_18-04-48.png (723KB, 1598x899px) Image search: [Google]
Screenshot_2016-09-06_18-04-48.png
723KB, 1598x899px
>>58032151
I have some like that in D, but I'm also making a VM. I haven't worked on it in forever though
This was for testing the read/write instructions
>>
>>58032226
hi Chris
>>
>>58032243
hi senpai
>>
>>58032226
The reason I said "Assembly-like" is that it'll offer a lot more power than regular assembly language, while retaining low level interfaces like registers.

I've already completed getting it to be a turing complete language, all I need to do is improve it.
>>
This my first year of university and we have programming classes.This semester is Fortran and the next one will be C++.I'm generally interest in programming but I don't really have any prior experience with it,but I thought it would be cool to start programming on my own,however the problem is:

>Should I start programming in Fortran or wait for the next semester so I can learn C++?Some people have told me that C++ is way better but I'm not sure what the difference is.
>How the fuck should I start?I downloaded Codeblocks but I seriously have no idea how to even create a simple program and how to run it,in classes we just write the code in Text Editor and run it through the terminal but our computers run Ubuntu
>>
>>58032405
>Fortran
weird
>>
>>58032405
Install gentoo
>>
>>58032331

I made two similar languages, one called SPP and one called SP4. The latter was more interesting, imo.

:main
cral res 0
call res MathThinger 25
prtl *(res)
ret 0

:MathThinger num
mult num *(num) 2
ret *(num)


All this would do is multiply the number passed to the function by 2 and then print it, but it was neat to have real functions. I don't know what I did with the other source, but I did some other basic shit, like recursive factorial and so forth.
>>
Rewrite again since I'm an idiot,

;;; R5RS
(define (pi-get n)
(pi 0 1 n 0))

(define (pi sum a n count)
;;; if n == 0, 0
(if (= n 0) 0)
;;; if count % 2 == 1, + ... else -, if count == n, sum
(cond ((< count n)
(cond ((= (modulo count 2) 1)
(pi (+ sum (pi-calc (+ 2 a))) (+ a 2) n (+ count 1)))
(pi (- sum (pi-calc (+ 2 a))) (+ a 2) n (+ count 1))))))

(define (pi-calc a)
(/ 1.0 a))


It seems to just iterate once, can I call defined functions from conditional branches?
>>
File: not sure if joking or retarded.jpg (64KB, 604x430px) Image search: [Google]
not sure if joking or retarded.jpg
64KB, 604x430px
>>58032405
>Fortran
>2016
>>
New thread:

>>58032469
>>58032469
>>58032469
>>
>>58032473
Yeah I'm not sure why either.The professor himself that Fortran is kind of outdated
Thread posts: 312
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.