[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: 311
Thread images: 48

File: hamster-escape.jpg (26KB, 400x402px) Image search: [Google]
hamster-escape.jpg
26KB, 400x402px
Hamsters are cute af edition

Old thread: >>52289791
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay


Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be refered to as designing
>>
>>52297205

good thread
>>
>>52297205
Fuck you
>>
>>52297205
thank you for doing your part in preventing trap proliferation
>>
i want to make a startup. who's in
>>
>>52297288
i'll make the logo
>>
>>52297304
no memes
>>
>>52297269
>>52297279
Good, hamster loving programmers
>>52297269
Shitty trap coder
>>
File: bzzt.jpg (287KB, 620x876px) Image search: [Google]
bzzt.jpg
287KB, 620x876px
>>52297288
I'll create the logo
>>52297279
What about anime?
>>
>>52297320
>an adblocker blocker isn't a meme
see >>52297196
>>
File: memes.png (767KB, 473x632px) Image search: [Google]
memes.png
767KB, 473x632px
>>52297320
I was thinking I'd make some concept art based off this
>>
>>52297369

ME GUSTA
>>
File: Hamsterhamham.png (128KB, 611x767px) Image search: [Google]
Hamsterhamham.png
128KB, 611x767px
>>52297325
Only if they're anime hamsters.
>>
>>52297347
have you made an app before
>>
File: ew.png (272KB, 470x624px) Image search: [Google]
ew.png
272KB, 470x624px
Is this a good way to preload visible images on 4chan, /dpt/.

http://pastebin.com/KzqgTpxN

I had to upload to pastebin, 4chan thought my post was spam.

I'm new to JavaScript so feel free to call me a retard for anything.
>>
File: lua.jpg (149KB, 914x897px) Image search: [Google]
lua.jpg
149KB, 914x897px
why is lua so comfy?
>>
>>52297288
L O G O
O L O G
G O L O
O G O L
>>
File: 1425622024474.jpg (71KB, 573x892px) Image search: [Google]
1425622024474.jpg
71KB, 573x892px
>>52297422
Why is lua so cute*
>>
>>52297415
i have a mobile game in production
>>
Guys I'm fucking confused between 2 codes.

index = 1
while index < 5:
print(index * 2, end="")
index += 1
[/code}

and

index = 2
result = "a"
while index < 4:
result *= 2
index += 1
print(result)


< [number] clearly means it's supposed to stay UNDER that number right?

On the first code the answer is "2468". Basically what it does is:

1 x 2
2 x 2
3 x 2
4 x 2

It never reaches 5.

How come in the second code it does? The answer is "aaaa".
It starts with index 2 makes "aa" of it. Then it jumps to index 3.
You can't multiply on index 3 again because then it would jump to 4, which is not supposed to happen.

Where am I fucking up?
>>
File: nagisa.jpg (40KB, 480x749px) Image search: [Google]
nagisa.jpg
40KB, 480x749px
>>52297403
Oh shit man as a kid I watched that show religiously

I don't even know what it was about anymore but damn it was good

>>52297435
Wow, lua is cute

>>52297288
What are you even trying to make anyway

>>52297451
>>52297475
Shit lol format pls, then I'll answer
>>
>>52297451
in the first one it's 1, 2, 3, 4, all less than 5

in the second one it's 2, 3, both less than 4

"a" is stringmultiplied by two to become "aa" and then once more to become "aaaa"
>>
>>52297475
Why the fuck am I fucking up the layout every time?
>>
What do you do when you can't program anymore.

My mind is shot I need something to do for an hour
>>
>>52297499
>[/code}
>>
O C A M L
C
A
M
L
>>
>>52297499
You're not being autistic enough
>>
>>52297501
also interested in suggestions

should i pick up competitive CS:GO or something to stimulate my mind and hand eye coordination?
>>
>>52297483
Tbh I just searched for anime hamster

>>52297416
That's a big hamster?

>>52297475
It's multiplication not addition. Goes "a" to "aa" to "aaaa", not " a" to "aa" to "aaa".
>>
>>52297422
lua is like the opposite of comfy
>>
>>52297445
same

>>52297483
what are YOU trying to make
>>
>>52297501
dress up like a woman and post irrelevantly in /dpt/
>>
>>52297416
window.addEventListener("scroll", preloadImages);


Is there not a better way than checking every time you scroll?
>>
File: trap programmer.png (1MB, 1702x2471px) Image search: [Google]
trap programmer.png
1MB, 1702x2471px
Daily reminder that if you don't program while dressed like a schoolgirl, you don't belong on /dpt/.

You can redeem yourself by buying a schoolgirl outfit and a copy of The C Programming Language (2nd Edition) by Kernighan and Ritchie, preferably in the same amazon cart.
>>
If I know c++ fairly well, are there any advantages to picking up python to use in my data structures class next semester, or should I just continue in c++?
>>
>>52297543
>That's a big hamster?
for you
>>
>>52297510
oh lol.

>>52297490
You see, the first one never multiplies 4 in the first place. It jumps from 3 to 4 and that's where it ends.
Number 5 is never getting reached.
The second one does multiply number 3, that would move the next one towards number 4 which is >not< supposed to happen.

Maybe I need some sleep man, my head is all fucked up.
>>
>>52297570
don't learn python it's one of the worst languages

stick to C++ or learn java/C#/D/nim if you want something more high level
>>
>>52297475
>codes
>>
>>52297260
STFU
>>
>>52297529
CS is great if you want russians screaming "CYKA BLYAT XAXAXAXAXA"

>>52297569
Would rather dress up in pic related and read about meme snake
>>
File: 1452112132284.jpg (36KB, 600x337px) Image search: [Google]
1452112132284.jpg
36KB, 600x337px
Why do people act surprised and make fun of me after they find out I write all my software in C?
>>
>>52297584
3 is less than 4 so it's fine
index is 3, the result gets multiplied, index becomes 4, the loop stops
>>
>>52297649
because C is only relevant in very limited contexts such as embedded systems, operating systems, drivers and that's about it
>>
File: brains.png (141KB, 460x275px) Image search: [Google]
brains.png
141KB, 460x275px
>>52297550
I just finished a project of mine, so I;m looking to pick up a new one. If I can't find one soon, I'll go back to solving project euler with haskell/uva online judge with C++

>>52297569
Thanks onii-chan
>>
>>52297603
Do you know any good java textbooks I can purchase from amazon for someone who already knows knows quite a bit of c++ already? I don't need beginner shit mostly just reference level stuff and just how to get started in general with java syntax.
>>
>>52297653
Then how come the first one's answer is not "246810" ?

If it's at index 4, it can multiply one more time right? Like the second one.
>>
>>52297728
i don't know about books but you can check out
https://docs.oracle.com/javase/tutorial/

and also the docs. java has great documentation.
>>
>>52297558
But I'm already dressed like that
>>
>>52297728
http://ddili.org/ders/d.en/index.html
>>
>>52297746
index = 1
if index < 5: # index is 1 which is less than 5
print(2, end="")
index += 1
if index < 5: # index is 2 which is less than 5
print(4, end="")
index += 1
if index < 5: # index is 3 which is less than 5
print(6, end="")
index += 1
if index < 5: # index is 4 which is less than 5
print(8, end="")
index += 1
if index < 5: # index is 5 which is NOT less than 5
print(10, end="")
index += 1
>>
>>52297746
lolwat? At the end of the fourth iteration, index is incremented to 5, so the loop terminates because 5 is not less than 5.
>>
File: 5kg.png (103KB, 836x385px) Image search: [Google]
5kg.png
103KB, 836x385px
>>52297746
Because you wrote while(x < 5)

That means, when the loop ends and x==4, it does x++. So now x==5. It now does the comparison one last time, sees that x is no longer < 5, and finishes the loop without executing for x==5.

In other words, the loop body will only execute when the condition is true.

>>52297760
pics or it didn't happen

Continuing with great quote dump
>>
File: flat,800x800,075,f.jpg (61KB, 800x507px) Image search: [Google]
flat,800x800,075,f.jpg
61KB, 800x507px
So apparently pic related is a hamster.
>>
File: YEAAAAAH COLA.jpg (141KB, 1280x720px) Image search: [Google]
YEAAAAAH COLA.jpg
141KB, 1280x720px
Have you had your afternoon cola today?
>>
>>52297844
pepsi-cola yes
>>
>>52297800
>>52297811
>>52297812
Pardon me for being a fucking idiot, I get it now. Somehow I thought multiplying 3 would add +1 and end up at 4 which was not allowed for some reason.
I need some fucking sleep. Thanks fellas.
>>
>>52297844
I don't want to increase the risk of getting cancer, thanks.
>>
>>52297844
No, but I've had this:
>picture of gray circle that I didn't save
>>
File: 1452211906834.jpg (2KB, 118x119px) Image search: [Google]
1452211906834.jpg
2KB, 118x119px
>>52297844
>>
File: photo_2016-01-07_16-15-13.jpg (34KB, 804x649px) Image search: [Google]
photo_2016-01-07_16-15-13.jpg
34KB, 804x649px
>>52297205

I don't program at all, but here's my hamster, Cybele
>>
>>52297844
>drinking the sugary jew at anytime of the day
>>
File: uui9.png (481KB, 626x988px) Image search: [Google]
uui9.png
481KB, 626x988px
dom(".thread .fileThumb").forEach(function(elem, index, array) {
elem.addEventListener("click", function(){
let imageURL = elem.getAttribute("href");
let thumbnailURL = elem.firstChild.getAttribute("src");

if(imageURL.substring(imageURL.length - 4) !== "webm") {
elem.setAttribute("href", thumbnailURL);
elem.firstChild.setAttribute("src", imageURL);
elem.firstChild.removeAttribute("style");
event.preventDefault();
}
});
});


Is this a good way to enlarge and shrink images on 4chan when you click them senpai?
>>
I'm bored.
Hows fluid simulation like?
C++
>>
lua or d?
>>
File: popcorn.jpg (37KB, 732x720px) Image search: [Google]
popcorn.jpg
37KB, 732x720px
>>52297958
You get 1/2 for the hamster. You should learn to program. Here's mine.
>>
File: Laughing-Frog-Man.jpg (25KB, 400x386px) Image search: [Google]
Laughing-Frog-Man.jpg
25KB, 400x386px
>>52298044
>functions inside functions
>>
>>52298115
D
>>
>>52297416
>>52298044
Just use the inline extension and stop being autistic by making your own.
>>
>>52298127
>I feel superior because I don't understand first-class functions! Hahaha!
>>
>>52298127

Embrace nested functions. :)
>>
File: 1385792865025.png (304KB, 722x768px) Image search: [Google]
1385792865025.png
304KB, 722x768px
Is it easy to make your own chrome extension, /g/?
>>
>>52298298
extremely I can help if you like :)
>>
>>52298115
d is meme. Just use luaJIT with FFI. You can also throw in Terra code if you feel like it
>>
>>52297422
Because it's so simple.
>>
>>52297831
False.
>>
File: uhg.png (10KB, 521x180px) Image search: [Google]
uhg.png
10KB, 521x180px
>>52298197
What about this for a friendlier post time?

