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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 314
Thread images: 32

File: dpt programming club.png (890KB, 1550x1123px) Image search: [Google]
dpt programming club.png
890KB, 1550x1123px
old thread: >>60765457

What are you working on, /g/?
>>
Remember to use foldMapM wherever possible!
>>
File: 192.png (217KB, 600x600px) Image search: [Google]
192.png
217KB, 600x600px
reminder to always fold your maps so they fit in your car
>>
>>60770391
>and if you question the usage of python you're treated like an ANSI C purist weirdo
But C and Python are the only good languages.
>>
>>60771277
>not using mzipfoldMapAWith
>>
>>60771277
That's too vague.
>>
>>60771285
>But C is the only good language.
ftfy
>>
>>60771297
What could possibly be vague about it?
>>
File: dlang_chan.jpg (70KB, 349x368px) Image search: [Google]
dlang_chan.jpg
70KB, 349x368px
Threadly reminder that dlang-chan has RAII; she's quite fast in execution and compilation; and she's super duper cute! Say something nice about her, /dpt/!
Also, Andrei's a cool guy.

>Tour
http://tour.dlang.org/
>Books
https://wiki.dlang.org/Books
>GC
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
https://wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes
>>
>>60771321
Did they finally remove GC cancer?
>>
File: smug_ran8.jpg (571KB, 1111x857px) Image search: [Google]
smug_ran8.jpg
571KB, 1111x857px
>>60771277
Let f be the foldMap map in Hom(Hom(V),Hom(W)) of maps on the sets of types V and W, does there exist a foldMapMap g such that g maps f to g(f) such that g(f) is the foldMap map in Hom(Hom(f(V)),Hom(f(W))) between the sets of types f(V) and f(W)?
>>
>>60771321
What is your major malfunction?
>>
>>60771252
Not programming but I'm trying to make an ISO of Gentoo which has linux-libre and no non-free software.
>>
>>60771332
There is nothing wrong with GC
>>
>>60771333
Certainly not in Hask!
>>
>>60771345
No, but from a language that is supposed to be a better C++ it is cancer.
>>
File: 1493563407630.jpg (78KB, 640x640px) Image search: [Google]
1493563407630.jpg
78KB, 640x640px
What's a good book about low level computer/programming stuff? Getting caught out by my lack of understanding with Floating Point numbers and shit like that.
>>
>>60771252
Working on a fitbit android app with 4chan integration
>>
>>60771332
Read the links I provided, please.

>>60771335
I'm gay.
>>
>>60771361
It already is a better C++ by design
>>
>>60771356
What is a ``Hask"?
>>
File: 2297881.jpg (22KB, 400x400px) Image search: [Google]
2297881.jpg
22KB, 400x400px
>>60771431
>>
File: lol.jpg (9KB, 289x175px) Image search: [Google]
lol.jpg
9KB, 289x175px
>>60771431
>he doesn't know what Hask is
>>
>>60771454
I know what """Hask""" is, but that doesn't seem appropriate to mention when discussing category theory.
>>
>>60771464
evidently you don't
>>
>>60771469
Why would someone mention a non-category when discussing category theory?
>>
Ran is worst touhou
>>
>>60771484
Plenty of category theory concepts aren't categories.

Hask is a category.

Aren't you embarassed
>>
>>60771495
Stop that, I won't allow anyone badmouthing my smart and beautiful wife.
>>
foldMap is blowing my mind. I have a new understanding and respect for monoids.
>>
>>60771496
>Hask is a category.
Not with seq being part of the language.
Link me to a formal proof of it """being""" a category. I'm pretty sure it would be impossible without the language actually having an operational semantics.
>>
>>60771292
Ok, here's what I came up with quickly, native Python, no modules. Obviously not impressive, but now I can import my own interleave function when needed:
def interleave(lst1, lst2):
lst =[i for pair in zip(lst1, lst2) for i in pair]
if len(lst1) > len(lst2):
lst.extend(lst1[len(lst2):])
elif len(lst2) > len(lst1):
lst.extend(lst2[len(lst1):])
return lst

>>> interleave([1, 2, 3], list(range(10)))
[1, 0, 2, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9]
>>
>>60771535
seq doesn't exist
>>
>>60771262
>You have no argument.
A) Not an argument
B) Yes I do
> imported an entire library to do a trivial task that should be handled in the standard library
>>
>>60771546
Much like """Hask""".
>>
>>60771558
If Hask doesn't exist then Ed Kmett doesn't exist
>>
>>60771550
>that should be handled in the standard library
Shut the fuck up brainlet.
>relying on libraries
See >>60771536
Problem solved, end of discussion.
>>
>>60771527
I know that feeling, anon. Such a simple concept yet it turns up in so many places
>>
>>60771566
Formally prove that it 1) exists 2) is a category.
>>
>>60771572
>Problem solved
>Longest solution so far to a simple task
You continue to prove why Python is objectively the worst language
>>
>>60771585
Here's an informal formal proof:

1) Hask. Therefore Hask exists

2) id and (.)
>>
>>60771536
>i for pair in zip(lst1, lst2) for i in pair
>i for ... in ... for i in ...
what
>>
>>60771593
>Longest solution so far to a simple task
No, the import solution was the shortest, and this code is forever reusable and callable, making it this short:
interleave()

That's one single function - very short.
>>
>>60771632
>the import solution was the shortest
That's not even accurate, as the ruby solution is a single line and the import solution was two.
It's still not part of the standard lib to do a simple and common task, meaning the use that you're going to have to import the library that function now lives in (or outright declare it), so it's moot.

