[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: 314
Thread images: 23

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

http://mattgemmell.com/what-have-you-tried/
http://www.catb.org/~esr/faqs/smart-questions.html


What are you working on ?
>>
thanks for not posting a fag image
>>
>>57246369
This can also be trivially proven:
https://repl.it/EGct/2

First print shows the pass by value, you can't overwrite the sc instance outside of the Swapski method. Second print shows pass by reference, you can overwrite the sc instance outside of the SwapskiRef method.
>>
>>57246452
now that's what i call a cool story bro
>>
Building a Word Ladder in C++ but im not sure how I should organize each word. I would make a tree but it would end up having possibly thousands of words and id like to limit as many as I can. What ADT am I overlooking /g ?
>>
> https://www.reddit.com/r/programming/comments/59cq8r/eating_linus_shit

Why redditards are such rettitards?

Just look at this shit!
indirect = &(*indirect)->next;


How can they masturbate to something so disgusting?
>>
>>57246597
>linking directly to plebbit
>>
>>57246452
>>57246573
it's an important distinction at some point, though early on it would be more confusing than anything else. the semantics here make sense, of course, because this is an edge case (and probably the wrong move in most contexts where it could potentially be used) where more explicit semantics (like those of ref) are more suitable. needless to say, for a beginner to hear this and and go around using ref all the time to avoid passing things (wholly) by value (or so they might think) would not be a positive thing
>>
beginner here with a silly question. I have this code:
button1.layer.borderColor = UIColor.lightGray.cgColor


Is it correct to say that cgColor is a property of lightGray, which is, itself, a property of UIColor? If so, is there a term for a nested property?
>>
>>57246597
>indirect = &(*indirect)->next;
Seems like a perfectly reasonable way to traverse a linked list to me. You go to the next thing until you are at the thing you want to be at. Couldn't be simpler.
>>
>>57246597
How can that function reference head if it didnt pass it? Am I missing something?
>>
>>57246778
I think it's supposed to be pseudo code but you could always just imagine that head is global.
>>
>>57246691
updating my question a bit, I noticed that the book states:
>UIColor has a property called lightGray that returns (shock!) a UIColor instance that represents a light gray color

When does a property "return" a modified instance of a class? Isn't that only for functions/methods? Not clear on what's going on here.

Say I do
newThing = myObject()

that instantiates an object right?
so where does the .lightGray come in?

Thanks senpaitachi
>>
>>57246691
>>57246816
I just read the docs
answering (kind of) my own question for posterity:

lightGray is an example of a type property (class var) of type UIColor, whereas cgColor is an example of an instance property (var) of type CGColor

now I have to learn when to use type properties and when not to
>>
>>57246597
That looks exactly like my style of coding.
>>
I underestimated the time it would take to generate every possible permutation of a list of 15 items. I left the program running overnight, thinking I'd at least make some headway.

Unfortunately, doing some math based on the progress it made, it's going to take 4 years to try every permutation.
>>
>>57246691
>>57246816
>>57246995
follow-up question: Why aren’t we using an accessor method here? Why are we accessing this property directly? Is that because it's a class (type) property?
>>
>>57247023
should take less than 1 sec
>>
>>57247131
Literally a trillion different permutations in 1 sec, are you stupid?
>>
>>57245870
When you're working with geometry, triangles, vertices and meshes there's often really no variables that make more semantic sense.
>>
Got a basic brainfuck interpreter working, wasn't too hard. Missing lots of features but does a hello world just fine.
>>
>>57247023
Time to explore alternative approaches. What's the problem?
>>
>>57247228
>missing features
How does one miss features in a bf interpreter and still have it work?
>>
>>57247263
Well I just realised when I check for the ending ],
I don't check for any earlier [, so it would terminate early. I don't have dynamically increasing storage size, and I'm currently using big ints instead of shorts/chars/whatever so programs can't use overflow. I might also have to look at what happens when an EOF is encountered, from reading the wiki
>>
>>57247210
you can at least prefix them with something, if you're transforming something from one thing to another then prefix the variables with one thing and another
>>
>>57247023
what exactly is the problem?
>>
>>57247131
There are 1307674368000 possible permutations. My (admittedly very unoptimized) algorithm gets through about 10000 permutations per second.

My algorithm is tuned for finding an arbitrary permutation given the starting list and a permutation index from 0 to factorial(list.length)-1. It can do it in (list.length-1) swaps.

This is great if you want to know, for example, what the 347th possible permutation of a deck of cards is. It's not great if you want every permutation.

There are better algorithms (such as the Steinhaus–Johnson–Trotter algorithm) which, given a particular permutation of a list, will return the next permutation in a single swap. This is great here, but obviously not great if you want an arbitrary permutation (347 swaps to get the 347th permutation). I'm currently in the process of implementing the algorithm in Ruby.

>>57247251
I'm helping a friend with a math problem, just for fun. There's a particular arrangement of 15 billiards balls (numbered 1-15) in a triangle such that the value of each ball is equal to the difference between the balls directly below it.

You can probably find it through critical thinking (we know, for example that 15 has to be on the bottom row) but I wanted to try brute forcing it by trying every permutation.
>>
>>57247315
sure i could, and i often do when i feel it helps readability

but in that particular case i really don't think naming them 'vertexA' and 'vertexB' instead if 'a' and 'b' would have made any difference at all.
>>
why do constant variables exist??
I mean you could know that sometimes a constant just by naming it in all uppercase.

seems like a waste of a keyword to me.
>>
>>57247503
*somethings
>>
>>57247503
Compiler optimization. If the compiler knows the value will never change, it can replace it with a literal value in the machine code.

Also peace of mind if you're creating a library that will work with other people's code. No way for their code to change a value you expect to be constant.
>>
>>57247503
Because semantics by convention is usually a bad idea.
>>
>>57247503
This. All "vari"ables should be implicitly constant. Mutability should not exist.
>>
>>57247533
makes sense, thank you kind anon.
>>
>>57247557
wouldn't that bloat code though?
How would primitives work? assign a primitive for each variable?
>>
>>57247585
Monads.
>>
>>57247605
functional programming is scary.
>>
>>57247616
rather than modifying a value, you take an extra parameter (the initial state) and return an extra value (the new state), i.e

input -> output
becomes
(s0, input) -> (s1, output)

then you can chain these operations together by feeding the out state into the in state
>>
I'm on chapter 6 on LYAH.

map (mod 3) [1..10]
is apparently equivalent to
[mod 3 x | x<-[1..10]]
.