let unixTime = Math.floor(Date.now() / 1000);

dom(".thread .desktop .dateTime").forEach(function(elem, index, array) {
let secondsAgo = unixTime - elem.getAttribute("data-utc");
let minutesAgo = Math.floor(secondsAgo / 60);
let hoursAgo = Math.floor(minutesAgo / 60);
let daysAgo = Math.floor(hoursAgo / 24);;
let postTimeHTML = "";

if(secondsAgo < 60) {
if(secondsAgo === 1) {
postTimeHTML = "1 second ago";
} else {
postTimeHTML = secondsAgo + " seconds ago";
}
} else if (minutesAgo < 60) {
if(minutesAgo === 1) {
postTimeHTML = "1 minute ago";
} else {
postTimeHTML = minutesAgo + " minutes ago";
}
} else if (hoursAgo < 24) {
if(hoursAgo === 1) {
postTimeHTML = "1 hour ago";
} else {
postTimeHTML = hoursAgo + " hours ago";
}
} else {
if(daysAgo === 1) {
postTimeHTML = "1 day ago";
} else {
postTimeHTML = daysAgo + " days ago";
}
}
elem.setAttribute("title", elem.textContent)
elem.innerHTML = postTimeHTML;
});


Is that ok?
>>
>>52298044
>elem.firstChild.removeAttribute("style");

It doesn't seems to "restore" the style tag when you click a picture again for making it smaller.
>>
So I know C, Lua, Python, and Go pretty well. I've been meaning to learn C++ and a functional language. So which should I do? If functional which should I learn? A lisp or something more pure functional? I was looking at Erlang or Haskell.

I really only have time to learn one. I have work, soon school, and I am reading two other books on programming (TAOCP and Dragon Book).
>>
>>52297260
thanks mr.fagtel
>>
>>52297369
I would actually ironically wear that Memez hat. It is pretty fuckin dank desu
>>
>>52298525
Please use ternary operators more, your code is absolutely disgusting.
>>
>>52298531
It doesn't need to, those style tags are only there to tell the browser what the width and height of the images will be before they load.

Once the page loads that style attribute is useless. Try it for yourself, inspect element and remove the style attribute. Nothing will happen.
>>
>>52298619
>those style tags
*attributes
>>
>>52298550
If you already know C and Python, you would probably gain the most out of learning Haskell, but I'd warn you that it's not the most practical option if you're job hunting for this coming summer.

