[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: 338
Thread images: 35

File: deluxo el maco.jpg (124KB, 1280x854px) Image search: [Google]
deluxo el maco.jpg
124KB, 1280x854px
Previous thread: >>56350257

What are you working on, /g/?
>>
>>56358765
First for D
>>
When you go to university for CS, is it required for you to be familiar with Discrete Mathematics, Graph Theory, etc. or do they teach those subjects from ground-up?
>>
>>56358765
Too early you dumbass
>>
>>56358871
no
>>
Possibly going to intern at EA, have only heard bad things about them but I think it'll be worth it, right? Would be in internet interfacing stuff, which seems cool.

>>56358871
It's required for us to learn it at least; they taught discrete "from the ground up" per se but it was a cut-off course and a lot of people failed, so being a non-idiot helps
>>
>>56358871
They teach those subjects.
>>
>>56358871
Well it depends on country/school, but in general they assume you know high school level stuff, which doesn't directly involve discrete math and graph theory. They'll probably have some courses that continue on your high school math, like calculus. But Discrete and Graph Theory are separate subjects so they teach those from the ground up.
>>
>>56358765
Why are there two /dpt/s?
>>
>>56358931
>>56358933
>>56358928
Thanks! I consider myself not to be too dumb, so I think I'll manage.
>>
What's the best library for D to do some basic opengl graphics? derelictsfml are just some shitty C bindings and derelictglfw is just a PITA that doesn't work (for whatever reason). i only want to draw very simple 2d shapes, high-level is preferred
>>
>>56359035
Wrap sdl in high level functions.
>>
http://www.strawpoll.me/11125373

have you remapped caps lock to ctrl? it seems really bad for ctrl+c and ctrl+v but i'll remap function keys as copy/paste anyway. i'm kind of on the fence about using caps lock as ctrl or if i should just use the ordinary ctrl
>>
Is it possible to use the address operator on a function that returns a char pointer so that the function that comes after it can take a char ** pointer?

eg.
char *func3(char **str);
/* */
char *done = func3(&func2(func1(some_source)));
>>
>>56359290
Why would you do that? You shouldn't be pressing caps lock regularly, since using shift for single letters is faster. Literally why?
>>
>>56359324
I wouldn't
>>
File: 1471507906706.jpg (470KB, 2264x1062px) Image search: [Google]
1471507906706.jpg
470KB, 2264x1062px
>>56359344
i mean using the caps lock key as if it was a ctrl key
>>
File: zig.gif (19KB, 480x240px) Image search: [Google]
zig.gif
19KB, 480x240px
>>56358808
allies against the fad/meme languages
>>
>>56359369
Oh, that does make sense I guess...
>>
>>56359441
bjarne and stallman use pic related or one like it
>>
>>56359415
D is not a meme
>>
What's a meme language?
>>
>>56359698
Haskell lisp etc.
>>
Reading https://msdn.microsoft.com/en-us/library/cc668191.aspx#Y684
What's happening when the article says to put

inspectors = this.Application.Inspectors;
inspectors.NewInspector +=
new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);


in _Startup? I know that the inspector's purpose is to pull up the topmost open window (which for the example would be clicking "New Email," but why are we adding it to new Outlook.InspectorEvents... and setting it to inspectors.NewInspector?
>>
How do I make a DFA from a regex in C?
I'd like it to be extensible, like being able to add some extensions like POSIX character classes.
I have no idea where to start.
>>
>>56359779
*and THEN setting it to
>>
>>56359767
>What's a vegetable?
>"Tomato, avocado, etc."

You didn't define what a meme language is, and those aren't meme languages.
>>
>>56359779
It's adding an event callback. When the New Inspectors event triggers, InspectorsEvents_NewInspectorEventHandler will get executed.

It's just a fancy way of saying "When X happens, execute method Y".
>>
>>56359817
Doesn't need defining, meme languages are just meme languages
>>
File: 1472580044677.png (357KB, 1388x1080px) Image search: [Google]
1472580044677.png
357KB, 1388x1080px
>>56358765
hey /dpt/, how would you make a script to click checkboxes on chrome? I do it like a fucking retard. I open the page I need a lot of things clicked and then run this python script using pyautogui to find a checkbox and click them.

Like I said, like a fucking retard.

I know there's a way of doing it better using javascript to click the elements, how do I do that?

import pyautogui
import time
while True:
for i in range(0,10):
o = pyautogui.locateOnScreen('checkbox.png')
if o == None:
print('wow')
break
ox, oy =pyautogui.center(o)
pyautogui.click(ox, oy)
r = pyautogui.locateOnScreen('r.png')
rx, ry = pyautogui.center(r)
pyautogui.click(rx, ry)
pyautogui.press('enter')
time.sleep(2)
>>
>>56359779
When NewInspector is fired, you call your own method "Inspectors_NewInspector()".
>>
>>56359698
No one knows.

If anyone says X is/is not a meme language, just say they're wrong and there's no more conversation.
>>
>>56359698
it's a language that's unsuitable for productive work (e.g. haskell, lisp) but it gets used by memers
>>
>>56359857
Doesn't sound like a bad way to do it, honestly. You could use Selenium in Python and just look for any checkboxes in a similar fashion to the JS thing you want to do.

https://automatetheboringstuff.com/chapter11/
>>
>>56359698
A language that you can't get jobs for in your own town. For example, you can get Java and Python jobs anywhere, but you have to move to another country to get a job writing Haskell.
>>
>>56359976
I will soon have a OCaml job. It's fucking nice.
>>
>>56360035
Yes, but you literally had to move to the other side of the planet for it, so it's a meme.
>>
File: 1471477689849.png (311KB, 652x669px) Image search: [Google]
1471477689849.png
311KB, 652x669px
>>56359922
why is he doing firefox in the example? can you do just the same but replace 'firefox' with 'chrome'?


my thing works but it's so so slow, that's why I want to make something better
>>
>>56360076
No I will stay in my country.
>>
>>56360080
Not using a code generator.
>>
>>56360089
No, that's not possible. OCaml is definitely a meme so you had to move to a totally different planet to find a job like that.
>>
>>56360080
A E S T H E T I C
>>
>>56360155
Don't be jealous anon.
>>
>>56360185
I'm not jealous at all. I'm safe and comfortable in my home here on Earth while you're out traveling through the cold, empty void to some other galaxy.
>>
>>56358765
Is it me or all languages suck ass?

I know a little bit of Python what real language should I learn?

Is Haskell a waste of time?
>>
Are pajeets actually good at code?
>>
File: space-hooker.jpg (8KB, 300x168px) Image search: [Google]
space-hooker.jpg
8KB, 300x168px
>>56360203
There are space hookers in the void anon. Don't be jealous.
>>
>>56360080
>can you do just the same but replace 'firefox' with 'chrome'?
http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium

>my thing works but it's so so slow
Make sure you set pyautogui.PAUSE to 1 so there's only that 1 second delay between commands and use time.sleep() for any lengthy pauses you need. So at the top you can add
import pyautogui as p
p.PAUSE = 1


I dunno if this helps but for a script I have at work, I did
# import lib as "p" as above
def locate(img):
btn = p.locateOnScreen(img)
btnX, btnY = p.center(btn)
clk(btnX,btnY,l)
>>
>>56360206
C#