But i don't get how to write the map equivalent of
[mod x 3 | x<-[1..10]]
.
>>
>>57247671
I get what you're saying, but I don't understand why thats better than regular variables.
>>
>>57247707
learn about applicatives anon
>>
>>57247707
1) use "flip", this reverses the order of parameters
flip mod 3

2) use an operator section
you can turn functions into infix operators using backticks (``)
When you use an operator section, it respects which side the arguments are on, e.g.
(/3) is not the same as (3/)
You can use both together
(`mod` 3)

3)
If in doubt, use a lambda expression

map (\x -> mod x 3) [1..10]
>>
>>57247756
it's not better. functional programming is a stupid gay meme
>>
How much general knowledge about computers do I need to become a good programmer (as opposed to codemonkey)?

I do know in general how a computer works, what TCP/IP, a compiler, interpreter, OS is, what a CPU, RAM, Register, Hard Drive, do.

Is something further in detail needed?
>>
>>57246428
What's the coolest thing you've written in Prolog?
>>
File: arraysort.png (12KB, 307x213px) Image search: [Google]
arraysort.png
12KB, 307x213px
Anyone here who knows f#?

I am a beginner and trying to make some code that can take an array, sort it, and then return the sorted array.

I know there are 'Array.sort' and 'Array.sortInPlace' operators, but I'd like to learn to make it without those.
I'm thinking i have to use merge sort somehow, but it confuses me... Anyone here got some tips on how to get started?

Pic is some code i tried to get to work, but it doesn't
>>
>>57247822

i once tried to reconstruct a sherlock holmes case and make the program solve it logically

but it made no sense because sherlock holmes short stories make no sense.
>>
>>57247831
Here's a simple sorting algorithm (written in Haskell, you can translate it)

sort [] = [] 
sort (x:xs) = sort low ++ [x] ++ sort high
where low = filter ( < x) xs
high = filter (>= x) xs
>>
>>57247816
Depends what kind of programming you want to do. If you want to write kernels you're gonna need to know a hell of a lot more than that. For just general web/desktop applications all you really need to know is that registers are faster than ram is faster than disk is faster than network.
>>
why are web devs not respected as much as other programmers?
>>
>>57247972
Sorry, but are you a web dev?
Web devs aren't allowed in this thread.
Please leave.
>>
File: Lena Meyer Landrut2.jpg (3MB, 1425x1923px) Image search: [Google]
Lena Meyer Landrut2.jpg
3MB, 1425x1923px
>>57247972

>web devs
>programmers
>>
>>57247991
Webdevs are useful unlike beardy neets like you.
>>
>>57247892
>shitty O(n^2) efficiency
>filters the list twice instead of just using
partition
, preventing deforestation and being needlessly verbose and slow
1/10 for trying
>>
File: 1435372828296.png (750KB, 854x853px) Image search: [Google]
1435372828296.png
750KB, 854x853px
>>57247972
>>
>>57247972
>>57248029
>It's another "webshit comes into /dpt/ to bitch about being a webshit" episode
>>
>>57248037
What makes you think I'm compiling it on GHC, and not a custom built compiler that recognises this specific function?
>>
>>57247991
im... im not a web dev...
i can fizz buzz in 10 languages across different paradigms AND i can code in brain fuck.
>>
>>57248037

i thought >>57247892 was supposed to be quicksort
>>
>>57247892
Idk Haskell, but appreciate the answer. Ill try my best
>>
i can run flex foo.l from the shell prompt, but not from a shellscript, why?
>>
>>57248055
>Webshit
Nice arguments you have here. You wasted all your life with useless FizzBuzz-tier garbage and now need to insult the superior knowledge of smarter people.

Your whole life you lied to yourself as the fucking degenerated ego-inflated ape you are.
>>
>>57248055
please lets all be friends.
>>
>>57248176
>grrrrrr i need to feel better about myself
>instead of actually doing something like getting a job, i'll leave /wdg/ and go attempt to boost my ego by screaming FIZZBUZZ x--DDDDDDDDDDD in /dpt/
>>
>>57248260
>Insulting people
>Wondering why they would react
1/10. You're dumb.
>>
moving on

listOfFuns = map (*) [0..]
gives me a list of functions. So i thought
>how do i call all these functions?
and this is what i came up with.
take 11 [f x | x<-[5], f<-listOfFuns ]

I feel retarded. How would you do this?

[]
take 11 [f x | x<-[5], f<-listOfFuns]
>>
>>57248298
>It's yet another episode of "webshit comes into /dpt/ to bitch about being a webshit"
>>
>>57248307
Ah, those last two lines were not supposed to be there.
>>
>>57248298
POO
>>
>>57247972
why are gooey guys not respected as much as other programmers?
>>
>>57248107
It's not quite quicksort, but it shouldn't be O(N^2)
He's right partition would be faster, partition does both ends

>>57248114
If it's an empty list, return an empty list
Otherwise, if it's a non-empty list produce two lists
1) All the (other) elements smaller than the head
2) All the (other) elements greater than or equal to the head
Run the sort algorithm on both of these