>>52298599
Yeah, it really needs it. Its also got some serious need of code reuse
>>
Jesus Christ, this thread is more shitposting than usual.
This is what happens when you start a thread early.
>>
>>52298550
Learning C++ takes forever if you want to learn it well enough to actually use. If you learn a (pure) functional language first, it will help if you get into template metaprogramming.

For functional, pick one of the ML family (ML, Haskell, Hope, Miranda, etc).

Lisp (incl. Scheme or Racket) is worth learning in its own right, but not as a functional language. Nowadays, "functional" generally implies "declarative", and Lisp isn't really that.
>>
>>52298525
Anon, take a look at this
function ago(t) {
var units = 'second minute hour day'.split(' ');
var divs = [60,60,24,Infinity];
var i=0;
while(t>divs[i]) {
t /= divs[i];
i++;
}
t = Math.floor(t);
return t+' '+units[i]+(t===1?'':'s')+' ago';
}


or more concisely,

function ago(t) {
var units = 'second minute hour day'.split(' ');
var divs = [60,60,24,Infinity];
for(var i=0;t>divs[i]; i++) t /= divs[i];
t |= 0;
return `${t} ${units[i]+(t===1?'':'s')} ago`;
}
>>
rate my skyline printer
http://paste.debian.net/362260/
>>
>>52298782
Thanks, anon. It was annoying me that I was calling Math.floor more than once every iteration.
>>
>>52298856
>http://paste.debian.net/362260/
That's cool, but... isn't that a lot of code for a skyline printer? Especially for Haskell? Idk, maybe I'm missing something
>>
>>52298947
i'm new to this haskell thing, maybe someone can do it better?
>>
Is lisp and its dialects really the most powerful language there is?
>>
>>52298705
I heard lisp is good for AI, is haskell similar in this aspect?
>>
>>52299090
The most powerful language is the language of love
>>
>>52298705
>>52299125
Should i learn common lisp, emacs lisp, or scheme? Does it matter? Can i easily use another dialect if i learn one?
>>
>>52299043
Well that's no problem. I think it could be made smaller though. I'll mess around and see what happens.
>>
After a week of brainstorming, still hung up with respect to an effective bottom-up strategy to natural language understanding for my chatbot, starting from an empty knowledge base and while shying away from explicit cues from its native intermediate language for conveying sentence structures, grammar, and semantics.

This is more of a thought experiment than anything though, since given even the bare minimum with respect to key terms/concepts (true, false, maybe, self, other, is-a, etc.) it's theoretically possible to deduce the meaning of statements, but this isn't exactly possible with a perfectly clean slate except with a hell of a lot of back-and-forth discourse with the system as it inquires as to the attributes of words and phrases.

This is a significant departure from the project's "comfort zone" of conversational exchanges in its intermediate language, and as a consequence, there do not appear to be any easy answers.

