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

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

Thread replies: 255
Thread images: 48
File: hamster-escape.jpg (26 KB, 400x402) Image search: [Google]
hamster-escape.jpg
26 KB, 400x402
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 (287 KB, 620x876) Image search: [Google]
bzzt.jpg
287 KB, 620x876
>>52297288
I'll create the logo
>>52297279
What about anime?
>>
>>52297320
>an adblocker blocker isn't a meme
see >>52297196
>>
File: memes.png (767 KB, 473x632) Image search: [Google]
memes.png
767 KB, 473x632
>>52297320
I was thinking I'd make some concept art based off this
>>
>>52297369

ME GUSTA
>>
File: Hamsterhamham.png (128 KB, 611x767) Image search: [Google]
Hamsterhamham.png
128 KB, 611x767
>>52297325
Only if they're anime hamsters.
>>
>>52297347
have you made an app before
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
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 (149 KB, 914x897) Image search: [Google]
lua.jpg
149 KB, 914x897
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 (71 KB, 573x892) Image search: [Google]
1425622024474.jpg
71 KB, 573x892
>>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 (40 KB, 480x749) Image search: [Google]
nagisa.jpg
40 KB, 480x749
>>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 (1 MB, 1702x2471) Image search: [Google]
trap programmer.png
1 MB, 1702x2471
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 (36 KB, 600x337) Image search: [Google]
1452112132284.jpg
36 KB, 600x337
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 (141 KB, 460x275) Image search: [Google]
brains.png
141 KB, 460x275
>>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 (103 KB, 836x385) Image search: [Google]
5kg.png
103 KB, 836x385
>>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 (61 KB, 800x507) Image search: [Google]
flat,800x800,075,f.jpg
61 KB, 800x507
So apparently pic related is a hamster.
>>
File: YEAAAAAH COLA.jpg (141 KB, 1280x720) Image search: [Google]
YEAAAAAH COLA.jpg
141 KB, 1280x720
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 (2 KB, 118x119) Image search: [Google]
1452211906834.jpg
2 KB, 118x119
>>52297844
>>
File: photo_2016-01-07_16-15-13.jpg (34 KB, 804x649) Image search: [Google]
photo_2016-01-07_16-15-13.jpg
34 KB, 804x649
>>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 (481 KB, 626x988) Image search: [Google]
uui9.png
481 KB, 626x988
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 (37 KB, 732x720) Image search: [Google]
popcorn.jpg
37 KB, 732x720
>>52297958
You get 1/2 for the hamster. You should learn to program. Here's mine.
>>
File: Laughing-Frog-Man.jpg (25 KB, 400x386) Image search: [Google]
Laughing-Frog-Man.jpg
25 KB, 400x386
>>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 (304 KB, 722x768) Image search: [Google]
1385792865025.png
304 KB, 722x768
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 (10 KB, 521x180) Image search: [Google]
uhg.png
10 KB, 521x180
>>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 (317 KB, 700x898) Image search: [Google]
1410860209595.jpg
317 KB, 700x898
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 (107 KB, 1600x557) Image search: [Google]
relate.jpg
107 KB, 1600x557
>>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 (204 KB, 575x467) Image search: [Google]
torvalds.jpg
204 KB, 575x467
>>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 (73 KB, 700x374) Image search: [Google]
fffff.jpg
73 KB, 700x374
>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 (75 KB, 2076x80) Image search: [Google]
watdo.jpg
75 KB, 2076x80
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 (49 KB, 460x276) Image search: [Google]
evolution.jpg
49 KB, 460x276
>>52300447
Forgot an amazing inspirational quote
>>
File: 1439523429849.gif (133 KB, 311x366) Image search: [Google]
1439523429849.gif
133 KB, 311x366
>>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 (39 KB, 300x309) Image search: [Google]
42315.jpg
39 KB, 300x309
>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 (90 KB, 1280x720) Image search: [Google]
ppp.jpg
90 KB, 1280x720
>>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 (140 KB, 814x545) Image search: [Google]
quantum.jpg
140 KB, 814x545
>>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 (102 KB, 1280x720) Image search: [Google]
religion.jpg
102 KB, 1280x720
>>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 (13 KB, 843x219) Image search: [Google]
hhj.png
13 KB, 843x219
>>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 (61 KB, 391x340) Image search: [Google]
1445731234754.jpg
61 KB, 391x340
>>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 (16 KB, 388x834) Image search: [Google]
Capture.png
16 KB, 388x834
>>52301752
if I am not misunderstanding, yes it does run the function
>>
>>52301848
of course it runs the function ffs.
>>
File: line.png (132 KB, 942x739) Image search: [Google]
line.png
132 KB, 942x739
>>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 (334 KB, 1024x768) Image search: [Google]
Sea Horse4.jpg
334 KB, 1024x768
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 (23 KB, 600x338) Image search: [Google]
mount stupid.jpg
23 KB, 600x338
>>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 (11 KB, 363x223) Image search: [Google]
normal.jpg
11 KB, 363x223
>>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?
Thread replies: 255
Thread images: 48

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.