Python lives below only JavaScript for most unnecessary imports.
>>
>>60771623
List comprehension. zip returns pairs as tuples, then for each tuple build a list from its elements.
>>
File: 1494974910515.jpg (362KB, 1453x1879px) Image search: [Google]
1494974910515.jpg
362KB, 1453x1879px
>>60771617
seq undefined 3 => undefined
seq (undefined . id) 3 => 3

Therefore """Hask""" is not a category.
>>
why does /dpt/ hate importing again?
you cant even print a string in C without importing stdio
>>
>>60771321
I preferred the old Dlang-chan.
>>
>>60771687
>print
>io
Get the fuck out of here.
>>
>>60771687
>he believes C has strings
NSA shill pls
>>
>>60771682
https://wiki.haskell.org/Hask#Is_Hask_even_a_category.3F
>>
>>60771687
There's nothing wrong with importing.
There's a some stuff wrong with importing a single function.
There's a LOT wrong with importing a dozen different libraries each for a single function.
>>
File: koakuma_marisa.png (68KB, 268x292px) Image search: [Google]
koakuma_marisa.png
68KB, 268x292px
>>60771714
>category of types
>not even a closed monoidal category
You can't make this shit up bros.
>>
File: 1493615537514.jpg (105KB, 629x473px) Image search: [Google]
1493615537514.jpg
105KB, 629x473px
>>60771714
Not interested in reading a government website. I have just proved it's not a category. Let me know when the language gets fixed though.
>>
>>60771741
>not even
Why should it be?
>>
Is it possible to use 4chanX filter, to filter out all posts that have sentences that don't have punctuation and capitalized words?
>>
>>60771766
That would be neat, I could also filter those who use punctuation like retards.
>>
>>60771658
>meaning the use that you're going to have to import the library that function now lives in
I've never had to interleave a list, so I don't care. Also, there's nothing wrong with importing your own library. I fail to see your point.
>>
>>60771766
if you have to ask you arent a real programer
>>
>>60771773
So you would filter yourself?
>>
File: smug_ran2.png (495KB, 1000x1000px) Image search: [Google]
smug_ran2.png
495KB, 1000x1000px
>>60771755
If your language is based on the mantra "everything are just functions!!! xddd" then the category of types based on your language better be closed and monoidal, or that's a direct contradiction.
>not closed => not everything are functions
>not monoidal => not everything behaves like functions
What the fuck were Shitkellers doing? This is a catastrophe.
>>
>>60771780
I'm not that good at regex. Give me a hint.
>>60771773
Yeah, plebbit spacing posts would be nice to ignore too.
>>
>>60771713
all languages have strings
even if your hard drive had no software on it and only stored one big text file it would have strings
>>
>>60771785
>What the fuck were Shitkellers doing?
Pretending to understand at least the very basics of category theory. Their kind is known for this.
>>
>>60771785
let me know when you solve the halting problem so we can rewrite the whole language
>>
>>60771785
Not everything is a function you dumbass, that would be far too slow
>>
>>60771779
>Every other language made after 1983 has the ability to do this baked in
>Python, touted as the king of "you just write it and it happens!", has to import an entire library or makes you write the function from scratch
>>
>>60771687
Yes you can but you have to import unistd
>>
File: 1493359837519.png (539KB, 617x615px) Image search: [Google]
1493359837519.png
539KB, 617x615px
Is Trashkell truly the worst and most broken language currently available besides OOP trash?
>>
>>60771810
you can import a single function from a library easy enough
i hate python but "import" is not a reason to dislike it
you negative shitposters are really anoying you know that
you dont even know why you hate the word import its just a cargo cult
>>
File: smug_ran6.jpg (114KB, 802x1240px) Image search: [Google]
smug_ran6.jpg
114KB, 802x1240px
>>60771799
Yeah don't worry, I'll be investigating non-Abelian qubits soon and hopefully we can make a quantumsupercomputer that solves the classical halting problem.
>>60771808
That's literally what functional programming is you stupid dick.
>>
>>60771830
>That's literally what functional programming is you stupid dick.
If you think functional programming means that everything has to be a function, then you're a retard
>>
>>60771824
Haskell is the worst language, apart from all the other languages
>>
>>60771830
What are your plans for solving the quantum halting problem?
>>
>>60771824
haskell is the only non-oop language worth using
>>
File: 1494448634847.jpg (72KB, 553x746px) Image search: [Google]
1494448634847.jpg
72KB, 553x746px
>>60771846
Why would you be using a language with a broken and crippled type system if you have an above average IQ?
>>
File: progchal.png (305KB, 1920x1080px) Image search: [Google]
progchal.png
305KB, 1920x1080px
Rolling
>>
>>60771857
L I B R A R I E S
>>
>>60771857
you have a weird definition of broken and crippled
>>
>>60771843
Dunno lol I just like making you CScucks lose your jobs.
>>
>>60771857
haskell is fun to program in because haskell is the best language
>>
>>60771871
Anything less expressive than the CoC (which is itself the bare minimum) is crippled trash.
>>60771873
This is wrong.
>>
>>60771872
>losing jobs
>based on the imaginings of an anime-posting furry using something even more useless than haskell
I think we're safe, lads.
>>
>>60771785
>>60771808
>>60771830
>>60771837
But everything really is a function at the most basic level in any language.

In assembly everything is a function. Just pick an address and call it.