/rant
>>
>>52299125
I'd compare Haskell to a type safe lisp.
>>
>>52298704
>this thread is more shitposting than usual.
no it's not. you're being overdramatic
>>
>>52299421
Not at all, Lisp is homoiconic (which is why it's cited so much in AI, as it can "rewrite itself") and Haskell isn't even close
>>
>>52299315
On the bright side, hammered out a quick and dirty algorithm today for assessing the similarity of sequences of words.

Which doesn't really yield any semantic insight, but is a useful addition to a process that identifies the conceptual similarity of sentences given the context I'm currently trying to manually facilitate the deduction of.
>>
>>52298044
It's probably a good idea to check the type of click with "event.which" so you can still open images in a new tab when you middle click.

dom(".thread .fileThumb").forEach(function(elem, index, array) {
elem.addEventListener("click", function(){
if(event.which === 1) { //if left click
let imageURL = elem.getAttribute("href");
let thumbnailURL = elem.firstChild.getAttribute("src");

if(imageURL.substring(imageURL.length - 4) !== "webm") {
elem.setAttribute("href", thumbnailURL);
elem.firstChild.setAttribute("src", imageURL);
elem.firstChild.removeAttribute("style");
event.preventDefault();
}
}
});
});
>>
File: 1410860209595.jpg (317KB, 700x898px) Image search: [Google]
1410860209595.jpg
317KB, 700x898px
making a connector to make SAP supply chain management work with oracle fusion sales and marketing module
>>
What type of projects would look good in my github portfolio (for getting a job)?

I just want to code something but don't know what.
>>
>>52299125
Neither is good for AI. In late February, ocaml will become capable of AI. Right now, lua, python, java or C++ are the only legitimate options.
>>
>>52297727
How about a logo?
>>
>>52299823
prolog is the superior choice for AI.
>>
File: relate.jpg (107KB, 1600x557px) Image search: [Google]
relate.jpg
107KB, 1600x557px
>>52299828
TOoooOOOo LAAAaaAATE

I'm already working on a Haskell skyline printer because of >>52299043 >>52299156
>>
>>52299785
android tetris
hadoop cluster that does simple classification on some dataset from https://archive.ics.uci.edu/ml/datasets.html
then upload it to cloud
chat app with websocket
>>
>>52299898
hrhr what language are you using?
>>
>>52299823
why is java preferred over c# for huge-scale AI/big data shit?
>>
File: torvalds.jpg (204KB, 575x467px) Image search: [Google]
torvalds.jpg
204KB, 575x467px
>>52299954
Haskell - I'm almost done, I'll post code soon

Have some more inspirational quotes
>>
>>52299628
Scrap that, event.which is deprecated:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which

Use "event.button === 0" instead, and you can reduce event listeners by shuffling the code around a bit.

dom(".thread .fileThumb").forEach(function(elem, index, array) {
let imageURL = elem.getAttribute("href");
let thumbnailURL = elem.firstChild.getAttribute("src");

elem.firstChild.removeAttribute("style");

if(imageURL.substring(imageURL.length - 4) !== "webm") {
elem.addEventListener("click", function(){
if(event.button === 0) {
elem.setAttribute("href", thumbnailURL);
elem.firstChild.setAttribute("src", imageURL);
event.preventDefault();
}
});
}
});
>>
File: fffff.jpg (73KB, 700x374px) Image search: [Google]
fffff.jpg
73KB, 700x374px
>tfw it sounds like there's a big ass spider in your room
>>
>>52299964
> why is java preferred over c# for huge-scale AI/big data shit?
Distributed computing is one of Java's strong points. That's pretty much what "enterprise" means: being able to split jobs over as many servers as you need (without having to manually implement IPC and housekeeping).
>>
File: watdo.jpg (75KB, 2076x80px) Image search: [Google]
watdo.jpg
75KB, 2076x80px
Any alternative to .applicationFrame since it's deprecated? Xcode says I should use .bounds but I need to get the exact screen size being used by the app, .bounds just gives me the full screen value, wat do?

Am I the only iOS developer here?
>>
>>52299883
I laughed.
>>
>>52299964
Because the tools are there. That's literally the only reason. Hadoop, weka, etc.
>>
>>>52297205
>>>52297260

>>52297269



test
>>
>>52299043
>>52299954
I finished, but I think mine draws lines on the inside instead of the outside or something. It's probably a trivial change in the tocol method to make it like yours. It's not my best work, but I'm not amazing at Haskell either.

http://hastebin.com/raw/jinopecehi

*Main> :load skyline
[1 of 1] Compiling Main ( skyline.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
###
# #
# #
# #
# #
###### # # ######
# # # # # #
### # # # # #
# # # # # #
# # # # # #
# # # # # #
# # #### # # # #
# # # # # # # #
# # # # # # # #
# # # # # # # #
# # # ##### ### #
# # # #
# # # #
# #___# #


>>52300129
I kek'd

>>52300295
That's neat

>>52299437
Nobody uses the homoiconicity of Lisp for anything important in AI these days.
>>
File: evolution.jpg (49KB, 460x276px) Image search: [Google]
evolution.jpg
49KB, 460x276px
>>52300447
Forgot an amazing inspirational quote
>>
File: 1439523429849.gif (133KB, 311x366px) Image search: [Google]
1439523429849.gif
133KB, 311x366px
>>52300447
>import Data.Maybe
https://www.youtube.com/watch?v=fWNaR-rxAic
>>
>>52299437
If you do want homoiconic, you use the free monad. You are correct that the Haskell language itself is not homoiconic, but it can absolutely do anything lisp can.
>>
>>52300447
>http://hastebin.com/raw/jinopecehi

since the first building is '(1,5,11)' -> (x1, height, x2) you should consider, that the first heightchange is at 1, so '_' should be the leftmost visible thing in your render
>>
File: 42315.jpg (39KB, 300x309px) Image search: [Google]
42315.jpg
39KB, 300x309px
>tfw 3 straight semesters with the same shit teacher

God I just want to die
>>
>>52300524
>not being in an honors program that lets you pick your classes earlier than everyone else so that you can make the perfect schedule
I've had Friday off for two semesters because of this, and goddamn is it a blessing.
>>
File: ppp.jpg (90KB, 1280x720px) Image search: [Google]
ppp.jpg
90KB, 1280x720px
>>52300295
r8 my show replies code, /dpt/. it probably needs cleaning up a bit and some variable names changing, but it works. :^)

//Appends replies to posts
dom(".postMessage .quotelink").forEach(function(elem, index, array) {
let postNum = elem.parentNode;
let quoteNum = elem.getAttribute("href").substring(1);

//sometimes green text and code tags mess up the html position of quote links smdh
while(postNum.getAttribute("id") === null) {
postNum = postNum.parentNode;

}

postNum = postNum.getAttribute("id").substring(1);

if(quoteNum.indexOf('/') === -1){
let backlink = dom('#' + quoteNum + ' div.backlink');
let backlinkHTML = "<a href='#p" + postNum + "'>&gt;&gt;" + postNum + "</a>"

if(backlink.length === 0) {
dom('#' + quoteNum)[0].insertAdjacentHTML('beforeend', "<div class='backlink'>" + backlinkHTML + "</div>");
} else {
backlink[0].insertAdjacentHTML('beforeend', backlinkHTML);
}
}
});


>>52300010
thanks anon.
>>
File: quantum.jpg (140KB, 814x545px) Image search: [Google]
quantum.jpg
140KB, 814x545px
>>52300511
I made mine autotrim to fit the building data (which you're right, isn't what the original did).

If you want it to start at the origin, replace line 13 with

bounds bs = (-1, maximum rs, maximum hs)


Running out of inspirational quotes here...
>>
File: religion.jpg (102KB, 1280x720px) Image search: [Google]
religion.jpg
102KB, 1280x720px
>>52300559
I'm in the honors college in mine but our CS program always has shitty schedule options for the mandatory CS classes... ;_;

>>52300524
What is he teaching?

Alright, that's it, I'm out of inspirational quotes, this one isn't the greatest
>>
>>52300563
>>52300563
>>52300563
>>52300563
Does it account for when a user replies more than once?
>>
File: hhj.png (13KB, 843x219px) Image search: [Google]
hhj.png
13KB, 843x219px
>>52300625
No.

REEEEEEEEEEEEEEEEEE

I'll have to fix this.
>>
So in bash how can I make it so instead of 53B81CA36DCBB3A6DE0829489F4A25DF being my output I get
53B81CA3
6DCBB3A6
DE082948
9F4A25DF
I was using
 sed "s/./&\n/$char" 

but that's outputting
53B81CA3
6DCBB3A6DE0829489F4A25DF
>>
By the way, does the Haskell standard library have a method for the "ltrips" function I made?
ltrips :: [a] -> [(a,a,a)]
ltrips (a:b:c:ds) = (a,b,c) : ltrips (b:c:ds)
ltrips _ = []


It turns a list into a list of shifting triplets.

*Main> ltrips [1,2,3,4,5]
[(1,2,3),(2,3,4),(3,4,5)]
*Main> ltrips "topkek"
[('t','o','p'),('o','p','k'),('p','k','e'),('k','e','k')]
>>
>>52300801
unfortunately no, i also had to make one, but that's simple stuff.

F# has seq.windowed...
>>
>>52300801
So, I've done research and it seems like there isn't. The function's only 2 lines anyway, so it doesn't really matter, I guess.

>>52300940
Hm, yeah.
>>
>>52300940
300 microsoft points have been added to your account
>>
>>52300801
ltrips = zip3 <*> tail <*> tail . tail
>>
>>52300993
>Haskell is not an esoteric language
>>
File: 1445731234754.jpg (61KB, 391x340px) Image search: [Google]
1445731234754.jpg
61KB, 391x340px
>>52301010
Writing point free definitions is a fun puzzle.
>>
Why is F# so based?
>>
>>52300993
How exactly does the <*> work in Haskell? I get the idea of what's happening in that but I don't formally understand what <*> is doing. Is there a descriptive link you could point me to?
>>
>>52301082
<*> for functions is the same as the S combinator. You can think of it as the fundamental way to "duplicate" a variable.
f <*> g = \x -> f x $ g x

It just so happens that, because it is left-associative, it "works" for multiple arguments:
f <*> g <*> h = \x -> f x $ g x $ h x

It's really useful for point free programming because of this.
>>
>>52301139
Does it return a tuple?
>>
>>52300729
$ echo "53B81CA36DCBB3A6DE0829489F4A25DF" | fold -w 8
53B81CA3
6DCBB3A6
DE082948
9F4A25DF

lol
>>
>>52301211
No, the part that makes the tuple is zip3:
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

Here's the "pointed" form of ltrips, if it helps:
ltrips xs = zip3 xs (tail xs) (tail $ tail xs)
>>
>>52301139
Wow, that's amazing. Truly an awesome tool. Thanks, that was a clear explanation.

I think as I go along I'll find more places to use it.
>>
>>52300729
$ echo "53B81CA36DCBB3A6DE0829489F4A25DF" | gsed -r 's/(.{8})/\1\n/g'
53B81CA3
6DCBB3A6
DE082948
9F4A25DF

lol
>>
Can someone tell me why this is giving me wrong results?
The operators have the same precedence and associativity as C operators and I'm pretty sure the algorithm is correct.
There's no right associativity check because i only have + - * / operators and all of them are left associated, if i read http://en.cppreference.com/w/c/language/operator_precedence correctly.
static struct token *shunting_yard(struct token *in)
{
struct token *op_stack = 0;
struct token *out = 0;

while (in){
struct token *t = clone_stream(&in);

if (t->type == NUM)
push(&out, t);

if (t->type == OP){
while (op_stack && (t->asoc == LEFT_ASOC && t->prec <= op_stack->prec))
push(&out, pop(&op_stack));
push(&op_stack, t);
}
}

while (op_stack)
push(&out, pop(&op_stack));

return tail(out);
}

Input: 1+2*3
Lexed input: 1 + 2 * 3
RPN: 1 2 + 3 *
>>
>>52301229
I mean when you call it does it return a tuple
it invokes multiple functions with the same argument, what does it do with returns
>>
>>52301420
(<*>) :: (a -> b -> c) -> (a -> b) -> a -> c
f <*> g = \x -> f x (g x)

Does that make it more clear? It applies x to g, and then applies x and the result of that to f, which produces a single value.
>>
>>52301464
The second one really helps
>>
I am trying to learn OpenGL and I'm starting with glut because reasons.
Can someone explain why the square just violently vibrates back and forth rather than turning around when it hits the edge?
Is my logic flawed somewhere?
#include <stdio.h>
#include <GL/gl.h>
#include <GL/freeglut.h>

//Square
GLfloat x1 = 0.0;
GLfloat y1 = 0.0;
GLfloat rsize = 25.0;

//step size in pixels
GLfloat xstep = 1.0;
GLfloat ystep = 1.0;

GLfloat window_width;
GLfloat window_height;

void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.,0.0,0.0);
glRectf(x1,y1,x1+rsize,y1+rsize);
glutSwapBuffers();
}