>>56360234
No but they can put together simple stuff for pennies. Sometimes that's what you need, sometimes it's not.
>>
>>56360238
>>
File: what_its_like_to_use_C.png (468KB, 936x550px) Image search: [Google]
what_its_like_to_use_C.png
468KB, 936x550px
You travel back in time a few days before Dennis Ritchie invents all of programming, but only get to say 5 words to him. What do you say?
>>
>>56360300
oops didnt realize it was nude
>>
>>56360319
C is a meme language

>>56360322
>deleting your post's image because you realise it violates the rules
you can stay anon, i like you
>>
>>56360319
templates please, that is all.
>>
>>56360206
C# if you want something enterprise-friendly that's also enjoyable to write (unlike Java, C++).
>>
File: 4ch-rs.png (212KB, 1920x1080px) Image search: [Google]
4ch-rs.png
212KB, 1920x1080px
Playing around with the 4chan API: https://github.com/4chan/4chan-API
>>
>>56360319
fuck header files, nigger
>>
>>56360300
Shit I wanted to watch your picture.
>>
>>56360343
What is the best resource for learning c#?
>>
>>56360415
This one is pretty solid.

Link to free PDF on page:
http://www.robmiles.com/c-yellow-book/

It sort depends on what industry you're in, or what you really want to do with it, because some books are geared towards certain ends.

The book I learned on back in the day, Murach's, is very database focused, so I can't recommend it in general.
>>
>>56360415
http://www.robmiles.com/c-yellow-book/

MSDN
>>
>>56358871
A Discrete Math undergraduate course will usually be just set theory and relations.
>>
>>56360440
>>56360445

thanks anons, I'll check these out.
>>
>>56360440
I use linux. Can I use Mono and everything will be nice?
>>
>>56360493
You should be fine, Monodevelop is fairly solid. I've got a buddy that uses Fedora (I think), and he came from Python and is now using C# in Monodevelop for everything.

Just note that the best C# dev experience is with VS, even if you're developing cross-platform programs, and you may consider loading up a Win10 VM for it.

Obviously, you can use whatever text editor + shell compilation strategy you want, if you want to stick with emacs or vim or whatever.
>>
>>56360319
objects contain data and functions
>>
>>56360537
*objects encapsulate data and functions

gets the point across better
>>
>>56360551
*objects encapsulate data WITH functions

i suck at time travel
>>
>>56360551
> meme language
>>
File: 1472379407796.jpg (40KB, 597x652px) Image search: [Google]
1472379407796.jpg
40KB, 597x652px
>>56359922
>>56360262

here guys, I figure it out. This is all that you need to paste in the console:
document.querySelectorAll('input[type=checkbox]').forEach(el => el.checked = true)


one fucking line, so much time saved
>>
>>5635989
you're a meme dpt-er, so your opinion has no value around here
thanks
>>>/rebbit/
>>
How to do this problem in O(1)? Iterative solution is easy.

https://projecteuler.net/problem=40
>>
>only finished 3 out of 5 problems on the hackerrank challenge for an internship i'm applying for
the first question i'm 90% sure was a troll question too. It wanted you to return a boolean of if there's any pair of values in two arrays that could be added to equal a set goal value, in O(n) time
>>
anon...
>>
>>56361217
meant for >>56361051
>>
>>56361007
project euler problems, though they can be programmed, can usually be done using math in O(1)
>>
>>56361051
Christ. You're a fucking bright one aren't you? Did you ever think to get the max values out of the 2 arrays and add them together?
>>
>>56361273
that doesn't even have anything to do with the problem
>>
>>56361273
that's not the solution. you need the pair to add up to an exact goal value, they shouldn't exceed it
>>
>>56361297
shit
Well use a hash set then.
>>
>>56361007
post your solution please

d n = champernowne !! (n-1)
where champernowne = concat $ map show [1..]

main = map d [10^i | i <- [0..6] ]
& map (\x -> read [x]) -- convert to list of digits
& product -- product those digits
& print



> main
210
it :: ()
>>
>>56361330
O(n)
>>
>>56361051
am i the only one who's figured out a solution

remember that k*n i still O(n)
>>
>>56361443
Mine literally just does what it says in the question, concatenates all those numbers and multiplies the 1st, 10th, 100th val. What does yours do?
>>
File: Pong2.webm (950KB, 1094x720px) Image search: [Google]
Pong2.webm
950KB, 1094x720px
>>56353713
Improved a bit on my pong game yay
>>
>>56361446
        static bool ContainsSum(int[] ArrayA, int[] ArrayB, int Check)
{
System.Collections.Hashtable Table = new System.Collections.Hashtable(ArrayA.Length + ArrayB.Length);
int counter = 0;
for (int i = 0; i < ArrayA.Length; ++i, ++counter)
Table.Add(ArrayA[i], counter);
for (int i = 0; i < ArrayB.Length; ++i, ++counter)
Table.Add(ArrayB[i], counter);
counter = 0;
for (int i = 0; i < ArrayA.Length; ++i, ++counter)
if (Table[Check - ArrayA[i]] != null)
if ((int)(Table[Check - ArrayA[i]]) != counter)
return true;
for (int i = 0; i < ArrayB.Length; ++i, ++counter)
if (Table[Check - ArrayA[i]] != null)
if ((int)(Table[Check - ArrayB[i]]) != counter)
return true;
return false;
}
>>
>>56359857
Well, it depends. Are you sure you absolutely need to open the page in a web browser? Can't you intercept the requests and see what it does underneath, then simulate the requests in (insert your preferred language with networking support here)?

What do you want to do?
>>
>>56361631
no i just wanted to search history for a certain website, and then check all the instances so only that website is removed from history while the rest of the history is intact. figured it out here >>56360617
>>
>>56361624
Are you playing or an AI?
>>
>>56361607
the same thing
but I want to see the solution in your language
assuming it isn't haskell
>>
>>56361666
Does it look like it's an AI playing Devilboy?
>>
>>56359324
Maybe? Does func3 dereferences it, or does is it used as a array or char*?

Also, if func2 returns a dynamically-allocated char*, this would result in a memory leak.
>>
File: pepeeeeeeeeeeeeeeeeeeeeeee.png (124KB, 261x218px) Image search: [Google]
pepeeeeeeeeeeeeeeeeeeeeeee.png
124KB, 261x218px
>>56361624
that;s a lot easier to do in javascript I would say

>https://www.udemy.com/code-your-first-game
>>
how do I create a file in haskell without doing
writeFile "file" []
>>
>>56361686
>Implying anyone completing that course can program something afterwards
>>
>>56361630
Isn't this n^3?
>>
Does anyone here know about the localization process used for video games?
My question is if built-in function words are still English when Japanese programmers program, or if they are translated? If so, then does the code itself need to be translated during the localization process, or does the code remain the same and just the strings/dialogue are replaced with English?
>>
>>56361786
>for loops going from 0 to the array lengths
Why the fuck would that be O(n^3)?
Also the last for needs ArrayB in the null check.
>>
>>56361865
Don't your searches within those loops use O(n)?
>>
>>56361856
It's widely recommended to program in English, no matter what country you're from.

It all depends on the developers.
>>
>>56361908
the loops aren't nested
>>
>>56361908
n + n + n == n * n * n
you got it figured out anon
>>
>>56361856
some japanese people might program in japanese but they generally don't involve themselves with english programmers. the source code is almost always in english and only the content of the game (not the source code) needs to be localized
>>
File: TA.jpg (32KB, 516x335px) Image search: [Google]
TA.jpg
32KB, 516x335px
For Non-NEETs ITT, what are the stereotypes of the following people in the workplace:

>Backend Web Dev
>Frontend Web Dev
>Data Engineer
>Database Admin
>IT guy (i.e. hardware)
>Analysts/Business Intelligence

I work with all these kinds of people, just interested in seeing if the stereotypes carry over
>>
>>56361994
>>56361959
Interesting, thank you guys.
>>
What's going on here? How can an array list of doubles actually contain longs?


public static void main(String[] args) {

Long a = 10301002L;

Map<String, Long> mapStringLong = new HashMap<String, Long>();

mapStringLong.put("value 1", a);

Object stuff = mapStringLong;

@SuppressWarnings("unchecked")

Map<String, Double> mapStringDouble = (Map<String, Double>) stuff;

System.out.println(mapStringDouble.get("value 1"));

double myDouble = mapStringDouble.get("value 1").doubleValue();

System.out.println(myDouble);
}



Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Double
at com.game.main.graphics.example.main(example.java:24)
>>
>>56362008
>Map<String, Long> mapStringLong = new HashMap<String, Long>();
>Long
>>
>>56361908
They're hash tables, so they have O(1) insertion and O(1) search times.
>>
Currently working on a project for source games by exploiting how they send info to the client and server by using a MITM attack to allow shit like radar hacks for csgo accessible on the phone or even browser.
>>
>>56362081

64 bits, same as a double
>>
is it just me or does R look really easy to learn?
>>
>>56358765
Why does Java suck so much?
>>
>>56361856

Code is all English because compilers do not have any built-in functionality to have stuff built-in to handle keywords from a different language and it would greatly complicate matters so no one does it.

Variable names, on the other hand, may be in a different language depending on if the compiler allows one to use Unicode or whatnot in the source code, or even stupid emojis, like Swift, but the biggest game language like C++ will not allow it. Comments are the most likely to be in a foreign language too, because it is allowed.

But it doesn't matter in the end. You don't get access to the source code of a game unless you have some legal agreement with the developer. And the compiler strips out everything that would be useful from having the source code so why would you need it? If you are translating it legally, you just get excel sheets most of the time and some in-game lore bible to be able to translate the game strings and send it back to the developer to insert in the game, where they handle everything. If you are doing a fan translation, the same thing goes where you have to translate every single game string but you also might have to hack around with the game code in order to make your localized string display correctly. But that involves hex editing which is language agnostic anyways.
>>
>>56362195
>he doesn't code with emoji variable names and functions
>>
File: 1428645148972.png (87KB, 591x346px) Image search: [Google]
1428645148972.png
87KB, 591x346px
>>56362223

>implying that anyone would want pic related anywhere in their codebase
>>
>>56361856

In my experience programmers program in whatever language they're comfortable with and if they're writing code for general use they write using short mathematical variables.
>>
a lot of people say you have to learn how computers really work before you try to learn C

how do I learn how computers really work?
>>
>>56362292
Program a website in Assembly.
>>
>>56362268

That's not that complex. At least you know what it is still doing after looking at it a bit. Pic related is truly terrifying though.
>>
File: 1446300902947.png (1MB, 846x902px) Image search: [Google]
1446300902947.png
1MB, 846x902px
>C++ namespace syntax
>>
File: 1459267173335.png (312KB, 506x662px) Image search: [Google]
1459267173335.png
312KB, 506x662px
>>56362317
nice meme
>>
>>56362340
>C++
>>
File: 1471901801400.jpg (10KB, 480x468px) Image search: [Google]
1471901801400.jpg
10KB, 480x468px
var likeElement = document.querySelector('.coreSpriteHeartOpen');
var nextElement = document.querySelector('.coreSpriteRightPaginationArrow');
var likeCount = 0;

function doLike() {
likeCount++;
console.log('Liked ' + likeCount);
var nextTime = Math.random() * (14000 - 4000) + 4000;
likeElement.click();
setTimeout(function() {nextElement.click();}, 1000);
if (likeCount < 25) {
setTimeout(doLike, nextTime);
} else {
console.log('Nice! Time for a break.');
}
}

doLike();



Some of the guys on my team were playing around with this simple instagram like bot they found.

I'm a bit new to JS (python background) - I can see how it works, but the one thing I can't figure out is this line:
var nextTime = Math.random() * (14000 - 4000) + 4000;


I get why it's random, but why is he subtracting 4 seconds from 14, and then adding on another 4 at the end?

Is he retarded or is there a reason I'm not seeing?
>>
File: 1444933478214.png (7KB, 473x454px) Image search: [Google]
1444933478214.png
7KB, 473x454px
>>56358871
How many high schoolers do you think go into college knowing discrete math and graph theory? That's some Phillips Academy level shit.
>>
>>56362160
first of all, Double and Long aren't the same as double and long

and java has strong typing so you're using the wrong language for whatever cancerous shit you're trying to do
>>
>>56362361

Order of Operations.
>>
>>56362356
>C
>>
>>56362361
It's a combination of two things: You and your friend are both fucking retarded, unless those numbers are written like that as a way to point out that 14-4 seconds is significant in some way. If the 14/4 is significant, it's just you that's retarded, because order of operations.

Either way, you're retarded.
>>
>>56362361
doesn't it
subtract 4 seconds from 14
multiply it for Math.random()
add 4 seconds

which is not the same as removing and adding?
I'm not sure I understand the question
>>
>>56358765
A fat shit.
>>
File: 1328774028152.jpg (11KB, 188x201px) Image search: [Google]
1328774028152.jpg
11KB, 188x201px
Rate my file type parser. It's vulnerable to spoofing, but it's better than using the file extension.

getMimeType :: FilePath -> IO (Maybe String)
getMimeType path =
IO.withFile path ReadMode $ \file -> do
bytes <- ByteString.hGet file 10
return $ listToMaybe $ catMaybes
[ fromBmp bytes
, fromGif bytes
, fromJpeg bytes
, fromPng bytes
, fromWebm bytes
, fromZip bytes ]

fromBmp :: ByteString -> Maybe String
fromBmp bytes =
let magicNumber = ByteString.take 2 bytes
in if magicNumber == "BM"
then Just "image/bmp"
else Nothing

fromGif :: ByteString -> Maybe String
fromGif bytes =
let magicNumber = ByteString.take 4 bytes
in if magicNumber == "GIF8"
then Just "image/gif"
else Nothing

fromJpeg :: ByteString -> Maybe String
fromJpeg bytes =
let magicNumber = ByteString.take 4 $ ByteString.drop 6 bytes
in if elem magicNumber ["JFIF", "Exif"]
then Just "image/jpeg"
else Nothing

fromPng :: ByteString -> Maybe String
fromPng bytes =
let magicNumber = ByteString.take 3 $ ByteString.drop 1 bytes
in if magicNumber == "PNG"
then Just "image/png"
else Nothing

fromWebm :: ByteString -> Maybe String
fromWebm bytes =
let magicNumber = ByteString.take 4 bytes
in if magicNumber == "\SUBE\223\163"
then Just "video/webm"
else Nothing

fromZip :: ByteString -> Maybe String
fromZip bytes =
let magicNumber = ByteString.take 2 bytes
in if magicNumber == "PK"
then Just "application/zip"
else Nothing
>>
>>56362379

I came across this gem today whilst trying to solve some compiler warnings related to types. The program itself was taking javascript data and somehow casting it right into java producing some cool bugs but this one with a double array full of floats really got me.
>>
>>56362386
>>56362401
>>56362407
I get that it's not
(14-4) + 4