The result is the lower one, then the head element, then the higher one
>>
>>57248318
You really need to stop screaming "webshit" everywhere if you don't like it. But whatever you're obviously unable to process such a simple correlation.
>>
>>57247361
That sounds like a problem that can be found using a branch and bound type algorithm.
>>
File: web dev.png (67KB, 822x143px) Image search: [Google]
web dev.png
67KB, 822x143px
>>57247972
>>
>>57248307
How do you WANT to call all those functions?
You could call them all with the same argument
(your list comprehension isn't actually bad, at all)

Here's another way to write your comprehension

listOfFuns <*> pure 5
or
listOfFuns <*> [5]

You could also use ZipWith

ZipWith ($5) listOfFuns
$5 is a function that "applies 5" to another function
>>
>>57248380
thats completely different.
>>
>>57248421
whoops, that should be map, not zipwith
>>
>>57248395
You really need to stop bitching about your skill choice if you don't like it. But whatever you're obviously unable to process such a simple correlation.
>>
>>57248391
quicksort is O(n^2). what's he supposed to do about that?
>>
>>57248400
node is the future. embrace it.
node should be the end all implementation for web programming, cant wait for the day it is standardized, so we can stop all this web framework hell nonsense
>>
>>57248307
>>57248421
by "how do you want to call all those functions", I mean

> you could have a map from keys to functions, and lookup a key and use that one
> you could have a list of values, and then apply the first function to the first value, second to the second, etc
>you could do above, but generate all combinations (that's what <*> does (for lists))
>you could ask the user for a number, then apply the function at that position in the list

>>57248462
Oh, nevermind, I'm an idiot.
>>
>>57248465
BURN
U O
R D
NODE
>>
>>57248462
CS graduate here o/

quicksort is only O(n^2) in the worst case.
>>
>>57248497
> CS graudate

thats redundant, everyone in /dpt/ is a PHD.
>>
Why is there a flawless plug-in for Eclipse for Python (PyDev), but I cannot find any for Java?
>>
>>57248515
>everyone
That's redundant, everything is a part of my subconscious self.
>>
>>57248133 anyone?
>>
>>57248488
in order

(lookup key list) <*> (pure value)
-- the <*> and pure is because we're applying inside the maybe monad

ZipWith ($) funs vals

funs <*> vals

n <- readLn
(funs !! n) x
>>
>>57248421
Well, the original thought was to call all the functions with the same argument, so of course like the dumbass noob i am my first thought was to go
listOfFuns 5


My list comprehension does the job, but it just looks clunky to me. I could just imagine someone on /dpt/ going
>In Haskell this is just *insert three characters of code *
>>
>>57248465
node is dying just like every meme framework/platform before it
>>
>>57248573
> node
> dying

[citation needed]
>>
>>57248532
it has flawless java support out of the box retard, it's primarily a java IDE
>>
>>57248552
map ($5) listOfFuns
(for everything in the list, apply 5) listOfFuns

your comprehension makes sense too, except the unnecessary (x <- [5])

[ f 5 | f <- listOfFuns ]
>>
Best tool to parse c header to json or xml?
Tried with pycparser but that pile of shit can't even get past
 __gnuc_va_list 
>>
>>57248465
>node
>npm everything
look mom, I made a webshite.
>>
>have a programming project
>it's too hard for me
>work well over 40 hours on it
>still not finished
>can't enjoy anything else in my life while it's hanging over me
>starting the downward spiral of depression again
>just want to say fuck it and never show up for class again
>doing so would be going nuclear on my already crappy life
>>
>>57248602
dependency hell is a bitch.
>>
>>57248594

I installed the C/C++ version and lack the option to start a Java project.
>>
>>57248612
sounds like you need more anime in your life.

might I suggest you spend some time off and focus on ricing your environment?
>>
>>57248431
How is that any different?

Web dev, in as far as it can be said to be programming at all (which is increasingly true nowadays), is essentially all about the GUI.

Unless by 'web dev' you mean backend. Then this >>57248400
>>
>>57248552
>>57248595
and equivalently
listOfFuns <*> pure 5
listOfFuns <*> [5]
>>
I'm no longer N33T.
How do I attain the motivation to program after a day at work?
>>
>>57248677
web dev is a general term for a full stack developer.

so yeah IT IS different.
>>
>>57248630
>I installed the C/C++ version and lack the option to start a Java project.
>I installed the C/C++ version
GEE

I WONDER WHY
>>
>>57248465
No its not,
php is here to stay since its easier and faster to setup a decent website
c# is meh and java is total crap for it.
Node is also meh, it has no redeeming features and the syntax also gets weird at moments.
Rust can be the future but as far i have seen so far people are just writing linux viruses in it.
>>
>>57248708

REEE

I WANT BOTH JAVA AND C++ PROJECTS ON ONE IDE
>>
>>57248699
get into VR programming and program yourself a waifu.
>>
>>57248595
>except the unnecessary (x <- [5])
>[ f 5 | f <- listOfFuns ]
Lol, I didn't fucking even think of this.
>>
>>57248708
calm down faget, you shouldn't need separate versions

>>57248726
i got the android version and it has both java and C/C++, dunno if you can add modules or something
>>
>>57248726
Intellij master race
>>
>>57248726
If you get the java version, you should be able to install the C/C++ tools via the plugin manager, maybe you can get the Java shit through the one you downloaded as well.
>>
Leaving the source code of my bot here if anyone is interested:
https://gist.github.com/anonymous/407bbc3750727ca91d9b6d568a46b5f7

It doesn't work well and implements naive datamining methods but some piece of codes can still be used for similar projects.
>>
I wrote a small program that takes a 32-bit unsigned int and outputs the bits to a character array. Now I need to convert it to base-8. How would I go about doing that?
>>
>>57248726
if you go to
>file -> new -> other...
then do you not have a java -> java project option?
>>
>>57248726
If you spent like 3 minutes looking at the Eclipse download section you'd have seen this https://eclipse.org/downloads/compare.php?release=neon and the instructions hyperlink that explains how to add features.

You are officially the niggest.
>>
>>57248810

Sadly not ...

I will try to do as >>57248766 said.
Because it would be absolutely retarded if you can easily combine C++/Python, but not C++/Java in one IDE.
>>
>>57248833
the instructions are fucking useless tho
>>
File: it gott.jpg (43KB, 495x375px) Image search: [Google]
it gott.jpg
43KB, 495x375px
what programming language are compilers themselves written in?
>>
>>57248726
Then use VS Code.
>>
>>57248706
Well, yeah, then this >>57248400

Alternatively, the problem might be that real, respectable, full stack developers simply don't call themselves "web devs".
In any case, there seems to be a disjunction in intuitive understandings of the term "web dev", as just demonstrated.

Sort of like the word 'feminism'. Someone calling themselves feminist thinks of the word as standing for fairness, rationality and justice, while everyone else just thinks 'feminazi'.
>>
>>57248894
>tfw modern C compilers are written in C++
>>
Can anyone point me to a resource for learning about docker?
>>
>>57248919

AHAHHAHAHAHAH

>muh "OOC is shit" fags
BTFO
>>
>>57248850
try help -> install new software

"work with" http://download.eclipse.org/releases/neon

and look in"programming languages"

it doesn't say java for me even though i unchecked "hide items that are already installed" but whatevs go check it out
>>
>>57248734
tactile feedback when?
>>
>While IntelliJ IDEA is an IDE for Java, it also understands many other languages, including Groovy, Kotlin, Scala, JavaScript, TypeScript and SQL.

>No Ruby
>No Python
>No C/C++

REEEEEEEEE
>>
>>57248964
im working on it.
>>
>>57248944

AHAHAHAAHAHAHA

>muh "muh "OOC is shit" fags" is shit fags
BTFO
>>
>>57248968
>Settings -> Plugins -> Install JetBrains plugin
>>
>>57248968
don't let the shills trick you, eclipse is fucking awesome and it's free even for commercial use
>>
>>57246816
Oh fucking god the horror

why is OO taken to such a ridiculous extreme where there's a fucking CLASS to represent a color? Can't it just as easily be represented any number that contains 32 bits?
>>
>>57248986

i know, but switching between two installation for either c++ or java is kinda very retarded
>>
>>57248968
V S C O D E
>>
>>57248987
because said class can perform transformations on the color.

did you really think the Color class only stored the color?
>>
>>57249009
it's all on one installation, you can add components as needed
>>
>>57248986
dont let this cuck hipster you into using dated IDEs like Eclipse.

install Intellij IDEA and increase your productivity.
everythings an plugin in IDEA
>>
File: Abstrakte Hölle.jpg (192KB, 854x859px) Image search: [Google]
Abstrakte Hölle.jpg
192KB, 854x859px
>its another "we made all these new, exciting features for you, so you can enjoy 4 hours compilation time and forced new syntax" episode
>>
>>57249044
kill yourself shill there is literally nothing wrong with eclipse neon
>>
File: ants.jpg (81KB, 400x225px) Image search: [Google]
ants.jpg
81KB, 400x225px
>>57249026
It's overengineered. 90% of use cases don't need to perform transformations on the color, and when they are needed it's usually in an outside case where the methods you've pre-rolled don't even apply.

And you also ignore the many cases where a developer who does need that kind of functionality just ignores what the API provides because they're too lazy to look it up, and just roll their own.

This is how we get software bloat.
>>
>>57249099
>And you also ignore the many cases where a developer who does need that kind of functionality just ignores what the API provides because they're too lazy to look it up, and just roll their own.

that sounds like a personable problem, you cant blame the tool for the users retardation.

Also many libraries offer modular functionality (decorators), so you can only use what you want. Reducing bloat.
>>
>>57249053
Nothing wrong, but it's shit for big projects. There's a reason to why Google chose IDEA as its IDE.
>>
>>57249137
Mama google always knows best.
>>
>>57248905
Not an IDE.
>>
>>57249152
It definitely is with the right plugins. Not all languages have all the right plugins though.
>>
>>57249137
because google is literally made up of pajeets and normies

eclipse is the industry standard for java
>>
>>57248968
IDEA Python
http://plugins.jetbrains.com/plugin/?id=631

IDEA Ruby (There's RubyMine from JetBrains, too)
http://plugins.jetbrains.com/plugin/?id=1293

IDEA C/C++ (There's also CLion from JetBrains)
http://plugins.jetbrains.com/plugin/?id=1373
>>
>>57249198

>google
>normies
>>
>>57249198
>eclipse is the industry standard for java
Maybe in the basement industry.
>>
>>57249212
ok then average IQ pseudonormie spergs and women and minorities
>>
>>57249196
It's shit made by MS. Stop shilling for it.
>>
>>57249099
ALSO, if I need to do transformations on color, there are much more efficient ways that make use of operators that you can't use with an object. Add to that most classes of this type tend to pack the data in the most babby-tier simplistic way imaginable (r g b and a as separate properties, often in a language where you can't choose to use a smaller format for numeric types).

I understand you're trying to make it simpler, trying to make things "easy to grasp" for people who don't want to spend their entire lives thinking about how bits are passed through circuit board traces, but this is just extra work for little to no gain. You're also passing all that extra BS down to those same inexperienced coders-- having to instantiate, capture in a variable, run a few methods on an object which is just going to be converted to a 32-bit integer further down the line anyway.

Button.color = 0xAAAAAAFF seems a lot simpler than

OColor mycolor = new OColor(OColor.COLORS.White);
mycolor.setOpacity(OColor.OPACITIES.one_hundred_percent_opaque);
Button.setColor(mycolor, false, true, false);

You know, HTML and CSS use hexadecimal color codes, and nobody complains that it's too complicated.
>>
>>57249229
>projecting this much
Being butthurt won't take you out of your mothers basement.
>>
>>57249249
>le google employees are geniuses meme
lol ok normie
>>
>>57249229

>women and minorities

as cleaners, clerks and accountants, maybe.
all the coders at g**gle are f*cking white males.
>>
>>57249247
bla bla bla
>>
>>57249136
I can blame the tool for (exclusively) being a watermelon splitter, a cheese-cutter, an onion dicer etc... when just having a simple knife would be just as valuable at those tasks, and proficiency with said knife would make me a far better programmer overall than constantly reaching for whatever whizz-bang modern gizmo I supposedly need for each separate task.

I'm mad about it because high-level languages (well, Java-based ones anyway) don't have to be so awful. People who had little practical experience wrote all this stuff from ideology, and now we're basically stuck with it.
>>
>>57249247
Are you tying to teach a dense basement dweller anything?
Cuz it won't listen to you.
>>
>>57249309

there are languages like groovy and cyclone and whatnot that try to """enhance""" the java experience.

whats important is the idea of a "universal" language that you can run everywhere and that has large corporate backing.
>>
>>57249316
>muh 8 byte object instead of a 4 byte integer
>m-muh b-bloat
>>
>>57247361
>the value of each ball is equal to the difference between the balls directly below it.

         5
4 9
7 11 2
8 1 12 10
6 14 15 3 13


and

         5
9 4
2 11 7
10 12 1 8
13 3 15 14 6


If you want to brute-force, do it right.
>>
File: 1476563481187.jpg (579KB, 1080x1080px) Image search: [Google]
1476563481187.jpg
579KB, 1080x1080px
Guys I'm Python newbie , I'm trying to do some beginner language processing,I have key value pairs that look like this

('his', 'beauty') 1
('all', 'eating') 1

But I have no idea how to get the value by accessing the key...I've tried
bigram[" 'all eating'"] ,
bigram ['all , eating'],

etc many other combinations help
>>
How did people even program back then, without fancy frameworks and the internet to consult?

No wonder that programmers still have this autism-image attached amongst normies. Back then you really needed to be dedicated to get even the most basic stuff done.
>>
>>57249369
it's not even hard, only pathetic normies need gay frameworks and curryoverflow hand-holding
>>
>>57248307
map ($ 5) listOfFuns

:t ($ 5)
($ 5) :: Num a => (a -> b) -> b
>>
>>57249368

Afaik what you did is two lists with two items, not a key/value pair.

A key/value pair looks like this

german_dictionary { "Police" : "Polizei", 
"Germany" : "Deutschland" }


Then your method of accessment should work.
>>
>>57249334
You're right. 4 extra bytes is nothing when you're only coloring a single UI element.

But when you try to use that same approach to set up a graphics pipeline, then it becomes an issue. You may scoff, but right now people are actually writing games in Java and C#, something unimaginable a few years ago, but CPUs can handle it-- sort of. Every ten seconds or so there's unavoidable frame dropping because they're waiting on the GC, and it just unilaterally interrupts whatever shit is going on in the main thread.

When tech advances that it's practical to do something simplistic and stupid, and not necessarily easier than saner ways, people will do it. Unfailingly.
>>
>>57249368
[] Lists
() Tuples
{} Sets
You have a tuple.
>>
>>57249369
by using existing structural/system design engineering practices and build thorough design and requirements documents and map out the domain

it was an engineering practice before it became a faggot hipster sjw framework paradise
>>
>>57249368
Not really sure what you're trying to do there. Maybe post the entire script if it's just a few lines?
>>
>>57248543
>>57248133 anyone at all?
>>
>>57249473
what have you tried?
>>
>>57249419
except when () means generator expression and when {} means dict literal like >>57249407
>>
>>57249437
Also, in programming, you only need to master a few concepts, and how they link together, to do basically anything. Some people looked at the long chains of instructions they had to make things happen and thought it was too complicated, and they started encapsulating that stuff in objects.

A lot of times, it makes perfect sense to do that.

I'm really liking what I'm learning of functional programming, it's like a return to that old paradigm, but with far greater flexibility. Hopefully we don't take it too far and create another enterprise abomination.
>>
>>57249482
jonathan@joestar:~/bin/08348$ cat ./build.sh
flex arith.l
bison arith.y
gcc -o arith.linux.out arith.c arith.tab.c -lfljonathan@joestar:~/bin/08348$ ls
arith.c arith.l arith.l~ arith.linux.out arith.tab.c arith.y arith.y~ build.cmd build.cmd~ build-output.txt build.sh lex.yy.c SPL
jonathan@joestar:~/bin/08348$ ./build.sh
flex: can't open arith.l
: cannot open: No such file or directory
jonathan@joestar:~/bin/08348$
>>
>>57249437
>faggot hipster sjw

>>>/pol/
>>
File: scala.png (13KB, 167x246px) Image search: [Google]
scala.png
13KB, 167x246px
>>57249504
>Hopefully we don't take it too far and create another enterprise abomination.
>>
>>57249528
Ohoho! You told him, son!
>>
>>57248765
my nigga
>>
>>57249330
Javascript is this-- kinda. No corporations back it for anything other than being a de facto standard (except maybe Adobe, but who cares about them?), they always have their own shit they want to push.

Node.js is pretty interesting, so are the forthcoming revisions to the language (except for actual real classes in Javascript-- really, fuck that shit. Why the fuck am I using the 'new' keyword in a high-level language?).
>>
>>57249518
>jonathan
https://www.youtube.com/watch?v=CMNry4PE93Y
>>
>>57249536

what do you dislike about scala?
>>
>>57249528
thanks for correcting the record
>>
File: snap.png (27KB, 596x694px) Image search: [Google]
snap.png
27KB, 596x694px
thanks for the responses
>>57249447

it looks like a simple assignment but I've never used Python before

Basically I need to split the text in one word, and two word pairs then count each word and each pair. Then when I input a word or a word pair I need to get how much that is in the text

However I don't know how to access the two word pair, Unigrams[word] works for the one word, but I don't know how to access the Bigrams[] ?
>>
Gonna make a cmatrix clone
>>
When you pass a string to a function in C it will read it as a pointer to the first element in the array.
Won't the function only know the first element? Does it know about the entire array that is still in the main?
I have a function here that's supposed to return
the size of the string, but I can't get it to work.
int stringSize(char *words)
{
int counter=0;
for(int i = 0; words[i]!="\0"; i++)
{
if(words[i]!="\0")
counter++;
}
return counter;
}

int main()
{
char words[]="okey";
printf("%d", stringSize(&words));

return 0;
}
>>
>>57249627
Don't you want '/0' here instead of "/0", or does it not matter
>>
>>57249627
>"\0"
Should be '\0'
>>
>>57249655
Also flip the slash
>>
>>57249621
OK I see what's happening. Your regexes have returned a list of tuples.

I think there are built in functions you can use to convert those to dicts the way you waint, but failing that the only way is to loop through the list, testing the first element of each item.
>>
>>57249594
>turtles
take your shitty unmanly jojo and fuck off m8
>>
>>57249369
This is actually a really interesting topic; it's one reason why I started listening to programming podcasts. During the 90s, people lived on Compuserve, PINE, Usenet, and IRC and this is where information was shared. Previous to the 90s, people relied on textbooks and traditional communication by landline or letter.

One thing that also helped was that the field was much simpler in the fact that any given programmer didn't need to know as much as they do now; it's a hell of a lot easier to start with Basic, Pascal, FORTRAN, or C and move onward and absorb in the 80s unlike now where we have the internet frontier mix of webdevs making things and webshits making lots of useless things/frameworks.

Older programmers and webdevs have been saying that the newer generations are honestly missing out on a chunk of information because they don't get to really live as close to the metal as they did among other reasons. They lived in a crazy and exciting time, we just live in a crazy time.
>>
File: ayy.jpg (34KB, 600x403px) Image search: [Google]
ayy.jpg
34KB, 600x403px
Would you choose Google over Facebook for an internship if Facebook offered 20% more?

I feel like a retard whichever I choose.
>>
File: Chrollo.jpg (92KB, 522x418px) Image search: [Google]
Chrollo.jpg
92KB, 522x418px
>>57249728
>They lived in a crazy and exciting time, we just live in a crazy time.

>tfw this is true
>>
>>57249627
It only knows the location of the first element, but that's all you need to know, the locations of the other elements can be found by looking "forward" in memory until you encounter the '\0' (null) character.

"" enclose string literals, '' enclose character literals. words[i] is a character (the i'th character in string word), so you want to compare it to a character, not a string.
>>
>>57249756
both are exceedingly jewish

go with facebook imo
>>
>>57249756
ah, you're still on this
the money isn't so important in the long run but doesn't that detail make it easy, given that you don't know anything else for sure? there are great people at both places to learn from
>>
>>57249627
btw, you just want
stringSize(words)
, as you seemed to correctly understand the variable words is a pointer to a char, so &words is actually a pointer to a pointer char, while your function accepts only a pointer to a char.
>>
>>57248968

those have their own dedicated ides.

>No Python
https://www.jetbrains.com/pycharm/

>No Ruby
https://www.jetbrains.com/ruby/

>No C/C++
https://www.jetbrains.com/clion/
>>
>>57249896

so do I really need to have 4 IDEs installed?
>>
>>57249912
no, you should always have a backup IDE just in case, so make it 8.
>>
>>57249756
I'd go with Google because it currently has more interesting projects than Facebook. Google also has a longer lifespan than Facebook. Both companies are equally bad though. I don't consider money interesting for an internship.
Also, do your best and try to land a job at the company you choose.
>>
>>57249912
no, just pick one programming language.
>>
>>57249348
>>57247361
literally a binary tree
>>
>>57249999

well, i like ruby best, but the jobs are with java(script)

sad!
>>
Why don't we just make a modern P2P imageboard? Is it that hard?

>git clone https://github.com/bitcoin/bitcoin.git

Just imagine about having unlimited distributed bandwidth, being able to share large files and not being a open book to the NSA once for all.
>>
File: 1473550131786.jpg (48KB, 500x375px) Image search: [Google]
1473550131786.jpg
48KB, 500x375px
is there something like scratch for visual "coding" on ios or android? target group are kids around 12.
>>
>>57249912
they are pretty different programming languages and intellij are jews
>>
>>57250036
Cordova.
>>
How the fuck do I make a gradle build file wtf
>>
>>57250034
>paying to post on an imageboard
Uh huh.
>>
>>57249912
not with eclipse you don't
>>
intellij does not give me the option to run my project?

huh?
>>
>>57249850
To be pedantic, consider the code
char arr[] = "hello";
char* pArr = arr;
sizeof(arr); //returns 6, because null terminator
sizeof(pArr); //returns 4 or 8, the byte size of a pointer, depending in 32 or 64 bit system
>>
>>57247361
even with brute force it shouldn't be extremely slow, maybe hours-days but not years
>>
>>57250026
Literally not even one tenth of the issue.
>>
>>57250191
rude
>>57250026
very good anon!
>>
File: kei.jpg (82KB, 881x960px) Image search: [Google]
kei.jpg
82KB, 881x960px
>>57250034
safari and ie don't support webrtc yet and many users, especially on mobile, won't want to use up their cap space. maybe you consider those things features. there were some privacy concerns a year ago that still linger

>>57250036
i don't recall how retarded 12-year-olds are but look at this
http://www.apple.com/swift/playgrounds/
>>
>>57250231
kawaii
>>
>>57249683
Thanks, looks like I got it to work.

If I searchd bigrams['the world'] it wouldn't return anything

but If I split part="the world".split(' ') and search bigrams[part[1],part[2]) it would return correct result

no idea why
>>
I want to make a music player in Python. It should function and look like ncmpcpp but I don't want to rely on mpd.
So, I came up with the following libraries to help me out making the application:
>curses - UI
>mutagen - metadata extraction
>playback - Python bindings for Gstreamer 1.0
I wonder, is t here another library I can use for audio playback? Something that relies on FFMPEG?
>>
File: Capture.png (31KB, 379x125px) Image search: [Google]
Capture.png
31KB, 379x125px
ha!
>>
>>57250437
Somebody call Apple
>>
>>57250034
this sounds like a cool idea

what happens when you post though? it would need to get transfered to ever peer. I hate the idea of missing out on dank memes because they're trapped in the net somewhere
>>
>>57250437
PEN PINEAPPLE APPLE PEN

>>57250499
It doesn't work because you literally have to pay to post. No one is gonna pay per post on an image board.
>b-but there are 4chan pass users...
... you might say. Well none of them would have bought the pass if it weren't for the millions of free users.
>>
>>57250523
>have to pay to post
says who? why is that a requirement
>>
sum' xs = foldl (\acc x -> acc + x) 0 xs 

>"This looks a little messy. Is there a better way of doing it?"
>"Nah, can't think ofany. This is probably how you do it."
>scroll down half a page
sum' = foldl (+) 0

This currying of functions takes a bit of getting used to, as a thought pattern.
>>
>>57250523
But any computer can be used as a bitcoin miner-- the client could build in a miner that could, overnight, net you enough credits to post for weeks. It would also control spam-- if it costs even tiny amounts of CPU cycles to post, it won't affect legit traffic much, but spammers will be all but priced out of the market.

We're talking prices on fractions of a cent to post-- that you pay for just by running a bitcoin miner overnight.
>>
>>57250593
it's pretty good
>>
>>57250593
what language is this?
>>
>>57250613
Will the bitcoin miner also pay for the electricity it uses every night?
>>
>>57250593
It would be cool if there was syntax like this: f _ a would desugar to
\x -> f x a
>>
>>57250644
Haskell. I've just begun learning it.
>>
>>57250651
Or, how you'd probably normally write it:
flip f a
>>
java question:

I have ProjectA and ProjectB

A is linked to B. how do I access assets like a picture in A from B.
probably somehow relativ to the classpath but I dont really know how.
>>
>>57250582
It's just how blockchains work. You have to pay, at the very least, a small fee per transaction you want to have stored on the blockchain.

>>57250613
You underestimate how heavily mined the bitcoin network is. Your home computer could mine for a year and not get a single cent in returns. You would have to join a mining pool, and even then you might only get a few posts per day. It would be such a hassle for next to no benefit over a conventional webserver. As is the case with all blockchain services.
>>
>>57250651
>>57250676
(`f` a)
I like the idea, but there is a problem with where the lambda should start

g (f _ a)

\x -> g (f x a)
g (\x -> f x a)
>>
>>57250789
The latter. If you want the former, you can write
(g . f)_ a
>>
I have a script.

#!/bin/bash
while (true)
do
read A
echo $A
done


Why pressing Enter key makes bash to repeat line, later giving error like "[abc: command not found"? Why can't it just switch to the next line?
How can I make script to not exit after ^C, but still having ^C printed?
How can I say Bash if we have line 'exit\n', then exit script?
>>
>>57250828
what if you've got loads of parameters
>>
File: disasm.png (75KB, 921x399px) Image search: [Google]
disasm.png
75KB, 921x399px
> What are you working on ?

I'm continuing writing disassembler/analyzer using RPN.
It's really close to producing "return argc" now.

I'm not too satisfied with how slowly the project is moving forward: my main work steals most of the time.
>>
>>57250738
Hmm... noted.

Still, using hashing in exchange for making posts could be a nice way to handle spam, and verify that someone isn't just exploiting the network. Maybe the hashing could be dedicated to folding@home or something besides bitcoin mining.

It wouldn't pay for the hosting or anything, but it would at least be a spam control that might be better than what we have now.
>>
>>57251087
And it wouldn't take much to control spam. I'm sure if you set it such that a little netbook could generate enough credits for you to make a post in five minutes, you'd set the bar high enough that spamming becomes infeasible.
>>
>>57250644
I'm pretty sure it's English
>>
how do we feel about ocaml
>>
Discord me up senpai.
>>
>>57251220
So-so. Go to F# instead: it has proper threading and no misery in a form of +. /. -.
>>
>>57251220
If you aren't using metaocaml, you're a plebian.
>>
elem' :: (Eq a) => a -> [a] -> Bool  
elem' y ys = foldl (\acc x -> if x == y then True else acc) False ys
If you implement elem like this, is foldl still going to traverse the entire list ys, even if it finds an early match? It'd have to, right? By definition of what foldl does. I don't see how it could detect an opportunity for lazy evaluation here.
>>
>>57251273
Fucking code tags

elem' :: (Eq a) => a -> [a] -> Bool  
elem' y ys = foldl (\acc x -> if x == y then True else acc) False ys

If you implement elem like this, is foldl still going to traverse the entire list ys, even if it finds an early match? It'd have to, right? By definition of what foldl does. I don't see how it could detect an opportunity for lazy evaluation here.
>>
>>57251287
Yes, it will. foldr, on the other hand, will be fine.
>>
>>57251344
Why? I don't see how starting from the other end of the list could be any different.
>>
How important is SCIP to learn, anyway?

I wouldn't say I'm a beginner at programming, but I certainly can't build a fully functioning kernal by myself.

I guess my question really is how far does SCIP really teach?
>>
>>57251414
foldr f b [] = b
foldr f b (a : as) = f a $ foldr f b as

foldl f a [] = a
foldl f a (b : bs) = foldl f (f a b) bs

If f doesn't evaluate its second argument, foldr stops.

By the way, you can express that a little better:
elem' y = foldl $ \acc x -> x == y || acc
>>
>>57251439
https://people.eecs.berkeley.edu/~bh/sicp.html
>>
Almost finished my MIPS assembly calculator. The UI loop, lexer, and variable lookup map work. The parser sort of works, in that it is closely tied to the evaluator and that is still very bork. Had a hard time getting the stack to unroll properly in the parser/evaluator on error, so I implemented a setjmp/longjmp and it's just messy. After that's done I need to improve error messages, currently there is only one generic error message.
>>
>>57246428
3000 LOC in my Machine Learning program and I realised that the basic datastructure is not practical. Time to go back to drawing board.

Everything went according to plan. But the plan was shit.
>>
File: Untitled.png (2KB, 130x67px) Image search: [Google]
Untitled.png
2KB, 130x67px
double mycosx(double cosx, double threshold)
{
double sum = 0.0;
int n = 0;
while (true){
double term = (pow(-1, n) / Fact(2 * n))*pow(cosx, (2 * n));
sum += term;
if (term < threshold) { break; }
n++;
}

return cossum;
}
__int64 Fact(int n)
{
__int64 result = 1;
while (n > 1) {
result *= n--;
}

return result;
}


Anyone know how to fix this code? I'm required to use the equation that is pic related and I can't do any other way. I can't seem to get the answers right when I use .5 or 2 for cos. Threshold is 10^(-3).
>>
>>57251459
Wait, sorry, that's not right.
elem y = foldl (\acc x -> x == y || acc) False
>>
>>57250738
>It's just how blockchains work. You have to pay, at the very least, a small fee per transaction you want to have stored on the blockchain.
This is completely wrong and I'm annoyed about how you shut down a cool idea with your ignorance.
A block chain only prove the computational work of a network without requiring any trust between peers.
>https://bitcoin.org/bitcoin.pdf

It could be easily implemented into an imageboard where the longest chain is the current state of a thread without any transaction involved.
>>
>>57251459
>>57251505
Oh, and the parameters to the function are wrong.
elem y = foldl (\x acc -> x == y || acc) False
>>
>>57251485
You again, you motherfucker. Didn't I give you the answer the last time?
>>
>>57251542

I think the thread got deleted before I saw it.
>>
>>57251485
>Fix my code
Nope pajeet.
>>
>>57251464
imreadytofuckingdienow.jpg
>>
>>57246428
>What are you working on ?

r/dailyprogrammer #289 Easy

A program that computes damages factor between types or [moves and pokemons] by fetching data from https://pokeapi.co/
>>
>>57251485
>(pow(-1, n) / Fact
Isn't the term
(pow(-1, n)) * (pow(x, 2*n) / factorial(2*n))?

Also you're checking if term < threshold, but shouldn't it be if n < threshold?
>>
File: 1372029416590.jpg (40KB, 316x311px) Image search: [Google]
1372029416590.jpg
40KB, 316x311px
>>57251556

I've been trying to fix this shit for like four days now. Pic related.
>>
>>57251459
>>57251505
>>57251532
Thanks.
>>
>>57251087
Let's move away from the blockchain approach then. Since we arent working with money, a few lost posts would be acceptable. I think we could find a model that only requires peers to use bandwidth.
>>
>>57251580
4 hours in Pajeet brain time is not even close to 1 second in my time.

Just think more.
>>
>>57251593
   ||
||
\/


>>57251516
>>
>>57244651
package main;

import java.util.ArrayList;
import java.util.List;

public class Main {

public static void main(String[] args) {
System.out.print("got a ");
Main m = new Main();
Object result = m.openChest();
}

public Object openChest() {
double x = Math.random() * 100;
if (x <= 60) {
System.out.println("nothing");
return null;
} else if (x >= 61 && x < 90) {
return new GoldBar();
} else {
List<Chest> list = new ArrayList<Chest>();
list.add(new Chest());
list.add(new Chest());
return list;
}
}

class Chest {
Chest() {
System.out.println("New chest!");
Main m = new Main();
Object result = m.openChest();
}
}

class GoldBar {
GoldBar() {
System.out.print("Golden bar");
}
}
}


more or less does the trick, open to improvement though coded in like 5 mins
>>
>>57251554
You responded to me. Giving me some bullshit excuse that the reason you suck so much at programming is that your teacher is forcing you to write it out exactly
>>
>>57251568

No.
>>
>>57251516
I know exactly how blockchains work buddy. Why don't you do some fucking research before you try to claim I am wrong?

https://en.bitcoin.it/wiki/Transaction_fees
https://litecoin.info/Transaction_fees
http://multidoge.org/help/v0.1/help_whatIsTheTransactionFee.html
http://ether.fund/tool/calculator
https://en.wikipedia.org/wiki/Peercoin#Transaction_fees
https://wiki.namecoin.info/index.php?title=FAQ#Who_gets_the_transaction_fee.3F
https://ripple.com/build/transaction-cost/

YOU HAVE TO PAY A TRANSACTION FEE.
>>
>>57251220
I love it, elegant af
>>
>>57251662
You don't. Transaction fees are only here as rewards for the miners. But they're not intrinsically needed.

>Do some research
... I wonder why some can't just use use their own neural network to compute such simple notions.
>>
>>57251643

Oh, well the professor does require that equation. I can't do it the other method. I feel like the problem is that n is only going from 0 to 1 instead of putting out n's that go from 0 to say 20. I try to loop it, but I don't even get an answer.
>>
>>57244651
Don't need to write a program for this.
You have 6/10 chance you get nothing, 3/10 chance you get a gold bar and 1/10 chance your starship gets overrun by tribbl... i mean chests.
>>
>>57251593
Also, even if using a block chain for distributing posts may be considered overkill, it's still the most efficient way to prevent spammers and shills flooding the network with corrupted content.
>>
>>57251643
didn't you tell him to use a library function? that's not really helpful in this case. it's good to figure out how things work
>>
>>57251662
you're mixing up the economics of bitcoin with the technology. there is absolutely nothing that requires software to eat money other than the computing power cost. in a distributed system the computing power is provided by the participants, who obviously require an incentive to participate. the transaction fee is just an incentive.

i imagine that for a distributed image board the incentive would be the right to post, i.e. you can't post if you're not providing power
>>
>>57251732
It's literally the same equation but optimized for C++ code. Translating irl math to programming code is going to end up with performance issues due to real life constraints.

>>57251823
https://archive.rebeccablacktech.com/g/thread/S57217788#p57220434
>>
>>57244651
took a stab with haskell
-- | Returns the number of gold bars we opened. 
open :: IO (Integer)
open = do
r <- randomRIO (1,10) :: IO Integer
if (r == 1)
then do
putStrLn "Opened TWO CHESTS!"
c1 <- open
c2 <- open
return (c1 + c2)
else if r <= 4
then do
putStrLn "Opened gold!"
return 1
else do
putStrLn "Opened nothing..."
return 0
>>
What's the point in Bjarne Stroustrup?

What purpose does it serve?
>>
File: bona.jpg (115KB, 1080x1349px) Image search: [Google]
bona.jpg
115KB, 1080x1349px
>>57251869
i remembered uncharitably; my mistake
some of your small changes i can quibble with but overall it's much better. calculating all those powers was insane
>>
>>57251485
Your term will be negative very very soon
And hence less than threshold
>>
just wrote my ugliest code ever
>find all classes with superclass x
>cache them in an array
>when a class extending superclass x is initialised first get the index of the cache
ugly as fuck but will be fast a fugg. there is just no other way without endless iterating.
>>
>>57251908
The point in Bjarne Stroustrup is to be opinionated and does not afraid of anything.
>>
>>57251941
lol that's a good catch too. very fixable
>>
>>57251908
The hero we need, but not the one we deserve.
>>
>>57251908
bjarne stroustrup is the opposite of
>>57251955
>>
How do I write code everyday?
>>
>>57252016
Every day you write code.
>>
>>57252016
code with people
>>
>>57252016
Have a project to work on.
>>
>>57251936
You should also know that I compiled your program and ran it without issues.

.5 gave .85... like normal
>>
>>57252044
oh i'm not the original poster
>>
>>57248494
package main;

public class Main {

public static void main(String[] args) {
Main m = new Main();
String firstString = "burn";
String secondString = "node";
if (!(firstString.length() == secondString.length())) {
throw new StringIndexOutOfBoundsException();
}
if (!(firstString.charAt(firstString.length() - 1) == secondString.charAt(0))) {
throw new StringIndexOutOfBoundsException();
}
m.createShit(firstString, secondString);
}

public void createShit(String a, String b) {
System.out.println(a);
for (int i = 1; i < a.length() - 1; i++) {
System.out.print(a.charAt(i));
for (int z = 1; z < a.length() - 1; z++) {
System.out.print(" ");
}
System.out.print(b.charAt(i));
System.out.println();
}
System.out.println(b);
}
}
>>
>>57252068
NEW THREAD
>>57252068
NEW THREAD
>>57252068
NEW THREAD
>>
>>57252044

Try 2.
>>
>>57251908
He is a disgusting bank cuck
>>
File: removedupes.png (50KB, 942x666px) Image search: [Google]
removedupes.png
50KB, 942x666px
Can someone help explain the line with dup=ptr2.next ?

I'm pretty sure it's trying to maintain the position in memory, but it's never used anywhere else in the function. Can someone explain whether this is unnecessary or what's going on to require a variable used once to hold a node but not used again?

The function's purpose is to remove dupes in a linkedlist, I know better alternatives to do this exist but that's not what i'm interested in.
>>
>>57252153
>System.gc()
presumably so it wont be garbage collected
>>
>>57251905

>>57252178
pls r8
>>
>>57252196
But why? That just means you're deferring the garbage collection till you find the next duplicate? What's even the point of manually calling the gc there?
>>
>>57252289
I have no clue, the code is trash.
>>
>>57252153
>>57252289
>>57252301
>/*This is tricky*/
>ptr2 = ptr2.next
Looks like it's written by a troll.
>>
>>57252340
I like how he slips the comment between the else and the {. Never seen that before.
>>
>>57252371
That's actually pretty nice, now that you mention it.
>>
>>57252442
no it's not nice and it's one of the reasons you should use bjarne style else not cluttered cuddled else
>>
>>57248894
c++
go
rust
>>
>>57252028
>>57252029
>>57252031
Thanks. I will try to find some people.

Did anyone find contributors to their projects on /g/?
>>
>>57248894
Most legit languages have compilers written in the language.
Thread posts: 314
Thread images: 23


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