void TimerFunction(int value)
{
/*
This is where the program determines if the square has reached the edge of the
window and reverses the direction. But for some reason it just causes the square
to violently vibrate back and forth. Why?
*/
if(x1 > window_width-rsize||x1<-window_width)
xstep = -xstep;
if(y1 > window_height-rsize||y1<-window_height)
ystep = -ystep;

x1 += xstep;
y1 += ystep;

glutPostRedisplay();
glutTimerFunc(33,TimerFunction,1);
}

void ChangeSize(GLsizei w, GLsizei h)
{
if(h==0)
h = 1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat aspectratio = (GLfloat)w / (GLfloat)h;
if(w<=h)
glOrtho(-100.0,100.0,-100.0/aspectratio,100.0/aspectratio,1.0,-1.0);
else
glOrtho(-100.0*aspectratio,100.0*aspectratio,-100.0,100.0,1.0,-1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void SetupRC()
{
glClearColor(0,0,1,1);
}

int main()
{
int x = 1;
char *c;
*c = 'a';
glutInit(&x, &c);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(800,600);
glutCreateWindow("Bounce");
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glutTimerFunc(33,TimerFunction,1);
SetupRC();
glutMainLoop();
return 0;
}
>>
>>52301220
>>52301315
you sexy fucker
>>
Am I right for thinking that indents are completely ignored by every compiler? The function of the brackets means that indents don't have to do anything, right? So they are basically like comments in runtime?
>>
>>52301505

move the box back inside the screen after you find it's out of bounds
>>
>>52301550
depends on the language
>>
>>52301550
Yes, compilers generally completely ignore whitespace.
The only time it's used is in the lexer to group characters into words, but every stage after that they're non existent.

Except for Python of course, but Python isn't a real language anyway.
>>
>>52301581
ok good

and yeah, I do remember that about python sortof
that was the point where I switched to jscript, because typing out 4 spaces to make the code slightly readable just isn't very appealing
>>
>>52301642
>typing out 4 spaces
>What is tab
>>
>>52301550
what is haskell
what is python
what is coffeescript
>>
>>52301657
it doesn't accept tabs

did you even read the posts? lmao
>>
>>52301668
͏>m e m e l a n g s
>>
>>52301668
Haskell lets you escape significant whitespace with braces and semicolons, at least
>>
>>52301677
>it doesn't accept tabs

You can use any tab/space indentation you want in Python, but convention is to use 4 spaces, because arbitrary reasons. A tab is read by the interpreter as 4 spaces, so you could even combine them, but I think Python 3 gives a warning if you have inconsistent indentation these days.

Dosn't make the language any better though
>>
>>52301551
I don't think that's the problem.
Some how these two lines of code are constantly being executed
if(x1 > window_width-rsize||x1<-window_width) xstep = -xstep;
if(y1 > window_height-rsize||y1<-window_height) ystep = -ystep;


i'm not sure how though...
>>
>>52301721
oh, I just remember it breaking when I used tabs
you are probably right though
>>
In Java if I do

if(function)


Does it run the function and change the state of my entire program or does it just run the function for the sake of the if, leaving the program unchanged?
>>
>>52301737
move
the
box
back
inside
the
screen
>>
>>52301752
if the function changes global shit, then yes.

it runs the function as normal
>>
>>52301752
If you do
if (function() {
//etc.
}

It will execute the function, yes. There is no distinction between what you are asking. Running a function will always modify your program IF YOU WRITE IT TO. A simple function that changes no external variables, and simply returns a bool or equivalent though, will obviously not change anything.
>>
>>52301792
>>52301796
Thx
>>
>>52301761
I
doubt
that
is
the
problem.

printing what window_width and window_height are gives: width = 20319152 height = 0
They should be 800 and 600.
>>
Are you a 10X developer yet?
>>
>>52301737
>>52301761
>>52301820

>box is outside the screen
>flip it's speed (now heading towards screen)
(next update)
>box is STILL outside the screen
>flip it's speed AGAIN (now heading away from screen)
(next update)
>box is STILL outside the screen
>flip it's speed AGAIN (now heading towards sceen)

ad infinitum

>box is outside the screen
>flip it's speed (now heading towards screen)
>put it back inside the screen
(next update)
>box is not outside the screen
>happy fucking days

alternatively do each check separately and use abs
>>
>>52301827
No, but I recently worked with some 0.10X devs. It's way easier to spot the shitty programmers than the god ones.
>>
File: Capture.png (16KB, 388x834px) Image search: [Google]
Capture.png
16KB, 388x834px
>>52301752
if I am not misunderstanding, yes it does run the function
>>
>>52301848
of course it runs the function ffs.
>>
File: line.png (132KB, 942x739px) Image search: [Google]
line.png
132KB, 942x739px
>>52301845
Do you think people like that are actually just biologically inferior?

It has to be true at least some of the time. I tutored this dude who was actually retarded, and he was aware of it, which was kind of sad. It was staggering, how slowly he took on new concepts I was teaching him. I'd never seen anything like it.
>>
>>52301905
Worst are the bullshitters, who apply to programming jobs without a clue what they are doing, with the idea that they will pick it up as they go or something.

Spoiler: they don't pick up anything, and then they get fired.

Recently had a guy who was trying to work on some C# application, didn't understand the first thing about OO, or what a class even reall "is". He just wrote it all in the main method, with like 3 other functions. And he was being paid full time.
>>
>>52301963
is this in the US
>>
>>52301827
You dont become a 10X developer. You are or aren't. Personally I'm not focused enought to sit and code 500 working lines an hour. Might do 100 working lines an hour if I really tried, but I'd crash after 2 hours or so.

What's the most amount of lines you've written in one day /g/?
>>
>>52301905
holy shit I really fucking like that formatting style with the ;{}

am I a bad person?
>>
>>52302050
Yes. How the fuck do you think that's more readable?
>>
>>52302062
i said I liked it not that it was more readable

it could be more readable though, { } and ; really get in the fucking way

you can just use explicit { and ; } when it's important
>>
Haskell needs to git gud

https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ghc&lang2=rust

>Dat performance boost
>>
>>52299823
>In late February, ocaml will become capable of AI.
Why then? What does it get then that it's lacking right now for AI?
>>
>>52302103
>comparing haskell to rust
what are you doing
>>
>>52301974
No, not in America.
>>
>>52301842
the box never touches the edge of the window
the box starts in the center of the screen and flips back and forth in the center of the screen.
it thinks that it's outside the screen

I've fixed the problem. The box flipped around because the window width and height were not set when declared and defaulted to 0.
>>
>>52302083
Personally I find } important because it tells me when some chunk (and thus scope) are ended.
>>
>>52302048
In a 24-hour hackathon I wrote a primitive 1300 ish line online multiplayer version of Solarmax.

>>52302050
I lost it when I saw that the first time

>>52302103
>comparing haskell to rust
>>
what's a 10X developer?

>>52302048
lines of code is a terrible metric
>>
>>52302211
>lines of code is a terrible metric
Quality of code is subjective. What other measurement is there?
>>
>>52301963
>>52301974

He would also make every class member as public, no exceptions, but he would also write a public getter and setter, manually, for each member variable.
public int _someInt;

public int someInt()
{
return _someInt;
}

public int setSomeInt(int someInt)
{
_someInt = someInt;
}


This can all be written, neater, as
public int someInt { get; set; }
>>
>>52302224
idk features implemented?
>>
>>52302224
not him but I'm not entirely sure you need a metric to compare your code to others

I mean really
we all spend thousands of hours on these projects, there's really no need to feel better or worse than everyone else
>>
>>52297205
I had a hamster once

and one day it died :)
>>
>>52302238
Alright sure. But of course you couldn't tell unless you were specifically tested. No one reimplements a large amount of code to cover a whole feature.

>>52302260
For businesses looking to hire, a more productive coder means better cost efficiency. Even if they pay him double, a cool $200,000 a year or so; if he is 10x more productive it's a net positive for them.

Especially in new markets subject to first mover advantage.
>>
>>52302144
>>52302182

And why the fuck shouldn't I compare the two?
>>
File: Sea Horse4.jpg (334KB, 1024x768px) Image search: [Google]
Sea Horse4.jpg
334KB, 1024x768px
Why do people act surprised and make fun of me after they find out I write all my software in PL/I?
>>
>>52302309
One is a high-level functional language, with all that implies; and the other a low-level procedural language. You must be drunk m8.
>>
>>52302307
Oh, I wasn't talking about coding for other people but I see your point
>>
>>52302260
I'm not a guy lol

>>52302328
>low-level

that doesn't mean what you think it does
>>
>>52302048
that's a horrible way to measure productivity

how many lines you should write depends entirely depends on what you're doing and what the requirements are

if you're designing an algorithm it could be 0 lines of code

if you're refactoring existing code it could be -1000 lines of code
>>
>>52302344
>-1000 lines of code
Wow, so bad you can't even code a single line, you have to remove them...
>>
Is there a single language that use 0o for octal literals?
>>
>>52302344
>>52302369

the most achieved with the least code in the shortest time and the fewest resources
>>
>>52302371
in C++ anything beginning with a 0 is an octal literal

even 0
>>
Oh boy, the way OpenGL handles data, I can already tell it's going to be a horrible pain in the ass to deal with 3D model formats in the future.
>>
>>52302369
kill yourself
>>
>>52302342
I hate this retarded elitist attitude where anything that isn't assembly is considered high level. If you take that stance the label doesn't mean anything anymore and you may as well just call it non-assembly.

Rust and C are used in embedded systems for a reason. It's because they're low level languages.
>>
File: mount stupid.jpg (23KB, 600x338px) Image search: [Google]
mount stupid.jpg
23KB, 600x338px
>>52302399
how so?
>>
>>52302383
> most achieved
How is that measured?
> least code
Not always the best...
> fewest resources
What does that even mean? What resources does a programmer need besides a computer and an internet connection?
>>
>>52302416
You insulted me, so I'm not going to reply to you.
Good day, sir.
>>
>>52302410
Back in the old days, when C was introduced, it was considered high level.
Anything that doesn't involve fumbling with opcodes is high level, deal with it.
>>
>>52302309
you use haskell for whatever retarded reason

you use rust because... i dunno i guess you're right
>>
>>52302399
It handles data pretty reasonably. Did you think the GPU rendered FBX models directly or something?
>>
>>52302427
k tard

nothing wrong with how opengl handles data
>>
>>52302420
i want web devs to leave
>>
>>52302440
It's not 1980 anymore, C is a low level language, deal with it.
>>
>>52301820
>printing what window_width and window_height are gives: width = 20319152 height = 0
>They should be 800 and 600.
Where do you initialise them? You declare them at the top, but you never initialise them or pass them to any function.
>>
>>52302457
I didn't say there's something wrong with the way it handles data. I said it'd be a pain in the ass to import various 3D model formats the way it does.
You are quite stupid.
>>
>>52302483
>I said it'd be a pain in the ass to import various 3D model formats the way it does.
and i asked you to explain how
>>
>>52302470
Shitpost bot detected.
>>
>>52302410
rust has enough features that it's hard to consider low-level
>>
>>52302483
>>52302457

Good old /dpt/

>you are le stupid programmer
>no you are stupid programmer

Repeat forever. Come back when you are actually doing something worthwhile.
>>
COME ON IT'S 2016

ANY LANGUAGE CAN BE LOW LEVEL IF IT FEELS LIKE IT

SMASH THE ASSEMBLIARCHY
>>
God, I never realised how slow C# is before. Even just going to C++ is orders of magnitude faster, and this is shitty unoptimised code, if I worked on optimising it the difference would be even more insane.
>>
>>52302504
You'd know that if you had ever written a 3D model importer/exporter script for a 3D modelling suite.
I don't have time to argue with imbeciles.
Have a good day.
>>
>>52302514
>hurr i'm a complete newfag and i can tell you that opengl is going to be a complete pain in the ass when i haven't even tried it
>explain yourself tard
>no u
>>
>>52302560
kill yourself
>>
>>52297569
get a trip pls, something cute too
>>
>>52302558
C# is hard to benchmark, because of the JIT. Making some basic benchmark program and running it is an awful way to measure C# performance. The JIT takes time to kick in.

C# is slower than C++, but it's not that much slower. It's not anywhere near Python tier.
>>
>>52302399

https://github.com/assimp/assimp

WHAT A HORRIBLE PAIN IN THE ASS

>ASSIMP

>PAIN IN THE ASS

>ASSIMP

>ASS

>I can already tell it's going to be a horrible pain in the ass to deal with 3D model formats in the future.

THIS NIGGA PSYCHIC
>>
>>52302560
um I'm not the person you were talking to but I have written a 3D model importer before and had absolutely no problem

obj and 3ds store all the data that is easily fed to opengl

>>52302579
good idea c:
>>
>>52302620
>using third party 3D model formats
>not making your own
Faggot.
I bet you use .obj, too. Disgusting.
>>
>>52302565
I'm actually not the other poster, I was making fun of you both for having another of these pointless "you are a shitty programmer because" arguments.

You're right though.
>hurr i'm a complete newfag and i can tell you that $LANGUAGE_OR_FEATURE is going to be a complete pain in the ass when i haven't even tried it
>>
>>52302635
>.obj
>3ds
Pleb alert.
>>
I want a normal to a 3d line
what do
>>
>>52302667
Use maths fgt.
>>
>>52302681
explain
>>
>seems like more /dpt/fags are learning opengl these days
raw opengl masterrace
>>
>>52302641
>implying it's not a pain in the ass to deal with like 4 intermediate data structures getting a 3D model from the modelling suite to a file to your program to opengl
Especially considering every 3D modelling suite has a different scripting language for importer/exporter plugins.

You guys are retarded & not worth talking to.
>>
>>52302657
wait I also worked with md3 am I still pleb?

>>52302667
a 3d line doesn't have a single normal... does it?
>>
>>52302698
>You guys are retarded & not worth talking to.
yet you keep replying xd
>>
>>52297205
My hamster keeps escaping from its hamster ball during playtime. Holy shit it runs so fast I can hardly catch it
>>
>>52302701
no but it has infinitely many normals
>>
File: normal.jpg (11KB, 363x223px) Image search: [Google]
normal.jpg
11KB, 363x223px
>>52302667
>>52302689
You can only get a normal from a plane in 3D though. Rethink what you mean by normal. A normal from a 3D vector has infinite possibilities.
>>
>>52302719
i want the closest normal to a point so i can find the distance to it
>>
>>52302667
>>52302689

So if you look in this image >>52302719 the normal from the plane is n. But the normal of n can be any line that lines it the plane. So the normal of n is OX, where X is a point ANYWHERE on the plane.
>>
>>52302701
You're a pleb for not designing your own 3D model format that has all the features you need and leaves out features you don't need.
>>
>>52302731
So you mean you want to find the distance from a point to a vector?

Use something like http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
>>
>>52302772
wait

can I just project the point onto the line, get the point at the end of the projection and get the distance with the original point
>>
>don't know how to perform basic math thing
>look up how to perform basic math thing
>practice it on paper
>write it out in code
>go to bed
>wake up
>i have no idea how to read last night's code

am i gonna make it?
>>
Is it more efficient to use object-space normal maps than it is to use tangent space normal maps?

Aren't tangent space normal maps recalculated in object space at some point during rendering?
>>
>>52302752
ok
>>
File: PFvE9ye.webm (2MB, 718x404px) Image search: [Google]
PFvE9ye.webm
2MB, 718x404px
Ask your beloved programming literate anything.
>>
>>52302823
What is a man?
>>
>>52302823
Is C low level?
>>
>>52302796
Exact same result. Easiest way is to use that formula though. It's the abs of two vectors from two random points on your line to the point you want the distance too, crossed together. Then you divide by the abs of the vector between your two random points, squared.
>>
>>52302849
>easiest way is to use that formula
that really does not look or sound as simple, but thanks
going with the other one since I have a bunch of functions that already do every individual part
>>
File: snk.webm (710KB, 480x480px) Image search: [Google]
snk.webm
710KB, 480x480px
>>52302835
https://en.wikipedia.org/wiki/Man_page

>>52302848
technically, C is high level because C code is not an ISA but among all programming languages it can be considered low level due to its poor abstraction.
>>
>>52302861
it's not that hard really. are you working with a line or a line segment?
>>
>>52302889
>programming literate is snekfag
wow
>>
how could you convert a 2d array to a 1d array efficiently?

Particularly in java
>>
Windows 10: Choose a time to restart.
- today
- tomorrow

*tomorrow*

Sorry, that time is in the past.
>>
I'm trying to parse a CSV file, but Ruby is spitting errors about missing/stray quotations. I thought I was handling quotations in CSV correctly by just wrapping them around another pair of quotations. Does anyone know how to fix this?

Here is the line that causes the error:

movieID,location
3,"USA, California, Burbank, "Stage 16, Warner Brothers Burbank Studios - 4000 Warner Boulevard""


you see 2 opening quotations and 2 closing quotations. what is the problem?
>>
>>52303437
use System.arraycopy
>>
>>52297260
if you have been in corporate real world long enough you will use one of these:
Software Archaeologist
Code Janitor
>>
>>52298550
if you know c well then learning c++ will just make you angry.
ugly ugly looking language.
>>
>>52298091
Do it on the GPU or no balls
>>
>>52303778
If you know F# well then learning C/C++ will just make you angry.
ugly ugly looking languages
>>
New thread time
>>
>>52302048
write less not more.

your not a fucking factory worker. i've worked with some arrogant 10x developers. they generally fall into one of two groups, either sloppy code or tight code but they never see the bigger picture and write code that is difficult to modify or expand.
>>
>>52303863
No it fucking isn't
>>
>>52302420

>fewest resources
It means that the program uses the least amount of CPU cycles, or uses the least amount of memory, or takes up the smallest amount of space on disk.
>>
>>52303939
those + development resources
>>
>>52303493
You need to escape the inner quotation marks with a backslash so that it doesn't attempt to compile them as string wrappers.
>>
File: y.png (179KB, 1172x653px) Image search: [Google]
y.png
179KB, 1172x653px
Do you like my new "checkbox", /dpt/?

dom(".nameBlock").forEach(function(elem, index, array) {
elem.addEventListener("click", function(e) {
let input = elem.parentNode.childNodes[0];

if(!input.checked) {
input.checked = true;
elem.className += " checked";
} else {
input.checked = false;
elem.className = "nameBlock";
}

elem.addEventListener('mousedown', function(e){ e.preventDefault(); });
});
});
>>
>>52304146
>if statement

it's shit
>>
>>52303437
int arr_1d_size = arr_2d.length()*arr_2d[0].length();
// ^ assumes that all sub arrays have same size
type[] arr_1d = new type[ arr_1d_size ];
// ^ substitute "type" for your data type
for( int i =0; i < arr_2d.length(); i++ )
{
for( int j =0; j < arr_2d[ i ].length(); j++ )
{
arr_1d[ ( i *arr_2d.length() ) + j ] = arr_2d[i][j];

}

}



what this is basically doing is taking the length of the sub-arrays in the 2d array and adding them all up in an int variable by way of multiplying the length by the size of one of the sub array. As it says there, I'm assuming you have an array that has sub arrays all the same size.

Then what it does is it creates a 1d array of length equal to the combined lengths of the sub arrays in the 2d array.

Then it uses two loops to traverse the sub arrays in the 2d array and assigns each value to its corresponding place in the 1d array. If you'll notice, the array index to the 1d array is made by multiplying i by the length of the sub-array and adding j. This makes it so that the each sub array is denoted in the index as an offset of length() elements.

Hope this helps.
>>
>>52303437
>convert
disgusting
>>
How to spot a retarded code monkey:
>if statements
>loops
>OOP
>>
>>52304180
Ternary operators aren't as readable tbqh.
>>
>>52304211
>>if statements
>>loops

The Linux kernel is fucking trash lmao
>>
>>52304146
>muh minimalism
autist
>>
>>52304184
that thing inside the nested for loop should be

arr_1d[ ( i *arr_2d[ i ].length()  ) + j ] = arr_2d[i ][j ];


An easy way to picture this is, imagine you have a 2d array with [7][10]. The first sub-array can be found with 0*10 + j, where j is gradually incremented to 10. The second 1*10 + j, so on and so forth.

Let me know how it turned out.

If your sub-arrays aren't the same length this code will break.
>>
>>52304211
this desu senpaitachi
>>
>>52303437
Efficently? Use the standard library.
 int[] flatArray = Arrays.stream(originalArray).flatMapToInt(Arrays::stream).toArray(); 

Needs Java 8+ though.
>>
>>52304211
Real programmers use gotos :^)
>>
File: fragezeichen yui.png (94KB, 396x395px) Image search: [Google]
fragezeichen yui.png
94KB, 396x395px
I use foldr for everything
Is that ok?
>>
>>52304269
>int[] flatArray = Arrays.stream(originalArray).flatMapToInt(Arrays::stream).toArray();