I'm just asking why there's any addition and subtraction in this at all when a random number would have worked
>>
>>56362361
kill yourself
>>
>>56362422
How do I into haskell?
>>
>>56362432
BECAUSE THE PROGRAMMER WANTS TO ENSURE THAT THERE ARE AT LEAST 4 SECONDS AFTER RANDOMNESS

FUCK
>>
>>56362422
>but it's better than using the file extension.
No it's stupid. extension is the best thing.
>>
>>56362432
this: >>56362466
>>
>>56359779
>
new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);

>object-oriented """""languages"""""
>>
>>56362466
Oh

How come?
>>
>>56362334

At least you know that's mergesort of some sorts and the function names aren't emoji.

You can easily find worse emoji code. Try figuring out what this is supposed to do.
>>
>>56362506
it's a fucking bot that fucking tries to replicate fucking human fucking behavior

a human doesn't wait 0 seconds
>>
File: tumblr_inline_ndei96aXh71qgx55j.png (130KB, 500x709px) Image search: [Google]
tumblr_inline_ndei96aXh71qgx55j.png
130KB, 500x709px
>>56362557

Whoops, forgot to include pic.
>>
>>56362422
Use `file`
>>
>>56362502
that's C#, it's even worse than java, despite what /dpt/ memers want you to think
>>
>>56362502
new X.Y(Z) is too hard for you to comprehend huh?
>>
>>56362620
What language do you recommend?
>>
>>56358765
The guys in the linux thread are useless. How do I turn vim into an ide? I know about clang auto complete plugin. But how do I get proper views for debugging, pretty colors, split screens etc? What book should I read so I actually can use vim?
>>
>>56359324
The "address of" operator requires an lvalue. The function returns a number. You can't take the address of a number.
>>
>>56362775
java and/or C++ depending on the application
>>
>>56362813
Visual studio with the vsvim plugin.
>>
File: 1411135647764.png (919KB, 960x1440px) Image search: [Google]
1411135647764.png
919KB, 960x1440px
Who's your language waifu?
>>
>>56362825
Java = over engineered
C++ = harder than quantum physics
>>
>>56362850
I'll be doing linsux programming in possibly a console window. I have no choice due to coding for a living,
>>
>>56362002

>Backend Web Dev - Pajeet
>Frontend Web Dev - Josh
>Data Engineer - Gap year
>Database Admin - Neckbeard++
>IT guy (i.e. hardware) - Neckbeard
>Analysts/Business Intelligence - Jenny

u r welcome
>>
>>56362853

Omg. Just. Omg.
>>
>>56362896
Do you have learning difficulties?
>>
>>56362915

No. But I'm pretty sure the guy who posted the pic I referenced does.
>>
>>56362859
for you
>>
>>56362581
hahaha oh god

it doesn't even make sense you have to at least make it simpler or use things that look like their intended purpose
>>
>>56362178
bump

this is a question for non-comp sci majors btw
>>
>>56360319
Comment delimiters must be matched.
>>
>>56360319
Assignment and updates returns void.
>>
I'm learning Javascript for a college web dev module. Did a 12 year-old write this language?
>>
>>56363118
It was apparently initially designed in 4 days.
>>
>>56363118

Brandon Eich spent 10 days making the language before it was put into production code and then shipped with Netscape.

Compare that with other languages which spend years in a beta state before shipping.
>>
>>56363118
Its less dumb with things like jquery, but base JavaScript is painful to work with.
>>
>>56361051
hashmaps my man
>>
>>56358765
I'm writing my own command shell.
>>
>>56358928
I literally cannot believe people fail discrete math. The one offered in my CS dept was so weak. I am taking the upper level MATH offering of discrete maths so I can get a more masterful understanding.
>>
>>56359048
This
>>
>>56360319
Code as data as code
>>
>>56363329

And this student's name? Albert Einstein.
>>
I'm hoping someone can enlighten me as to what events are truly for in C#, and how I might achieve what I'm trying to do.

I was under the impression that events were something that a class was able to fire, and then any arbitrary number of other classes could receive that event, even if said class did not have a reference to or instance of the previously mentioned class stored. As it turns out, this isn't the case and as far as I can tell it's just a more roundabout way to call functions (albeit with respect to protection levels which is a plus)
What are events actually used for? Can someone offer me a use case example?
For what I'm looking for, what might be a good option? I'm trying to make a menu system that allows me to easily add and remove buttons that preform various functions (It is a game GUI)
>>
>>56362853
Would do sick things to Perl.
>>
>>56362853
if you're talking about which one I actually use/like using the most, C#
If you're talking designs, definitely perl
>>
I'm inspecting how exactly 4chan deals with posting on the user end to better understand web services and how code interacts with said web services- I hope to make some form of bot by the end of it. I figured that the data for a post would be sent in a POST request, but it isn't. How is it possible for 4chan to receive data without a request?
>>
>>56360451
The course I took had permutations/combinations, probability, generating functions and elementary graph theory. Got an A, even though I didn't fully understand the meaning behind some of the techniques until I got into signals and systems.
>>
I added name and tripcode support to my C messageboard!

akaribbs.mooo.com
>>
>>56362448
Here's the rough equivalent in C# (some function names may not be correct) if that helps you get an idea of what's going on.

string GetMimeType(string path)
{
using (var file = File.Open(path))
{
var bytes = file.GetBytes(10);
var mimes = new List<string>()
{
FromBmp(bytes),
// etc...
};

return mimes.Where(x => x != null).FirstOrDefault();
};
}

string FromBmp(byte[] bytes)
{
var magicNumber = bytes.Take(2).ToString();

if (magicNumber == "BM")
{
return "image/bmp";
}
else
{
return null;
}
}

// etc...
>>
>>56359789
https://swtch.com/~rsc/regexp/regexp1.html
>>
>>56363461
>As it turns out, this isn't the case
No, that is pretty much how they work. You were right the first time.

A good example is for a button click
myButton.click += () => {Console.WriteLine("I was clicked!");}

where "click" is the name of the event we are subscribing to.
>>
>>56362422
something like this slenpai
data M = { t :: Int, d :: Int, i :: String, m :: String}

mime f = do
withFile f ReadMode $ \h -> do
b <- hGet h 10
return ( map (check b) magiks
& listToMaybe . catMaybe
)

magiks
= [ M 2 0 "bmp" "BM"
, M 4 0 "gif" "GIF8"
, M 4 6 "jpeg" "JFIF Exif"
, M 3 1 "png" "PNG"
, M 4 0 "webm" "\SUBE\223\163"
]