Of course, not everything is a function that WORKS, but that's a different story
>>
masturbating to loli and watching movies / erping with faggots
>>
>>60771911
functions don't exist in assembly
>>
>>60771872
Keep fighting the good fight, we're few in numbers it feels like.
>>
>>60771794
This is what I have so far. Let's test it.

^[a-z]
>>
>>60771918
Yeah they do. That's what the call and ret instructions are all about. And also the stack.
>>
File: 1495309590450.jpg (33KB, 393x279px) Image search: [Google]
1495309590450.jpg
33KB, 393x279px
>>60771914
>>
I thought avatars were against the rules
>>
https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/
>>
>>60771926
Fuck it doesn't work. Come on guys, someone help me out.
>>
File: dlss3ysrqnd6sjjmxaji.jpg (914KB, 1920x1080px) Image search: [Google]
dlss3ysrqnd6sjjmxaji.jpg
914KB, 1920x1080px
>>60771957
>>
>>60771810
I import maths functions I've defined all the time. Should I be complaining, like you, that these functions aren't standard? I can bet that no language has a farey_neighbours() function in the standard library. By your logic, this makes a language unusable. You're still going on with completely asinine arguments, while I can simply import interleave() and be done. There is no argument here.
>or makes you write the function from scratch
Is this supposed to be a problem? And see above: your logic fails when a given function isn't standard in any language, which is most functions.
>>
filter this regex
>>
>>60771965
is this supposed to impress people?
>>
>>60771687
/dpt/ hates everything.
>>
>>60771965
dlang-chan is unstoppable!
>>
>>60771918
Interesting, my RegeEx did not filter this comment but did filter this. Anyone know why?

>>60771995
>>
round two regex. let's try this. OH I think I know why it won't work.
>>
>>60771965
Nice. D keeps getting better.
>>
>>60771918
I've figure it out lads. My regex won't filter this retarded comment because of the post link. Someone help me.
>>
>>60771929
am I under arrest ms. loli officer?
>>
>>60771867
Is this roughly organized by difficulty?
>>
>>60772077
Damn straight you are, you dirty lolicon.
>>
>>60771867
Can any of these be put on github? Or are they babies-first-project-tier, aka fizzbuzz tier?
>>
>>60772128
You can put anything on Github my dude
>>
>>60772067
>Someone help me
>But I'm not gunna share any information about anything I've written with you
>>
>>60772119
are you going to cuff me and do a body search?
>>
>>60772128
There's no reason you couldnt put every one of those on github.
>>
>using 'using' in C++ is bad practice, due to the nature and functionality of the pre processor
What the fuck is wrong with this language?
>>
>>60772160
C++ is a horrible meme. You shouldn't use it for any purpose.
>>
>>60772175
>meme
>>>/v/
>>
>>60772150
It's a regular expression that filters posts that don't capitalize the first letter of sentences. That one just looked at the very first sentence of a post.

^[a-z]
>>
>>60771901
>>60772150
>>60772160
>>60772179
Who said this?
>>
I'm currently learning solidity so I can create a Dapp for Ethereum
>>
>>60772153
Me? Touch you? You have quite the sense of humor for a pile of trash. One of my junior officers will be doing that--with gloves. So don't get your hopes up, scum. And don't try anything either, she might be eight, but her foot has a tendency to ram into sacks.
>>
>>60772282
wew, hope you find the right antidepressants for you buddy
>>
>>60772260
You're wasting your fucking time you piece of shit it's an undeveloped piece of shit language
>>
>>60772297
/dpt/ is my antidepressant.
>>
>>60772314
you should up the dose then
>>
>>60771867
roll
>>
>>60772160
>what's wrong with this language?!
So much anon. It can't be understated. Even new features are plagued by issues.

They just don't give a fuck. Avoid C++ if you can.
>>
It's 1 am here and I'm so fucking tired, but I'm trying to figure out how to calculate what percent of a matrix I've completely gone through.

Like

int percent = 0;

for (int r = 0; r < thing.Width; r++) {
for (int c = 0; c < thing.Height; c++) {
percent = Math.Ceiling(/*CALCULATE PERCENT HERE*/ * 100);
}
}
>>
>>60772522
anon go to sleep
(100 * (r + c * thing.Height))/(thing.Width * thing.Height)
>>
>>60771252
I don't get this meme at all.
>>
>>60772548
Fuggg I've been trying to write that exact line for a half an hour now thank you
>>
>>60772579
>meme
Use >>>/v/
>>
https://news.ycombinator.com/item?id=14490333
>>
>>60772676
>>>/trash/
>>
>>60772579
I made that OC anon you're insulting me
>>
>>60772755
You should be insulted and you should feel bad for being faggot.
>>
>>60772579
You'll understand when you become a master programmer
>>
>>60771252
why is this left to right?
>>
>>60772762
Liking feminine penisises isn't gay. I quite frankly have an amazing life making an amazing amount of money right now so if the trap memes are what did it I'm gonna keep shitposting

>>60772770
Exactly
>>
I have a list of IO actions that each may return a result. I want to execute them in order and stop as soon as I get a result. For example, here I ask the user for an int 5 times and print the first int they input.

bs :: [IO (Maybe Int)]
bs = replicate 5 (readMaybe <$> getLine)

test = do
b <- foldMap (fmap First) bs
print b

However, as written, this will always ask an int 5 lines. I want it to break as soon as it gets a valid int. I know this is possible like this:

doIt :: [IO (Maybe Int)] -> IO (Maybe Int)
doIt (a:as) = do
result <- a
case result of
Just r -> return (Just r)
Nothing -> doIt as
doIt [] = return Nothing