>Java

Every fucking time, Java always surprises me
>>
>>52304289
No, you should be using foldl.
>>
>>52304184
oh, I didn't know you could use .length to get the lengths of both sides
Anyways I did it pre-emptively for my bit, just faked it, basically

was originally a 3d array and looked a lot better but I can't write a 3d array to file
h = i * 10;
z = -1;
round = 1;
for (int x = 0; x < h; x++) {
if (z == 9) {
z = 0;
round += 1;
} else {
z++;
}
int n = z + 1;
lines2[x] = ("\t\"" + (b+1) + "\"{\n" + "\t\tfactory \"PlayCommands\"\n" + "\t\tname \"Spec Player " + n +
" Round " + round +"\"\n" + "\t\tstarttick \""+ (roundTick[round-1] + (128*16) + n) + "\"\n" + "\t\tcommands \"spec_player " + n + "\"\n" +
"\t}");
b++;
}

>>
>>52304293
I almost think that is 2 function calls more complex than coding it inline...probably more if it constructs the maps on the fly...
>>
>>52304308
make a directory and have the depth be described as separate files in that directory!
>>
>>52304301
Why?
>>
NEW THREAD (early because fuck traps)

>>52304354
>>52304354
>>52304354
>>
File: Capture.png (44KB, 1568x907px) Image search: [Google]
Capture.png
44KB, 1568x907px
>>52304348
literally the only thing that matters is that it works, ok
>>
>>52304383
hi5!
>>
>>52304146
you should probably move the post texts to the left since the headers are much closer to the edge and corner now
>>
I'm beginning work on a analytic engine for Wikipedia. I want to do stuff like get the average article length, number of sources, ages of the articles.