check b (M t' d' i' m')
= if elem (take t' $ drop d' b) (words m')
then Just ("image/"++i') else Nothing


note, it doesn't compile because I haven't importerd the proper libs
>>
File: Capture.jpg (33KB, 708x399px) Image search: [Google]
Capture.jpg
33KB, 708x399px
>>56363820
rip
>>
>>56363820

>name and tripcode support

I hope you aren't planning to make a pseudo-anonymous imageboard. Because out of all the legacy functions of a message/imageboard, those are the features that most impede such a purpose.

The only reason for such a thing is for an OP to identify oneself within a thread because of contributing OC. That can easily be remedied IMO from a user selectable option on whether or not each post has a unique identifier or not.

All other purposes that I have evaluated for a name/tripcode is not strong enough and easily can be abused for one's narcissistic tendencies moreso than for the benefit of the community.
>>
>>56363887
???

Reload the page, everything works great on my end.
>>
>>56363924
People who complain about tripfags are infinitely worse than tripfags.

This is a fact.
>>
Why are there no good GUI libraries for Python? PyQT seems like the only one, but the license is shit or expensive, depending on which you need.
>>
Hey guys, anyone familiar with sql?

I'm trying to make a table that contains 3 attributes that are all foreign keys. I want to make a composite primary key using two of the foreign keys. Is it possible to do so?

I understand this will probably have performance issues but this is for a steaming pos assignment that was written p poorly
>>
Any Android Developer lurking in this thread that has an App published on Google Play?
>>
>>56363941

I am complaining about the inclusion of such a feature, not about the people themselves, but I agree on your assertion, not fact, as a general observation.

However, enabling tripcode and naming for people's narcissism are contrary to a anonymous messageboard/imageboard community's interest and is not a good idea unless you are planning on making a named imageboard, in which case, you should not pretend to be anonymous in any sense at all to not misconstrue your intentions.
>>
Can someone please explain to me the concept of O(n^2)("Big O")? I need a better handle on the subject, if the examples could be shown in "C" would be amazing. Thanks in advance.
>>
>>56363963
https://wiki.python.org/moin/GuiProgramming
>>
>>56364013
I'm not sure what you're angry about.
Your post makes no sense and you seem like a sperg tbqh fampai.
>>
File: heckin fun.jpg (79KB, 466x700px) Image search: [Google]
heckin fun.jpg
79KB, 466x700px
>>56363924
;_*
>>
>>56364036

I don't know why you are replying to me if you don't exactly understand what I am talking about and will also insult me instead of wanting to gain clarity.
>>
>>56364020
>>56364020
>https://wiki.python.org/moin/GuiProgramming
I've read that.

I meant to say PyQT is the only *good* libraries. The rest are horrowshows.

GUIs are a mess on Python.
>>
>>56364055
Has anyone really been far as decided to use even go want to do look more like?
>>
>>56364013
I'd also rather have ID's instead of Name/trips with the option to sage for anonymous posting whilest keeping your ID.
>>
>>56363860
I like it.

getMimeType :: FilePath -> IO (Maybe String)
getMimeType path =
IO.withFile path ReadMode $ \file -> do
bytes <- ByteString.hGet file 10
return $ listToMaybe $ catMaybes
[ parseBytes 0 2 "BM" "image/bmp" bytes
, parseBytes 0 4 "GIF8" "image/gif" bytes
, parseBytes 6 4 "JFIF" "image/jpeg" bytes
, parseBytes 6 4 "Exif" "image/jpeg" bytes
, parseBytes 1 3 "PNG" "image/png" bytes
, parseBytes 0 4 "\SUBE\223\163" "video/webm" bytes
, parseBytes 0 2 "PK" "application/zip" bytes ]

parseBytes :: Int -> Int -> ByteString -> String -> ByteString -> Maybe String
parseBytes skip len magicNumber mimeType bytes =
let header = ByteString.take len $ ByteString.drop skip $ bytes
in if (header == magicNumber)
then Just mimeType
else Nothing
>>
>>56360319
type polymorphism and traits, default immutability
>>
>>56362154
that's pretty cool actually
how far are you? care to post some specifics?
>>
>>56363987
create table foo (
id1 int,
id2 int,
id3 int,
primary key (id1, id2),
foreign key (id1) references foreign1(id1),
foreign key (id2) references foreign2(id2),
foreign key (id3) references foriegn3(id3)
)
>>
>>56359698
F#
>>
>>56364066
But that's the story of almost every language, ever outside of the enterprisey desktop application languages. Stop complaining and just use the damn C++ bindings.
>>
>>56363852
Well, yes, but this requires a reference to myButton in the class that listens for the function
I'm looking for something that an arbitrary number of lambda functions can hear- a physical example would be a radio station and radios.

Would my best bet be to just have some boolean array that everything is constantly polling? That sounds slow.
>>
>>56362422
Why not just use the Magic package?
>>
>>56364107
no problem
always try to never repeat yourself
also, make bytes the first parameter and
try encapsulating skip, len, magicNumber and mimeTypes, into a single type, just like I did
that way, you can partially apply parseBytes and cut the code size
>>
>>56364207
You're going to want to subcribe all your radios to the NewBroadcast event, and do radioStation.broadcasts += new BroadcastEvent or whatever. I think that is the cleanest pattern. Something has to have a reference to something else at some point.

>Would my best bet be to just have some boolean array that everything is constantly polling? That sounds slow.
Events are designed specifically so you don't have to do this.
>>
>>56364165
Thank you very much! I did the same thing in sqlfiddle after posting, but that confirmation really saves me a bunch of time :)
>>
>>56364018
>examples shown in C
How illogical.

By the definition used in textbooks, Big O is the asymptotic upper bound.
In short, it is a mathematical function that places an upper bound on an algorithm or data structure's ability to grow. In this case, that growth, also known as complexity, is usually something like work (as in physics), or memory usage.

To say that an algorithm runs at O(n^2) means that for a given input (which may be a number or a set of numbers) the algorithm will not have to perform more than n^2 units of work to complete in the worst case.
Computer Scientists tend to ignore constants applied to Big O, because at the scales Big O is intended to work at, constants tend to be irrelevant.

Take searching for an element in a linked list.
As you should know, a linked list is composed of elements which point to the next element in line. Therefore, to find an element in a list (or verify that the element does not exist) given n elements, you must traverse n nodes in the worst case (the element is not found, or at the end of the list)
>>
>>56364242
I enjoy doing stuff myself if it's simple enough. It's about 16 lines of code now, so it feels not worthwhile to use a library.
>>
>>56363240
dog bless jQuery, absolutely essential for webdev
ajax will save your life one day.
>>
>>56364327
It is also important to note that Computer Scientists do not use an exact unit of work.
It is completely arbitrary.
For example, getting the next element in a list is a constant O(1) unit of work.
Computing FizzBuzz for the number 59684 is a constant O(1) unit of work.

In a computer programming language, it may become extremely obvious that the two are not equivalent amounts of work.
But keeping in mind that Big O is an asymptotic upper bound, as we trend towards infinity, the amount of work performed between the two functions becomes fairly insignificant and may as well be the same.
>>
>>56364327
is it possible to get fib O(logn)?
>>
>>56364405
I don't understand your question.
>>
>>56364416
calculate the nth fibbonacci numero
>>
>Trump will be the next president of the US

>Python is a great programming language

>Indians are a plague on the programming community

check em
>>
>>56364416
fibbonacci at logn?
possible?

whats the best O(f(x))
and is it possbile to have any f(x)
or are they all just typically logn, n^2, n, (1)
>>
How do I freeze my application properly? Freeze as in wait for SIGINT without causing 100% cpu load. In C.
>>
>>56364440
That is trivial in base phi. Of course, tranlating that back to binary or decimal is nontrivial. ; )
>>
>>56364479
SIGKILL works pretty well
>>
>>56364440
It depends on the algorithm.
If you were to calculate the nth Fibonacci number using standard recursion, your runtime would be O(n^2) because you branch twice attempting to calculate the (n-1)th Fibonacci number.

According to this algorithm: http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html#section1
it is possible to calculate the nth Fibonacci number with a constant amount of work, O(1).

I haven't verified its validity.