test2 = do
b <- doIt bs
print b


but is there anything more idiomatic?
>>
Been trying to learn C for about two weeks now and I still fail to grasp even the most basic stuff. [spoiler]Should I just pack it in and give up?
>>
>>60772837
What don't you get?
>>
>>60772676
Now this is a sensible person.
>how do you know the 'great culture' is for assumedly white dudes (what does that mean even, white dude is not some singular set of human traits)?
>I'm female, I've been the first and the only woman on teams. I don't give a crap about it. I do my job and expect my colleagues to do the same.
>Any place with crap culture is crap culture for almost everyone, no matter gender-identity or race.
>I look for places where the employees are passionate and care about what they're doing. Somewhere where code reviews are neither combative nor do they roll over and let things through. Basically somewhere I'll be working to be better for both me and for my colleagues.
>Maybe that's something you could ask about. How are code reviews handled, how are implementation disagreements handled. Ask for stories about the last time something fell over. How do they handle call outs, all those stressful situations that people often like to brag about. How someone brags can tell you if you want to work with them or not.
>>
>>60772808
I wasn't paying attention when I made the edit. Usually I browse manga in a webrowser so I imagine the pages laterally like the forward and back button. My bad. I still have the xcf file so I could swap them and fix the crop a bit
>>
>>60772836
>IO
Stopped reading right there.
>>
>>60772836
https://hackage.haskell.org/package/monad-loops-0.4.3/docs/Control-Monad-Loops.html

untilJust (readMaybe <$> getLine)
>>
>>60772859
This is very close but it doesnt limit it to 5 times. Also, I would like to be able to do different actions. For example, read from memory, if that fails, read from a file, if that fails ask the user, if that fails, supply a default.
>>
>>60772676
>The JS job market in STL just isn't cutting it for me
>The JS job market in STL
>JS
>STL
wtf?
>>
>>60772900
>>60772859
asum from Data.Foldable does what I want. Thank you for that module though, it is very interesting!
>>
>>60772900
you could write it yourself for now

perform [] = pure Nothing
perform (x:xs) = do
v <- x
maybe (perform xs) (pure.Just) v
>>
File: ttt.png (43KB, 444x387px) Image search: [Google]
ttt.png
43KB, 444x387px
My first ever piece of code.
It's not much,
it's not good,
but I feel so powerful.

kek.
>>
>>60772947
no wait, it doesnt .... fuck
>>
>>60772950
I suggest you never come to /dpt/ and keep learning. This thread will give you many bad advices. The oldfags of /dpt/ left a long time ago and this thread is infested with weebs and unemployable autists
>>
>>60772950
>py
>>
File: C72kq4SVsAEg_NS.jpg-large.jpg (125KB, 1080x1080px) Image search: [Google]
C72kq4SVsAEg_NS.jpg-large.jpg
125KB, 1080x1080px
I'm trying to define a 3d array for a class, but I don't know the required dimensions until the class is constructed. However I know the upper bounds of the array.

I attempted to define the array in the constructor but it appears I am unable to do that.

What would the best method be to implement this structure?