When I get that working i'll start the second bit where I implement a link analyzer that can scrape available data from the source links and then determine if the link is 404. I have a theory that there must be a massive amount of link rot in Wiki articles, however their standards say that's ok. However if I generate an accurate report maybe I can get editors and authors to go back and do some upkeep on their dead links.

The entire reason wiki allows dead links is because it's a pain in the ass to keep track of and upkeep them. Maybe making it easier would help.

Also I need more projects because this job search thing is not working out.
>>
>>52304837
Check for circular references too
A lot of times Wikipedia will cite A and B, where A also cites B (so one source appears as two)
>>
>>52304864
I'll add it to the checklist. Right now my priority is to figure how to to serialize parsing the 22 gig xml file that wiki uses for it's data dump.

Since I have the data on disk my first instinct was to use c++ but I haven't found web scrapers/parsers that are as powerful as the ones available in Python.
>>
How to spot an idiot:
>>52304211
>>
>start doing hackerrank
>check leaderboard
>indian, indian, indian, indian, indian, indian...

it's worse than I thought
how can i compete with so many people doing the needful?
>>
Anyone wanna help me out on this project?
https://github.com/Zenga1811/soundcloud-project
>>
>>52304896
nice!
>>
>>52306372
No readme of what it's about?
Thread posts: 311
Thread images: 48


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