>>56364452
The best Big O function possible is O(1). A constant amount of work. Essentially instant.
It is illogical to have a function below O(1). Think of Newton's three laws. You need to expend energy to get a result.

Theoretically any f(x) is possible as long as it is positive. But as you have said, because Computer Scientists like to ignore insignificant figures, we tend to prefer simple functions like 1, log n, n, n^m.
>>
>>56364452
Google
http://kukuruku.co/hub/algorithms/the-nth-fibonacci-number-in-olog-n
>>
>>56361051
Solution in O(a+b) for lists of length a and b:

Iterate over the a array, adding the values to a hash set, taking O(n) time.

Iterate over the b array, for each k in b compute goal-k in constant time (the value that would need to be added to reach the goal). Look up this value in the hash set, taking O(1) time, in total O(b) time for all b elements.

Return true if you exit early, false if you finish iterating without finding a match.

In total, you spent O(a+b) time, or O(n) in the length of the longest list.

You should know hash tables like the back of your hand, they're the single most important data structure in computer science.
>>
File: Vehicles (1).webm (787KB, 1364x768px) Image search: [Google]
Vehicles (1).webm
787KB, 1364x768px
>>56358765

My simple OpenGL vehicle simulation with 2 sensors can now detect objects! I want to simulate Braitenberg's vehicles, but I'm a long way from my goal. I spent a long time getting poiint-sector intersections to work. I had to write intersect func shader and cpu side, but the logical output didn't match up to the shader's output. Turns out I was using radians by mistake when converting from polar to cartesian coords, when I should have been using degrees.

I'm going to try writing a c++ function for a perspective projection matrix next, and know that GLM offers a very fine implementation. However, I want to use my own implementation from my understanding of the maths.

Also, here's the crappy program!
>>
>>56364523
>A constant amount of work. Essentially instant.
No. It just doesn't grow with respect to the input size. It's not anything close to fucking instant unless you have an infinitely fast machine.
>>
>>56364479
pause()
>>
>>56364327
>>56364386
Thanks for the answers guys, I have a better grasp on the subject.
>>
>>56364452
What is n here? The size of the input or of the output?

I mean, fib n grows exponentially with n, so the number of bits required for storing the output will be O(n). So at the very least, you need linear memory.
>>
>>56364523
>The best Big O function possible is O(1). A constant amount of work. Essentially instant.
It's not instant, it means that the amount of computation required is always the same. If something can take a week at n=1 and a week at n=1000, it's O(1) regardless of the speed.
>>
>>56364542
Instant in this case is a weasel word. It is meaningless in the context of Computer Science.
As I said before, it refers to a constant amount of work. It may be a large or small amount of work, but constant nonetheless, and I would believe anyone to be hard pressed to find an algorithm with constant runtime that took longer than the human perspective of ``instant".
>>
>>56364452
In general, the best complexity is O(1), unless you know the input sizes beforehand, in which case it is possible to have something O(n) which is faster than O(1), although this is unlikely.

You could write any f, but you generally don't. Very basically, O(1) and O(2) are as close as makes no difference, so they are considered to be the same thing. That is, any constant amount is something we don't have to worry about; so if we have f(x) = 5 and g(x) = 10, both are considered to be in O(1). Likewise, if we have h(x) = 2x and i(x) = 7x, then both are considered to be in O(n).

Then there's also domination, which in laymans' terms means that, if a function is composed of two two functions, one of which is much bigger than the other, it is considered to be the same complexity as the bigger of the two. So, for example, f(x) = 2x + 7x^2 is in O(n^2) because 7x^2 is in O(n^2)
>>
File: capture.png (6KB, 518x103px) Image search: [Google]
capture.png
6KB, 518x103px
>>56364600
>anyone to be hard pressed to find an algorithm with constant runtime that took longer than the human perspective of ``instant".
Found one.
>>
>>56364523
This answer is wrong.