Working in C++ btw
>>
>>60773004
which of the 3 standard libraries of C++ are you using?
>>
>>60773010
std::beta, also known as boost.
>>
>>60772841
Been stuck trying to figure out how arrays work for two days now. Particularly on an exercise in the K&R book.
>>
File: yande.re-321491.jpg (973KB, 1212x2172px) Image search: [Google]
yande.re-321491.jpg
973KB, 1212x2172px
>>60772990
There have always been "weebs." (You're using it incorrectly, newfag-kun.) This is an anime website.
>>
>>60773022
What don't you understand about arrays? Quite often newbies get confused about the relationship between arrays and pointers.
>>
>>60773010

C++11 , but I believe the program has to be able to compile on C++98
>>
>>60773051
I haven't even gotten to pointers yet. Basically, how to do this.

Exercise 1-14. Write a program to print a histogram of the frequencies of different characters in its input.

I've been trying to figure it out, and I don't wanna Google or ask for help yet. I'm thinking of starting the book from the beginning again to see if I missed anything or picking up an easier book.
>>
>>60772906

I think STL is referring to a location, not the Standard Template Library of C++. If I had to guess... St. Louis?
>>
>>60773004
Easiest way would be vectors. They're pretty low overhead but if that's a problem do it the old school C way. A 1 dimension array of ints is a pointer to the first int. An array of arrays is a 2 dimensional array so you make an array to pointers to a pointers to ints. Add one more layer and you're up to three dimensional.

So say you need a three dimensional array of ints with dimensions i j k. Create a variable of type int***. Use new to create an array of i int**s and have your int*** variable point to it. Then for each int** in that array use new to allocate a block of j int*s. For every int* that you just created allocate an array of k ints. Now you have a dynamically allocated ixjxk array of ints. Make sure you delete them. Only do this if you have a good reason not to use vectors like if your class doesn't want you to use STL.
>>
>>60773123
The trick to that question is that you need to realise that characters are just numbers, and you can use those numbers to index an array.
>>
>>60772836
Pretty sure that's just a right fold
>>
>>60772836
To clarify, doIt = foldr (\x r -> x >>= maybe r (return . Just)) (return Nothing)
>>
>>60773123
I'm there too lol. Will do it when I get home, but it's like with exercise 13.

how i would do it:

- make size_t array[ALPHABET_LENGTH]
- set everything in array to 0 (for loop or ={0})
- read input save the length
- when ' ' or '\n' ... is read then add to array[saved_length]++
- then draw the histogramm

you can think of the array
array[index]
like this
counter[letter_in_alphabet]

Don't get discouraged when you have long for the exercises. It's ok.
>>
>>60773479
>- read input save the length
>- when ' ' or '\n' ... is read then add to array[saved_length]++
You can do this character-by-character. There is no need to read an entire line in before counting the characters.
>>
test
>>
>>60773571
I'm pretty sure it didn't work.
>>
>>60772836
In lisp, this is just
(loop :repeat 5 :as int = (read-line) 
:thereis (parse-integer int :junk-allowed t))
>>
>>60773637
Better version.
(loop repeat 5 thereis (parse-integer (read-line) :junk-allowed t))
>>
File: colour.png (5KB, 232x317px) Image search: [Google]
colour.png
5KB, 232x317px
I'm messing around with C#'s RichTextBox's but can't seem to make it work right.

So I've got a simple program where after I press a button it loops through 0-99,999 then prints it all to the richtextbox once it's done (as a single string).
Sounds simple enough but I'm trying to colour the text as well and the text doesn't completely colour (pic related), it just stops at a certain point.

The printing/colouring code is pretty simple,
rtfMainBox.SelectionColor = Color.Blue;
rtfMainBox.AppendText(text);

According to SelectionColor documentation if there's no selection then everything afterwards should be coloured correctly until the selection is changed, so I don't think it's that.

And it doesn't seem to be a graphical problem since the RTF is matching the colouring.
{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\cf1\f0\fs17 0\par
1\par
2\par
3\par
...
(etc etc etc)
...
2230\par
2231\par
\cf0 2232\par
2233\par


Does anyone know why it's stopping at that point? It usually stops at the same number, is there some limit to the amount of text that can be coloured or something?
>>
File: shitmeme.png (35KB, 617x476px) Image search: [Google]
shitmeme.png
35KB, 617x476px
working on a shit text based single player dnd esque game. it's shit but my friend and I are learning python so fuck it.
>>
>>60773772
I hope you are using classes
>>
>>60773772
I hope you are not using classes
>>
>>60773772
Nothing says immersion like ironic shitposting in my """"""game"""""
>>
File: moreshit.png (78KB, 948x894px) Image search: [Google]
moreshit.png
78KB, 948x894px
>>60773805
Yeah, so far we have this player class and some bogus functions. Is there a more efficient way to initialize the class attributes (?) and assign values to them?
>>
>>60773823
Don't take yourself or this too seriously
>>
>>60771252
    static boolean anyDuplicatesInSudoku(char[][] grid){
if (grid[0][0] ==grid[0][1] == grid[0][2]== grid[0][3]== grid[0][4]==grid[0][5]==grid[0][6]==grid[0][7] ==grid[0][8] && grid[1][0] ==
grid[2][0]==grid[3][0]==grid[4][0]==grid[5][0]==grid[6][0]==grid[7][0] ==grid[8][0]&&grid[1][1]==grid[1][2]==grid[2][1]==grid[2][3]){
System.out.println("haribo");
return true;
}
System.out.println("Macht kinder froh");
return false;

}


Error: incomparable types char and boolean.

Wat do?
>>
>>60773856
Yeah, it seems to me there would be better ways to do it.
But I don't know Python.

Also, why aren't the jobs classes themselves.
Then you can make some specific jobs instances like those, and just compare it using a method.
>>
>>60774005
>grid[0][0] ==grid[0][1] == grid[0][2]
Pretty sure you can't do taht, have to do
>grid[0][0] ==grid[0][1] && [other stuff]
>>
>>60771867
roll
>>
>>60774005
Why not use a for loop?
>>
File: 1492559191171.png (165KB, 400x362px) Image search: [Google]
1492559191171.png
165KB, 400x362px
>>60774005
>grid[0][0] ==grid[0][1] == grid[0][2]== grid[0][3]== grid[0][4]==grid[0][5]==grid[0][6]==grid[0][7] ==grid[0][8]
>>
Lisp newfag here, how do I compare structs and objects that are complex (more than slots)
Am I supposed to make my own function?
>>
>>6077404
Will consider, ty anon
>>
>>60774089
because I am a retard.
No really, I am lacking sleep and have no money for enough coffee to get it done. So I am gonna slap some shit together that still works.
>>
>>60774046

Oops, >>60774133
>>
meme
>>
>>60773690
pls respond
>>
>>60773142
What about data locality? Wouldn't it be better if you allocated a single array with size of width height and length and accessed it like this: arr[x + y*width + z*(width*height)]?
You could even write a class to wrap it. I believe your method involves a lot of pointer dereferencing and has thus slower access time and slower allocation and deallocation times.
>>
>>60774182
no
>>
File: c-rust-rewrite.png (163KB, 600x382px) Image search: [Google]
c-rust-rewrite.png
163KB, 600x382px
Why haven't you rewritten your favourite open source project in Rust yet?
>>
>>60774112
Do you have a particular scenario in mind
>>
>>60771282
>you are like a little baby
>>
>>60774212
Because i dont hate myself enough to use meme languages.
>>
File: Safety_First.png (99KB, 578x1055px) Image search: [Google]
Safety_First.png
99KB, 578x1055px
>>60774212
>Rust is safe
>>
>>60774209
pls
>>
>>60774212
Rust is a literal meme. You rile up all of the stupid fucks at places like Reddit and Hackernews who know absolutely nothing about programming, and then they shill this shit everywhere.
>>
    static boolean anyDuplicatesInSudoku(char[][] grid){
if ((grid[0][0] ==grid[0][1] || grid[0][2]== grid[0][3]|| grid[0][4]==grid[0][5]||grid[0][6]==grid[0][7] ||grid[0][8] == grid[1][0] ||
grid[2][0]==grid[3][0] || grid[4][0]==grid[5][0] || grid[6][0]==grid[7][0] || grid[8][0]==grid[1][1]||grid[1][2]==grid[2][1]|| grid[2][1]==grid[2][2])){
System.out.println("haribo");
return true;
}
System.out.println("Macht kinder froh");
return false;

}


Now I just need to manage to ignore the empty '.' fields.
>>
>>60774251
What is this image supposed to demonstrate?
>>
>>60774291
Please just use the fucking for loop. Your code is not functional and utterly stupid
>>
>>60774302
That you don't know what an integer is
>>
>>60774289
T b h people on reddit and hn know more about programming than /g/. I mean, at least most of them have actual jobs.
>>
>>60774291
Dreck.
>>
>>60774337
>job equals competency
my favorite meme
>>
>his language can't do this
5.times { puts "Hey" }
1.upto(4) do |i|
puts "I am at number #{i}"
end
>>
>>60774326
It's manga, doofus.
>>
>>60774321
Care to elaborate? I see nothing wrong with neither the code nor the result.
>>
>>60774367
It's overflowing
>>
>>60774352
>I'm to intelligent too have a job
What a coincidence, this is my favorite meme.
>>
>>60774361
What language can't do this?
>>
>>60774380
>It's overflowing
So? Integer overflow is well-defined in Rust.
>>
>>60773690
With some more testing I can force the colour to change with richtextbox.Select(start,length), colouring it then deselecting it but that's fucking ugly. Surely there must be a way to apply a colour to all appends.
>>
>>60774383
You mean
>to intelligent too work for somebody else
>>
>>60774212
From what I have seen, Rust is always changing. I don't mind it as a language but I wouldn't use it for much in it's current state. Until it is more developed, I wouldn't write anything more than FizzBuzz in it.
>>
>>60774403
So? Giving you incorrect values of still wrong.
>>
>>60774380
This is why you run your test on release build:
$ ./test
thread 'main' panicked at 'attempt to multiply with overflow', test.rs:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

thread 'main' has overflowed its stack
Segmentation fault

And if you're worried enough, you should use checked_mul and checkde_add. This is still better than any other language t b h, especially "signed overflow is UB" C-tards came up with.
>>
>its not a bug its a feature
The RIDF really need a new script
>>
>>60774459 (You)
>you don't* run
>>
>>60774459
Hopefully you catch it in debug, senpai. Also, how is using special functions to check for overflow in rust any safer than using special functions to check for overflow in C?
>>
>>60774501
The key difference here is overflow in Rust is well-defined:
> The operations +, -, *, can underflow and overflow. When checking is enabled this will panic. When checking is disabled this will two’s complement wrap.
There's not much else they can do, the only alternative is to check all the operation in the release build too, and that would mean a huge hit to the performance.
>>
>>60771867
>roll
>>
>have to enable non-default measures to check for a basic thing
Im glad i knew Rust was trash from the start.
>>
Any languages where integers do not wrap?
>>
>>60774435
And what would the correct value be?
>>
>>60774888
In Haskell, IIRC, Integer type is automatically internally promoted to BigInt representation on overflow. But that's too slow for any practical use.
>>
>>60774888
C, where signed integer overflow is undefined and "does not happen".
>>
>>60774888
No idea. I think it'd be pretty neat for a language to let you specify the wrapping type of a variable though.
>>
>>60774435
>incorrect values
I guess you don't understand integers.
>>
>>60774927
Ruby does this too.
>>
how can I efficiently search through dozens of source code files for a particular word?

I just need to change one word to get this Android app that I enjoy using to work for me again due to an API change that I'm aware of.

Short of opening up every single file and Ctrl+F'ing to find this, I can't figure out a fast way to do.
>>
>>60775037
grep
>>
>>60771362
Try "learning forth" by Leo Brodie, it's free online
>>
>>60775037
CTRL-SHIFT-H in MS Code
>>
I just barely got enough points to pass the peliminary tests.
How do I learn to code better?
I am using codebat already.
>>
>>60774954
If you used any other wrapping type, your int would no longer form a group under addition.
>>
What would be the proper way of making a content editor that can access and set what should private members in C#?
I don't want to edit in a actually deployed build, I want to create and edit content which I save to files and then use in the application as intended.

I'm thinking of making dummy copies with public members of the classes I want to edit but there's quite a few classes I want to edit so that would be a pain.
>>
>>60774888
From what I know, Ruby and Python don't integer wrap.
>>
There should be a prefix in CPU to generate hardware interrupts on integer overflow, t b h.
>>
>>60775316
Thats a terrible idea, desu
>>
>>60775316
>generate hardware interrupts on integer overflow
No, just fucking no.

>user creates malicious program that runs in a loop increment a uint8_t
>start program 2 * core count times
>interrupt DOS everywhere
>>
>>60771252
I have some questions about stuff used in 2d games.

Suppose you have a custom type 2D grid, which contains indices i,j, and a reference to a unit x.
If looking for if a unit is on the grid at i,j, you simply index into it grid[i,j].x
If looking for all the units, it is faster to have a list reference to all the units then looking through all the indices i,j. Now I've heard something about second-order spatial data, is this the same as a sparse matrix?
>>
>>60775335
>>60775339
Why, tho? It's not different than hardware interrupt on division by zero every CPU has. I've googled it and it looks like MIPS and Alpha have it.
>>
>>60775377
Interrupts are already generated on certain overflows. Other overflows are desirable. The CPU can't make a distinction between intended and unintended overflows.
>>
>>60775403
>Interrupts are already generated on certain overflows.
Like what?
>The CPU can't make a distinction between intended and unintended overflows.
This is why I said it should be a prefix, the default behavior should stay the same.
>>
>>60775377
Because youre issuing a software problem to hardware.
>>
File: Fortunes.png (12KB, 1150x171px) Image search: [Google]
Fortunes.png
12KB, 1150x171px
Just starting on C and programming
Unless I put it the srand (time(NULL) ) ; line I always get the same result on my fortune.

I don't actually know what that line of code actually does and would appreciate some help
>>
>>60775418
>Like what?
Like overflowing a floating point, for example.

>This is why I said it should be a prefix, the default behavior should stay the same.
How do you propose setting up this prefix, especially from userspace?

>>60775419
Basically, this.
>>
>>60774784
>it's too hard!
lel
>>
>>60775419
It's "software" problem only because the hardware refuses to do something about it.
>>60775435
>How do you propose setting up this prefix, especially from userspace?
During compilation? You just generate `check add` instead of `add`. Signed overflow is already undefined in C, so it should be no difference if you silently overflow or generate an interrupt.
>>
>>60775429
Seeds your pseudo random number generator.
>>
>>60775429
>I don't actually know what that line of code actually does and would appreciate some help
time(NULL) gives you the current UNIX timestamp (seconds passed since January 1st, 1970, 00:00:00).

You take this result and seed the random function. rand() and other random generators are only pseudo-random. This means that they use a specific algorithm to calculate pseudo-random numbers (look online, there's a bunch of research on how to create pseudo-random numbers). By seeding the algorithm, you get different results.
>>
>>60775429
rand is a pseudo-random number generator. That is, it's not actually random, but it "looks" random.
Each number is generated from the previous number.
The very first number is called the seed, and if you don't set it, it default to 0, so you get the same result every time. srand is setting the seed, and time() is giving you a different value for every time your program is ran.
>>
>>60775429
> rand() % n
You should never do this.
>>
>>60775316
Wouldn't that make every integer operation slower?
>>
>>60775466
>because the hardware refuses to do something about it.
Then you might as well cut out the middleware and forward everything to hardware.
Have fun.
>>
Wew, pseudorandom generators experts in da house!
>>
>>60775493
that's how you get a random number in a certain range though.
>>
>>60774435
it's correct, integer arithmetic is modular.
>>
>>60775500
outdated
>>
>>60775493
It should actually be fine if RAND_MAX is a multiple of n.
>>
>>60775466
>During compilation? You just generate `check add` instead of `add`.
So you mean as in an entirely new CPU instruction?

In theory it could work just fine, in practice you'd have to create a new interrupt number for this, which would then require new interrupt vectors etc. Unless you propose just to use floating point exception (the same as you get when you divide by zero) ?

>Signed overflow is already undefined in C, so it should be no difference if you silently overflow or generate an interrupt.
CPU doesn't care about C, and C doesn't care about CPUs. Which is why signed overflow is undefined.
>>
>>60774435
Retard
>>
>>60775494
Why should it? CPU already detects overflows and sets C flag.
>>60775504
Not signed tho.
>>60775502
The distribution is wrong since the maximum value of rand() isn't a multiple of n. You should use std::uniform_int_distribution instead.
>>
>>60775530
>Why should it? CPU already detects overflows and sets C flag.
Halting execution and generating an interrupt has a vastly higher overhead than simply checking a flag inline.
>>
>>60775316
Fuck no. I use overflow a lot for, for example, for sequencing with 16 bit numbers.
>>
Hey /dpt/, instead of try/catching, why dont we just have a hardware interrupt, lmao.
>>
>>60775612
>Hey /dpt/, instead of try/catching, why dont we just have a hardware interrupt, lmao.

That's actually what happens when you catch segmentation fault or floating point exception though....
>>
>>60774784
>have to enable non-default measures
$cargo run looks pretty fucking default to me.

Rust has other issues, having less safety is none of them
>>
>>60775642
ah yes, those are definitely the same things.
>>
>>60775583
Well yes, but it shouldn't happen, to begin with, so why care about overhead. I mean, it's just like division by zero, you structure your program in such a way that prevents the hardware interrupt.
>>60775586
I'm thinking about signed arithmetic only and unsigned overflow is already UB in C.
>>60775612
This is how division by zero exceptions work tho.
>>
>>60775660 (You)
> signed* overflow is already UB in C.
>>
>>60775657
>having less safety is none of them
Anything remotely useful in Rust requires unsafe though.
Kind of sick of hearing this "Rust is king of safety" meme.
>>
>>60775676
>Anything remotely useful in Rust requires unsafe though
What is """"anything remotely (((useful)))"""""?
>>
>>60775660
>Well yes, but it shouldn't happen,
Arithmetic overflow is allowed and supported on x86, it's just that C can't make the assumption that you're running on x86, so it just says that it's undefined. It's a limitation with C, not with the CPU.

>I mean, it's just like division by zero, you structure your program in such a way that prevents the hardware interrupt.
You could just as easily argue that the C compiler could check register flags on every addition or subtraction to detect overflows.

>>60775658
I'm not sure if you're being sarcastic, but if you are, you should be aware that floating point exception possible to catch as an exception in C++ or as POSIX signals + setjmp/longjmp in C.
>>
>>60775660
>it shouldn't happen
Why not?

>UB in C
Who cares what is and isn't undefined in C? There are other languages, you know.
>>
>>60775676
Rustc and cargo have no unsafes tho, ripgrep has like 5 in low-level stuff.
>>
>>60775684
Porting any big C/++ base for one, which is the main thing rustlets always drone on about.
>>
>>60775694
> Why not?
In the same sense division by zero shouldn't happen, i.e. it happens rare enough for you not to care if it's slow or not.
>>
>>60775713
>signed overflow shouldn't happen
This is only true for the C programming language.
>>
>>60775703
>Big C(ancer)/++ (((base)))
Size doesn't mean the requirement of unsafe{}
>>
>>60775713
Division by zero has no mathematically meaningful result. Integer {addition, multiplication, subtraction} does.
>>
>>60775713
>>60775739
NaN
>>
>>60775739
Depends on the application. Sometimes division by zero is meaningful
>>
>>60775726
>Size doesn't mean the requirement of unsafe{}
More than not, it will though.
Every Rust talk ive seen on porting big bases, they usually skimp over the part about unsafe because it would break the illusion.
>>
>>60775739
Signed overflow isn't mathematically meaningful too, 128+1 =/= -1 in any system.
>>
>>60775752
Name one case.

>>60775748
NaN is basically just a copout for "this value is actually undefined"
>>
>>60775748
NaN isn't an integer in any language I've heard of. If you're talking floating points, isn't it actually Inf?
>>
>>60775752
>Sometimes division by zero is meaningful
when
>>
>>60775761
What illusion?
>>
>>60775767
Where are you getting 128+1 = -1 from? If you're working with 8-bits, shouldn't it be -127?
>>
>>60775786
That Rust is a magic wand that magically turns every port into a perfect code-base of gold.
>>
>>60775798
I don't think anybody is actually making that claim.
>>
>Unsafe meme
Let's at https://github.com/trending/rust?since=monthly:
https://github.com/redox-os/tfs/search?utf8=%E2%9C%93&q=unsafe&type= 12 unsafe
https://github.com/google/xi-editor/search?utf8=%E2%9C%93&q=unsafe&type= no unsafe
https://github.com/jwilm/alacritty/search?p=2&q=unsafe&type=&utf8=%E2%9C%93 16 unsafe
https://github.com/vmware/haret/search?utf8=%E2%9C%93&q=unsafe&type= 2 unsafe
https://github.com/SergioBenitez/Rocket/search?utf8=%E2%9C%93&q=unsafe&type= 11 unsafe
https://github.com/pipedown/noise/search?utf8=%E2%9C%93&q=unsafe&type= 8 unsafe
>>
>>60775798
It'll certainly make a better less stinky pile of shit that it already was.
>>
>>60775770
>>60775773
Lol ok, you don't believe me?

In spline theory, B-splines are often defined recursively. When you evaluate it in certain intervals you may obtain division by zero, signifying that the B-splines on this interval is non-active, and you drop it from the expression.

Taking the limits of certain functions may ask you to find what the evaluation approaches as you divide by zero, with certain specialized rules including L'Hopital for finding these limits in inderminate forms. Do you want more?
>>
>>60775787
Right, my bad, it's -127. Still tho, this doesn't make sense mathematically.
>>
File: 1487463346404.png (295KB, 1772x830px) Image search: [Google]
1487463346404.png
295KB, 1772x830px
>>60774251
Isn't that just wrapping the overflows? What are you trying to prove here?
>>
>>60771252

i want to get into image processing, recommend a good read

pls no bully ;..; im newbie


also is that a boy on the right?
>>
>>60775810
>nearly 50 instances in those 6 examples
>meme
???
>>
>>60775823
In what way does this not make sense? It still follows all of the rules:

(a + b) + c = a + (b + c)
(a + b) - b = a
a + (-a) = a
>>
>>60775814
I can also think of n-order poles for complex analysis, such as used in the residue theorem, removable singularities in holomorphic functions etc.
>>
>>60775848
Typo, should be 0 for that last one.
And also, a + b = b + a
>>
>>60775814
So, what should I get from 3 / 0 as an 8-bit integer?
>>
>>60775848
a > c /\ b > c => (a + b) > c isn't true anymore, and I'd expected it to be.
>>
>>60775767
Signed overflow is an interpretation concept. Registers aren't signed or unsigned, they're just bits you add, subtract, multiply, divide, shift, increment, decrement etc. The whole signed/unsigned thing comes with interpretation.
>>
>>60775879
Why would you expect that from a finite set?
>>
>>60775872
Again, depends on your application.
>>
>>60775814
Approaching zero is not the same as being zero, you're a flaming faggot and you should kill yourself for not knowing elementary number theory.
>>
>>60775899
Actually, you're right, this doesn't hold for modular arithmetics.
>>
>>60775910
He asked if division by zero is meaningful, i provided contexts where it is. It is not my fault you simpleminded mouthbreather is stuck at inputing numbers into formulas instead of analyzing their behaviour near points.
>elementary number theory
hahahahaha
>>
New thread:
>>60775927
>>60775927
>>60775927
>>
>>60771687
/dpt/ is filled with autists
>>
>>60775840
Gonzalez & Woods
Digital image processing
Thread posts: 314
Thread images: 32


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