First, the non-memoized recursive algorithm that just uses fib(n+2) = fib(n+1) + fib(n) is O(phi^n), not O(n^2) , i.e. it is exponential (it's easy to show that it is O(2^n), you can refine the estimate to exactly O(phi^n) with some math).

Also, supposedly O(1) algorithms such as those using Binets formula will not be O(1) in practice if you want an exact integer output, because it requires exponentiating an irrational number at arbitrarily high accuracy.

The most efficient way to do this for numbers of the form a + b*sqrt(n) is in fact to solve a difference equation, which in the case of the golden ratio just means computing the fibonacci numbers so you end up with a circular solution.
>>
>>56364659
That's O(n).
You have a series of inputs (DateTime.Now) with a closed range of the current time and the target time. You are then comparing each one of these inputs to the target time.
>>
>>56364690
>That's O(n).
k, now you're just fucking retarded. No matter what the arguments to that function are it's always going to take approximately 2 days to complete.
>>
>>56364501
I don't want to kill it, I want it to wait for SIGUSR1, do some stuff and go back to sleep
>>
>>56364705
Or you could have just done a 2 day sleep.
>>
>>56364600
A network round trip is commonly a constant-time operation, given packets small enough not to fragment, and can take quite a long time. Ie, authenticate with a server.

Flushing a fixed-size buffer is constant time with respect to the contents of the buffer (while other parts of the algorithm may depend on the contents, ie 0s don't count for anything).

Etc etc.

Big O has a precise meaning, bounding one function by another with some constant offset + multiplier. So a sort might be O(nlogn) in time with respect to the length of the list, but for your specific use case it might be O(n) in time with respect to the number elements you moved to the start of the array, or it might be an O(1) operation as part of a larger algorithm, with respect to some input variable that doesn't impact the length of the array.

All for exactly the same implementation of the sorting algorithm.
>>
>>56364733
That makes it look like the program is stuck, this lets the user know that it's doing something important since it maxes out a core.
>>
>>56364018
for (int i = 0; i < n; i++) {
for (int k = 0; k < n; k++) {
>>
>>56364705
That's like saying you made a function that does x+y, except that it throws away y and replaces it with the literal '3'.
We all know what the underlying function is, but you act as if you invented a new operator that can only add by '3'.
>>
>>56364541
Nice anon. Making these things from the ground up takes a lot of time.
>>
>>56364445
So close
>>
>>56364783
>run SHA512 over the input x times
>make x as large as you need to to make it annoying for the user
There. Now you'll be a fucking autist and say something retarded like hash all the fucking input values and store them in a fucking table on some magic SSD to make it "instant."
>>
>>56364742
And just to elaborate, this is actually super important to understand correctly.

If sorting a 500 element list is part of your algorithm, but the performance of the sort doesn't vary with respect to the inputs to your algorithm, your algorithm sit-up will have the /exact same asymptotic runtime/ regardless of if you used an O(n^2) sort or an O(nlogn) one.

In practice your algorithm may end up X times slower because you used the O(n^2) in length of list sort, but the asymptotic runtime will be exactly the same. It can't be more than a constant factor, even if you used an O(n!) sort.
>>
>>56364818
You sure are hung up on the usage of the word "instant."

Do you also send Maruchan emails based on their erroneous usage of the word "instant" in their brand of noodles?
>>
>>56364837
Yes. I was late for work because of their false advertising.
>>
Are you a real game developer even if you use Unity?
>>
>>56364873
>>>/vg/agdg
>>
WHY CAN'T I JUST HAVE FUN
/dpt/ calls my language a "meme-language"
and I can't take it seriosly
I really have fun programming in it
Its very expressive
Please dont call it a meme again.
Its really good
It even has ncurses Libraries and gui libraries
>>
c++ newbie here, having trouble printing out 8 words from a vector per line, i could just google but im not a faggot. Somebody give me a hint
>>
>>56364910
1-2 is -1.
-1 is less than sizeof anything.
sizeof char is 1
Element 1 is 2
>>
>>56364910
Because arrays are indexed from zero.
>>
>>56364910
>>56364945
>>56364955
Shit, meant why is the output 3?

int array[4] = {1,2,3,4};
if(array[0] - array[1] < sizeof(array)) printf("%d",array[sizeof(char)]);
else printf("%d", array[sizeof(short)]);


  Desktop gcc -o test test.c
Desktop ./test
3%
>>
>>56364928
start the counter with one
when the counter is divisible by 8, print the character and a newline, otherwise, print just the character
stop when it reaches EOF or '\0'
>>
>>56364962
sizeof short is 2, so you're accessing element 2.
>>
>>56364903
They probably work maintaining COBOL code and take it our on people who have fun in other languages because of their stressful job.
>>
I'm a noob to programming. I just wrote fizz buzz in C++ and now I feel like a 1337 hacker.
>>
>>56364897
>>>/trash/
>>
>>56364962
Where did the percent sign come from?

Step through with a debugger, that's weird and should not have happened.

Also put braces on your conditionals, and next time post a complete program.
>>
>>56364979
I shouldn't be accessing element 2 though, the if block should be executed, as >>56364945 said.
>>
>>56364995
>Where did the percent sign come from?
zsh does this once in a while

>debugger
Yeah, I'll do that.

>braces
Doesn't make a difference on my end, I compiled it both ways, and that's all that the prof gave in the assignment. I know this isn't homework help general, but this is bugging the fuck out of me.
>>
I'm going to write a language called Cobalt just so idiots confuse it with COBOL. wwww
>>
File: ariana.can.not.wait.anymore.png (402KB, 519x753px) Image search: [Google]
ariana.can.not.wait.anymore.png
402KB, 519x753px
>>56360440
>>56360445
Bananas?
>>
>>56364962
size_t is unsigned, so array[0] - array[1] is not -1, but quite a huge number, therefore that if evaluates to false
>>
why is imperative syntax so disgusting
>>
>>56364997
>>56364945
1 - 2 is -1
-1 is then promoted to size_t, an unsigned type
-1 becomes SIZE_MAX (2^64 - 1, probably)
Obviously this is greater than sizeof(array) (16, probably)
else is executed
>>
>>56365066
>>56365068
Ahh, OK. Thanks for the help.
>>
>>56365067
>Imperative syntax
That doesn't even make sense.
>>
>>56365068
Fucking hell, why is that promotion allowed
>>
>>56364997
sizeof returns a value of type size_t, which is usually an unsigned integer (the width is implementation dependant but usually the largest size on the machine like 32-bit/64-bit). When doing comparisons between signed and unsigned, signed is converted to unsigned, and -1 in unsigned is the largest value.
>>
Moderm C++ is comfy

Prove me wrong
>>
File: C++ in a nutshell.png (72KB, 1016x98px) Image search: [Google]
C++ in a nutshell.png
72KB, 1016x98px
>>56365104
>>
>>56364966

ok i think i got it. Rate my code

vector<string> strings;
string x;
int counter = 1;
while (cin >> x)
strings.push_back(x);

for (int c = 0; c < strings.size(); ++c) {

for (auto& i : strings[c])
i = toupper(i);

if (counter % 8 == 0){
cout << strings[c] << "\n";
}
else {
cout << strings[c];
}

++counter;

}
>>
>>56365104
Capture a string into a closure by move.
>>
>>56365084
The promotion is because it's not guaranteed for the unsigned integer to be small enough to fit in it's signed counterpart (unsigned is double the capacity of signed). The standard used to have it that they both were converted to signed, but the comittee changed it and it's probably because it's easier for the people who write compilers
>>
>>56365111
Is that typical C++ or just a more clusterfucky example of it?
>>
>>56365133
In my opinion, all lossy or wrapping conversions should be explicit. That's a huge footgun otherwise, changing the type of a value can radically alert program behavior rather than just throw an error.
>>
>>56365150
Yes and yes.
>>
>>56365150
You'll probably have to do something like that at least a few times in any large project.

Not "standard", but not super rare.

C++'s worst mistake was special-casing constructors. 90% of the time construction might fail and I want to return a ErrorOr<T>, or I want a unique_ptr instead of a bare heap pointer but I also want a private constructor, etc etc.
>>
>>56365120
I don't know sepples
but that looks about right

here's my c
#include <stdio.h>

int main () {
int c,i=1;
for (; (c=getchar()) != EOF; i++)
(i%8) ? putchar(c) : printf("%c\n",c);
return 0;
}
>>
>>56365150
That's just a really extreme snippet of code. You'll likely run into having to do something ridiculous like that every now and then but it's usually pretty niche and you don't have to interact with it much in other parts of your codebase.
>>
C:
char a='a';

Java:
CharacterCodeCalculator characterCodeCalculator = new CharacterCodeCalculator(CharacterCodeCalculator.Encoding.UTF16);
UTF16EncodedCharacter characterRepresentingTheLetterA = new UTF16EncodedCharacter(characterCodeCalculator.calculateFromOneCharacterLongStringOfUTF16Characters("a"));

Which is better?
>>
>>56365330
Honestly, lack of Unicode support is so fucking annoying that I'll give it to Java in this case.

Correctness is more important than elegance
>>
>>56365367
UTF16 is the most retarded way to do Unicode
>>
>>56365390

Says you.
>>
>>56365268
#include <stdio.h>

int main()
{
for (int i = 1, c; (c = getchar()) != EOF; ++i)
printf("%c%.*s", c, !(i % 8), "\n");
}
>>
>mpv binary is 1.8mb
hard on acquired
I wrote a program to download 4chan thread images in haskell and it was 4.74mb
>>
>>56365394
Yes, and everyone else who isn't a retard
>>
>>56365394
>Twice as big as UTF-8 for English text
>Still a multibyte encoding, so one 'char' isn't a character
The worst of both worlds.
>>
>>56365367
wchar.h?
>>
>>56365400
akarin mod detected
>>
>>56365390
Agreed, but it is better than nothing. UTF-8 is much more practical, generally speaking. 90% of everything still gets single bytes, and overhead isn't bad for the rest.
>>
>>56365441
My C isn't that archaic.
I do stick with C89 tho.
>>
>>56365440
Not what was written.
>>
>>56365441
What?

>>56365458
Why the hell would you do that? C has evolved a lot since then.
>>
>>56365458
post a good archaic c you wrote
>>
>>56361724
Use Hoogle

https://www.haskell.org/hoogle/?hoogle=FilePath%20-%3E%20IO%20%28%29

There's a touchFile function, but it looks like it will only work on posix-compliant systems
>>
>>56365458
Is C89 the one where you have to forward declare everything?
>>
>>56365496
Yes
>>
>>56365499
How does your masochism impact your relationships?
>>
>>56365514
I'm not the idiot who uses C89. I usually use C11.
I just answered your question.
>>
>>56365496
If by functions you always have to forward declare those.

If by variables yes, not just forward declare but they HAD to be declared at the start of their scope. most compilers have extensions that don't care about those rules.
>>
>>56365524
Sorry.
>>
>>56365268
That's printing a newline after every eight characters, not after every eight strings, which is what was desired.
>>
NEW THREAD!

>>56365584
>>
>>56365120
you could print strings[c] every time, and use that if only to print newline
>>
is k&r c really a bad idea in the modern age?
>>
>>56365588
I hate you.
>>
>>56365602
Not really.
You don't have to forward declare your variables like some idiots would have you believe.
>>
>>56365602
yes use C++
>>
>>56365602
Good luck finding a modern compiler that will accept K&R C.
>>
>>56365394
Says anyone with half a brain, you cretin. I can't believe you.

I work hard at my programming job. I have to! I have to keep the fucking Pajeets away, I have to keep a roof over my head. I'm the first one in the office and the last one out. I have the best turnaround in the office. When I get home, I study from 7pm to 3am. I work weekends! My girlfriend cheated on me because I didn't pay enough attention to her! But what's more important, a girlfriend or survival?

And you know what? They're still talking about laying me off, me and everyone else in my office! They are, behind closed doors, they are! I've heard it!

When I was a kid, I told my parents I would be the greatest programmer in the world. With my code I'd make everyone happy. War, starvation... I'll find solutions, I said... What happened to that smiling boy?

I can't believe you. I can't. People like you, and my managers, who don't think I'm worth anything. With everything I do and have done, you still don't. UTF16 IS the most retarded way to do Unicode, and I've earned the right to say that and to have you believe it!
>>
>>56359857
See: Selenium
>>
>>56365626
i've heard sepples is a clusterfuck and a very bad language that didn't acomplish what it set out to do
for those reasons, think sepples isn't a good idea to learn
thanks for the input though
>>
>>56365638
What is K&R C?
The C described in the first edition?

Because GCC accepts old-style function declarations.
>>
>>56365691
nope
non-ansi c will throw erros
>>
>>56365691
>The C described in the first edition?
Yes. Pre-standard C.

>Because GCC accepts old-style function declarations.
That is still part of the current standard.
There is more to it than that, though.
>>
>>56365678
people say every language is bad

they say it about java too

they say it about C too

everything is shit but really i think C (especially K&R C) is outdated and you can still use your own flavor of C++ like "C with classes/namespaces"
>>
Ive been really annoyed with my cli programs breaking when I try to take in an integer. Like how do I make it idiot proof. If you enter a character or string when I ask for an integer it craps out. Should I take in a character instead and cast that to an integer. Not sure if it will work or if theres a more elegant solution.
>>
>>56366083
You're basically one step above hello world programs.
This is homework-tier shit.
Learn what ASCII is.
>>
>>56366145
lol Im way past hello world. I have a cs degree. But guess what. They literally never teach you this which has always bothered me. Its irrelevant for gui's though.
>>
>>56366181
So you're pretty much admitting that your """"degree""" is completely worthless?

You can't even do basic input validation?
>>
File: Attractor 2016-08-31 22-37-12-85.png (906KB, 1920x1080px) Image search: [Google]
Attractor 2016-08-31 22-37-12-85.png
906KB, 1920x1080px
Haven't done any real programming in a long time. Thought i'd update some old programs. This one draws chaotic maps.

>>8312198

Source code if anyone wants to mess around with it:
https://mega.nz/#F!8llHnYZL!gWl-CwNddQFq5uVaPlltNg

I'd suggest modifying it to do more than 2 dimensions and also greater than order 2 equations like quartic or quintic.
>>
>>56364962
sizeof array = sizeof pointer.
>>
>>56366195
You mean throwing errors. Thats an extremely inelegant solution and should always be avoided. Im sure though with your """"""degree"""""" you probably just set it to some global variable.
Im looking for an elegant solution. If you dont have one dont waste my time.
>>
>>56366249
>throwing errors
Hi pajeet.
>>
>>56366282
Im just going to assume you are an idiot who only programs in python.
>>
>>56366181
lmfao if you aren't 100% retarded you should be able to figure it out on your own even with newbie tier programming proficiency
>>
>>56365066
it's an array of ints so it's signed
>>
>>56366370
Sure thing.
>>
>>56365598

didnt work, i think i need an if AND and else, otherwise it wont break after 8 words
>>
>>56366423
check the disassembly
there's an JA instruction, which cleary means that the result is treaded as UNSIGNED
>>
>>56366514
alright then, it makes more sense to go from signed to unsigned for the comparison than the other way around, i just didn't have the conversion rules in my head. mixing unsigned and signed isn't something you should do very often anyway, anon wasn't doing it on purpose, he should have cast the sizeof to signed int
>>
File: Attractor 2016-08-31 22-52-07-38.png (528KB, 1920x1080px) Image search: [Google]
Attractor 2016-08-31 22-52-07-38.png
528KB, 1920x1080px
Can someone help me with how to calculate Lyapunov exponent? There is example here:

http://sprott.physics.wisc.edu/fractals/booktext/sabook.htm

But I cannot read BASIC.
>>
1000 REM TWO-D MAP SEARCH
1060 OMAX% = 2 'Maximum order of polynomial
1070 D% = 2 'Dimension of system
1100 SND% = 0 'Turn sound off
1520 Y = .05
1550 XE = X + .000001: YE = Y
1590 XMIN = 1000000!: XMAX = -XMIN: YMIN = XMIN: YMAX = XMAX
1720 XNEW = A(1) + X * (A(2) + A(3) * X + A(4) * Y)
1730 XNEW = XNEW + Y * (A(5) + A(6) * Y)
1830 YNEW = A(7) + X * (A(8) + A(9) * X + A(10) * Y)
1930 YNEW = YNEW + Y * (A(11) + A(12) * Y)
2140 IF Y < YMIN THEN YMIN = Y
2150 IF Y > YMAX THEN YMAX = Y
2240 IF D% = 1 THEN XP = XS(I%): YP = XNEW ELSE XP = X: YP = Y
2250 IF N < 1000 OR XP <= XL OR XP >= XH OR YP <= YL OR YP >= YH THEN GOTO 2320
2300 PSET (XP
YP) 'Plot point on screen
2410 IF ABS(XNEW) + ABS(YNEW) > 1000000! THEN T% = 2 'Unbounded
2470 IF ABS(XNEW - X) + ABS(YNEW - Y) < .000001 THEN T% = 2
2520 Y = YNEW
2660 CODE$ = CHR$(59 + 4 * D% + O%)
2680 M% = 1: FOR I% = 1 TO D%: M% = M% * (O% + I%): NEXT I%
2910 XSAVE = XNEW: YSAVE = YNEW: X = XE: Y = YE: N = N - 1
2930 GOSUB 1700 'Reiterate equations
2940 DLX = XNEW - XSAVE: DLY = YNEW - YSAVE
2960 DL2 = DLX * DLX + DLY * DLY
2970 IF CSNG(DL2) <= 0 THEN GOTO 3070 'Don't divide by zero
2980 DF = 1000000000000# * DL2
2990 RS = 1 / SQR(DF)
3000 XE = XSAVE + RS * (XNEW - XSAVE): YE = YSAVE + RS * (YNEW - YSAVE)
3020 XNEW = XSAVE: YNEW = YSAVE
3030 IF DF > 0 THEN LSUM = LSUM + LOG(DF): NL = NL + 1
3040 L = .721347 * LSUM / NL
3110 IF D% = 1 THEN YMIN = XMIN: YMAX = XMAX

This is the code for 2d quadratic map. Can someone help translate this BASIC to C?
Thread posts: 338
Thread images: 35


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