[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: 317
Thread images: 28

File: acm_table.png (41KB, 361x472px) Image search: [Google]
acm_table.png
41KB, 361x472px
Russians are the best programmers edition

Old: >>55902227
>>
anime
>>
>>55910998
So every time they host it in Russia Russia wins? Not a coincidence.
>>
>>55911009
The hosts always win
It's more likely that there are just far more applicants from the home country

>captcha has the fucking olympic logo
What the fuck?
What?
How do I interpret that?
>>
>>55911009
Correct, not a coincidence.
More Russians enter if the competition is in Russia.
>>
>>55911235
>captcha has the fucking olympic logo
>What the fuck?
>What?
>How do I interpret that?
Tell the IOC to sue Google
They love suing people who use the logo without a license.
>>
It is clear there is some cheating going on. See the doping scandal in the Olympics.
Americans would win a fair competition 90% of the time.
>>
>>55910998
The older thread is not over the bump limit yet, what the hell?
>>
>>55911261
It is over 300
>>
>>55911266
And the bump limit is at 310.
>>
>>55911009
>>55911235
>>55911242
>>55911256
You guys memeing or serious?

The university names are the winners not the hosts
>>
>>55911289
>post a table without any labels for the columns
>You guys memeing
no
>>
python noob here, i'm developing an API where instead of using exceptions, i need to handle errors in a dictionary with values like ERROR_GENERIC, ERROR_STRING_WRONG_FORMAT, ERROR_SUCCCESS, and so on. isn't this retarded? how am i supposed to do it?
>>
>>55911374
Write error-free code instead
>>
Hey, any idea why I'm getting an "int object is not iterable" error here?

# img is height x width x channels numpy array

def foo(img):
height, width, channels = img.shape
segs = np.zeros((height, width, channels))
segs_total = np.unique(segs).shape[0]
# in practice, segs contains all integers between 0 and segs_total arranged
# randomly

svs = []
for seg in range(segs_total):
tmp = []
for channel in range(channels):
# append shit to tmp here
svs.append(tmp)
return np.array(svs)
>>
>>55911394
The error is in the
for channel in range(channels):
line even when I comment that line out.
>>
>>55911374
use an exception monad
>>
So I'm writing an Android app that fetches information (text/small images) from a few different web sites. Using HttpUrlConnection as means of fetching the info.
How do I simulate shitty internet connection in the virtual machine? Want to test the timeouts, incomplete queries, etc so that every scenario is covered.
>>
>you can store at the address of a label in ARM64 assembly but not load the address with ldr
Who decides this dumb shit? I swear ARM is getting as dumb as Intel
>>
>>55911383
Write Erlang and just let it crash whenever something happens.
>>
>>55911289
this

>>55911308
it says a year, a university, and a country

obviously the time and location of the event. there is no indication that the country is the country of the winner.
>>
>>55911411
interesting, i'm reading about it now. will take a while to figure out how to implement it though
>>
>>55911561
Exception a = Valid a | Error String
instance Functor Exception where
fmap f (Valid x) = Valid (f x)
instance Monad Exception where
return = Valid
(Valid x >>= f) = f x
(Error s >>= f) = Error s

Generalise to
Exception b a = Valid a | Error b
...

alt you can use the writer monad if you want to accumulate errors
>>
>>55911402
>even when I comment that line out
Makes absolutely no sense. Post whatever you're doing in that loop.
>>
>>55911602
import numpy as np
from skimage.segmentation import slic
import cv2

def generate_support_vectors(img):
## calculate segments
segs = np.array(slic(img, n_segments=500, sigma=5))
segs_total = np.unique(segs).shape[0]

## calculate median / mean / stdev value for each segment
LUT_median = np.zeros((segs_total, channels))
LUT_mean = np.zeros((segs_total, channels))
LUT_stdev = np.zeros((segs_total, channels))
for seg in range(segs_total):
coords = np.array(np.where(segs == seg)).T
pix_list = []
for pixel_id in range(coords.shape[0]):
pix_list.append(img[coords[pixel_id, 0], coords[pixel_id, 1], :])
pix_list = np.array(pix_list)
LUT_median[seg] = np.median(pix_list, axis=0).astype(np.uint8)
LUT_mean[seg] = np.mean(pix_list, axis=0).astype(np.uint8)
LUT_stdev[seg] = np.std(pix_list, axis=0)
## normalize standard deviation to use entire range of values
for channel in range(channels):
LUT_stdev[:, channel] = (255 * LUT_stdev[:, channel] /
max(LUT_stdev[:,channel])).astype(np.uint8)

## create output array
svs = []
for seg in range(segs_total):
tmp = []
for channel in range(channels):
tmp.append(LUT_median[seg, channel])
tmp.append(LUT_mean[seg, channel])
tmp.append(LUT_stdev[seg, channel])
svs.append(tmp)

return np.array(svs)
>>
Anyone here made a discord bot before? I'm going to make one soon and need to know any tips for making one
>>
Anyone have ideas for numerical/mathematical stuff to program?
>>
>>55911682
all programs are mathematical
>>
>>55911711
Oh yeah well I was bad at maths all through highschool but now I'm a professional competitive videogame player and I don't need maths so obviously not all programs are mathematical you nerd.
>>
>>55911682
arrow notation
>>
>>55911725
>I'm a professional competitive videogame player
lol
>>
File: (You).png (403KB, 521x520px) Image search: [Google]
(You).png
403KB, 521x520px
>>55911725
>I'm a professional competitive videogame player
>>
File: 2393753657.png (117KB, 372x351px) Image search: [Google]
2393753657.png
117KB, 372x351px
>>55911725
>I'm a professional competitive videogame player
>>
>>55911758
>>55911833
>>55911795
>being baited this hard
welcome to 4chan newfriends
>>
>>55911725
>A professional competitive video game player
>>
>>55911682
project euler
>>
>>55911862
we knew it was bait

welcome to 4chan newfriend
>>
>>55911862
>i was just pretending to be retarded
ok summerfag
>>
File: (You).jpg (40KB, 349x642px) Image search: [Google]
(You).jpg
40KB, 349x642px
>>55911862
>>
>>55911601
didn't get that code but thanks. will try implementing the writer monad since it seems easier
>>
>>55911926
don't get trolled into monads for freaking python
>>
>>55911957
>trolled
It is literally a way of turning shitty language built-in exceptions into proper systematic exception types that can be analysed and manipulated
>>
>>55911991
*
not turning, replacing
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
>>55911991
>>
Picking my first courses in the computer science meme today. Should I focus on web dev courses and self study if I'm wanting to move on to internships and jobs as soon as possible?
>>
File: 1455596028755.jpg (8KB, 265x265px) Image search: [Google]
1455596028755.jpg
8KB, 265x265px
>>55912053
>computer science
>web dev
>>
>>55912053
don't spend years taking courses if all you want to do is fucking web dev
>>
File: 2016-08-04_12-56-26.png (9KB, 360x241px) Image search: [Google]
2016-08-04_12-56-26.png
9KB, 360x241px
Guys, I just made the best string reversal algorithm
>>
>>55912170
done before
>>
>>55912170
>>55912177

https://en.wikipedia.org/wiki/Bogosort

of particular note is the multiverse implementation
>>
File: Pokemon Type Calculator Program.png (213KB, 1680x1050px) Image search: [Google]
Pokemon Type Calculator Program.png
213KB, 1680x1050px
Is it bad practice to use a bunch of global variables instead of local variables that you pass to specific parts of the program that use it? I just wrote a program where I did this and it was a lot simpler than having to pass everything by reference or whatever else to a half-dozen functions.

Is this a habit I should avoid or does it not really matter?
>>
yo to the haskell atom editor guy here
how do you accept the lint suggestion from ghc-mod/haskell-ide
>>
Any help?
segs is essentially a height x width matrix with values between [0, segs_total), the LUT_* arrays are essentially copies of segs but with 3 channels colored according to the mean / median / stdev of img at the appropriate pixels, coords is the list of coordinates in segs that have the same value, pix_list is the list of corresponding pixels from img. svs should contain (for every segment, i.e. every unique value in segs):
[
median of the H channel all pixels that are marked with the same segment ID,
mean of H channel of all pixels marked with same segment ID
standard deviation of H channel of all pixels marked with same segment ID
median of the S channel all pixels that are marked with the same segment ID,
mean of S channel of all pixels marked with same segment ID
standard deviation of S channel of all pixels marked with same segment ID
median of the V channel all pixels that are marked with the same segment ID,
mean of V channel of all pixels marked with same segment ID
standard deviation of V channel of all pixels marked with same segment ID
]


>>55911653
>>
>>55912474
C++ way is to use Classes/OOP, which has it as members

strive towards that while learning
>>
>>55912474
>Is it bad practice to use a bunch of global variables
yes
>>
>>55912474
It depends on your design.

It's almost always a bad idea, especially if those variables are publicly accessible to the entire program. This makes tracking what is changing your state fairly difficult.

I typically only allow constants to be universally accessible, because I know nothing can fuck with them.

tl;dr: Yes, it's generally a bad habit.
>>
>>55912523
>>55912523
not a solution but if these are actually in 1 array you should do this

enum channel = { H = 0, S = 2, V = 5 };
enum stat = { Median = 0, Mean = 1, StdDev = 2 };


array[H + Median]
array[V + StdDev]
>>
>>55912584
*S = 3, V = 6
>>
>>55912584
This is Python, not C.
I could use dictionaries instead of simple arrays, like
svs = {
'H': {
'median': LUT_median[seg, channel],
'mean': LUT_mean[seg, channel],
'stdev': LUT_stdev[seg_channel]
},
'S': {
## etc
},
'V': {
## etc
}
}

But that makes iterating inconvenient compared to simple indexing.

In any case I closed the jupyter notebook, restarted the server and now it's magically working. What the hell.
>>
>>55912631
does Python not have something like
for k,v in pairs (table) do
>>
yield! is one of the the coolest things that F# has over C#, even with IEnumerables and yield returns.

Rate my look-and-say sequence algorithm:

let count f =
let rec count' count previous sequence =
seq {
match sequence with
|[] ->
yield count
yield previous
|s::s' ->
if s = previous then
yield! count' (count+1) s s'
else
yield count
yield previous
yield! count' 1 s s'
}
let f' = f |> Seq.toList
count' 1 (List.head f') (List.tail f')

let toCount =
Seq.map (fun a -> (int a) - 48)

let toString c =
c
|> Seq.map string
|> String.concat ""

"1"
|> toCount
|> Seq.unfold (fun a -> Some (a, count a))
|> Seq.take 50
|> Seq.map toString
|> Seq.iter (printfn "%s")
>>
>>55912764
C# has yield, but I'm not sure of the functionality difference between them.
>>
>>55912764
>>55912790
Oh, I see what you're saying.

Isn't yield! like a
SelectMany
?
>>
>>55912670
In this case (like reading all linear combinations of (channel, means)) you'd use two loops like so:
for channel in svs:
for means in svs[channel]:
# read shit here

The problem is that Python doesn't necessarily store array elements in order. So for example if you have a 3x3 matrix, you might define a 9 element array to hold the values so
v11 v21 v31
v12 v22 v32
v13 v23 v33

is stored like this:
array = [v11, v12, v13, v21, v22, v23, v31, v32, v33]

and additional variables w = 3, h = 3 store the dimensions.

You could now maybe define an operation such that
for element in array:
loops over all elements in it, i.e.
iteration 1: element = v11
iteration 2: element = v12
iteration 3: element = v13
iteration 4: element = v14

and so on until you reach the end of the array (until you try element = array[w*h]).

array is a pointer to the memory address where v11 is stored and
array[n] == *(array + n)
.
What Python does (from what I understand) is that every element in an array, tuple or dictionary can be either an actual value (integer, float, char etc) or another array, tuple or dictionary of arbitrary length. This allows for arrays like
array = [
[1, 2, ('abc', 'def)],
[0],
True,
(('fuck', 'shit', 'cunt'), 1, 2, 3),
{'a': 0, 'b': 2}
]


The downside is that iteration doesn't happen recursively here; if I tried
for element in array:
like before, then we would have
iteration 1: element = [1, 2, ('abc', 'def)]
iteration 2: element = [0]
iteration 3: element = True
iteration 4: element = (('fuck', 'shit', 'cunt'), 1, 2, 3)
iteration 5: element = {'a': 0, 'b': 2}

(so element changes type from "array" to "array" to "boolean" to "Tuple" to "Dictionary").
I'd have to use nested loops, and even that only works properly without additional hassle if all elements have the same "depth".
>>
>>55912867
>
array = [
[1, 2, ('abc', 'def)],
[0],
True,
(('fuck', 'shit', 'cunt'), 1, 2, 3),
{'a': 0, 'b': 2}
]

>is a valid array

python, what are you doing

stop that
>>
>>55912790
>>55912837
Somewhat, yes. yield! enables you to chain a sequence onto the running sequence of items that yield returns. You could simulate the same thing in C# by iterating and yielding the items of the sequence you want to chain, but then it turns quadratic. SelectMany could be used, but then the single items would have to be into a IEnumerable too. It would be too much clutter.

yield! is beautiful for traversing trees.
>>
>>55912882
It has its uses. Compare it to struct in C.
>>
>>55911957
what should i do instead? it seems a good way of making a function return extra information (an error) without using exceptions
>>
>>55912892
I can't think of a single case where I wouldn't rather create my own object to handle a mess like that, or even an anonymous type if for some god-awful reason I was doing that in-line.
>>
>>55912886
It's cool and all, but I can't think of a single time I would have ever used that in a practical application.
>>
>>55912909
>I can't think of a single case where I wouldn't rather create my own object to handle a mess like that
I can. Not wanting to create seperate objects for example, or dynamically-sized arrays.
Take my example here: >>55911653
I don't know the image dimensions or number of channels in advance, I don't know how the segmentation algorithm will choose to segment the image, I don't even know how many pixels belong to each segment and the number of pixels per segment may vary. This approach makes it easy to define such data structures and fill them quickly.
I used to find it confusing and it definitely has its drawbacks but often it also allows for nicer notation.
>>
>>55912474

Try to avoid globals or at least put them in a name space only used for globals.

Btw typeList should probably be a tuple or struct containing the string and Type.
>>
>>55912882
What's wrong with it?
>>
>>55912964
>>55912982
Honestly, I'm sure it's fine for what you're doing, but I don't do dynamic typing.

If you have an array/list/whatever, if each element is not the same type, it is impossible to guarantee what can be done to each element in an array.

If I have a function called
CaressLovinglyWithMyPenis()
, and I pass it an array that I think contains catgirls, it would be awkward for everyone if suddenly within that object there's a group of porcupines.

I'd rather have a guarantee (via compilation restrictions) that my penis cannot come into contact with anything but a catgirl.

tl;dr: I just don't care for languages that aren't type-safe.
>>
>>55913064
It's bothering me as well. This is why I always have a big comment at the beginning of each function telling you exactly what assumptions I am making about the arguments. Plus exception handling is a thing, but that's runtime stuff and I can understand preferring compile-time errors.
>>
Hello /g/ents.

Was wondering if this was a thing: a program that analyses the waveform of a piece of music and auto adjusts the volume accordingly. So if the music is loud at one point, the computer volume would decrease and vice-versa. How difficult would this be to code?
>>
>>55913176
I think this would be pretty easy.

In C#, I'd maybe hook into the winmm DLL, and manage the system volume in real-time with whatever audio is playing.
>>
>>55913176
>>55913197
winmm.dll seems to be legacy.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370784(v=vs.85).aspx

Obviously, the harder part is getting the actual volume level output, because setting the system volume is trivial.
>>
learning c pls help me:

#include <stdio.h>
#include <stdlib.h>

union varinfo
{
int varno;
int varattno;
};

static void foo(union varinfo *var);

int main(void) {
union varinfo var;

foo(&var);

printf("varno: %d", var.varno);
printf("varattno: %d", var.varattno);
}

static void foo(union varinfo *var) {
int a = 1;
int b = 2;

var->varno = a;
var->varattno = b;

}


Why is varno = varattno = 2 ? whats correct code for varno = 1; varattno = 2;?
>>
>>55913263
I don't think you understand the purpose of union.
Anyway, just change every 'union' in your code to 'struct'.
>>
>>55913176
Not difficult, but you can make it more or less sophisticated.
Simple implementation:

> read sample from audio stream into shift register
> calculate RMS value of all register values
> multiply with (desired RMS / actual RMS)
> output last element of register
> shift register values, deleting the one that was played and reading a new sample into the free space
> repeat

Obviously this will introduce latency depending on sampling rate and register length, also you need to code it so that you're done with the calculations before the next sample is read or you'll get aliasing effects.
>>
>>55910998
Studied at ITMO for two years, it was shit.
>>
>>55913279
thanks got it now
i'm dumb, union always takes the largest type right?
>>
What was the last thing you wrote that made use of bitwise operators?
>>
>>55913487
Literally nothing currently on a production system.
>>
>>55912925
Made a sample for showing the files in the current folder with sublevels.

open System.IO

type ContentInfo =
|File of FileInfo
|Directory of DirectoryInfo*ContentInfo list

let folderToTree dir =
let rec fromDirectory (d:DirectoryInfo) =
[
let fromFile f = File f
let files = d.GetFiles() |> Seq.map fromFile
let subdirs = d.GetDirectories()
yield! [
yield! files
for d in subdirs do
yield Directory (d, fromDirectory d)
]
]
let d = DirectoryInfo(dir)
let r = fromDirectory d
Directory(d, r)

let showInfo c =
let pad n = Seq.init n (fun _ -> " ") |> String.concat ""
let rec info level c =
[
match c with
|File f -> yield ((pad level)+"- "+(f.Name))
|Directory (d, c) ->
yield ((pad level)+"+ "+(d.Name))
yield! c |> List.collect (info (level+1))
]
info 0 c

Directory.GetCurrentDirectory() |> folderToTree |> showInfo |> Seq.iter (printfn "%s")
>>
>>55913589
What's a sample output look like?
>>
>>55913487
chip8 emulator
>>
If I'm okay with working through the borrow checker shit in Rust for now, will I regret using Rust for some reason later?

So far it seems pretty fuckken good.
>>
>>55913600
+ root                                                                                                                                                                          
- .cg_conf
- main.exe
- main.fs
+ test
- f.txt
+ a
+ b
- g.txt
+ c
- d.txt
>>
>>55912474
Constant / immutable values which will never change are actually considered okay for globals. So, things like typeList, since you're not going to add new types of Pokemon or delete some of them while the program is running.

Nothing else though.
>>
I'm building WLAN onboarding software that authenticates against the organization's directory and installs the company's root CA certificate.
The best thing would be installing the user's personal certificate too, since it's more secure than password-based auth.
I might as well build the EAP-TTLS PAP supplicant myself.
>>
>>55913487
Packing vertex data into a 32-bit int for OpenGL, and then unpacking it in the vertex shader.
>>
>>55913310
union only stores value for one field at a time. So if you assign something to varno, and then something to varattno, the value for varno will be lost. the amount of memory allocated for your union is equal to whatever the largest data type any of its fields has.
>>
>>55913934
feel free to correct me on this lads. my C is rusty af
>>
File: 542140.jpg (14KB, 400x400px) Image search: [Google]
542140.jpg
14KB, 400x400px
https://github.com/rust-lang/rust-www/issues/268
>>
File: Hasklig.png (24KB, 418x466px) Image search: [Google]
Hasklig.png
24KB, 418x466px
ligatures are cool right
>>
>>55914191
what colorscheme?
>>
>>55914212
Gruvbox

https://github.com/morhetz/gruvbox
>>
>>55914165
>look at """her""" github
>all serious software is forked from others
>own repos are shit

Welp
>>
>>55914226
then this guy is a core member
https://github.com/steveklabnik
>>
>>55914165
You gotta wonder how many people on this team looks at these discussions and think "man, does this really matter?"
>>
I'm trying to solve a system of differential equations in Haskell.

Unfortunately, this requires me to define a set of tuples recursively as a function of the previous set of tuples.

How do I do this?

I've already tried:

solveDE1 :: (Double,Double) -> Double -> Double -> [(Double,Double)]
solveDE1 (u0,y0) = take 1000 $ iterate $ (stepDE1) (u0,y0)


Here "stepDE1" is of the form:

stepDE1 :: (Double,Double) ->  (Double, Double)
>>
>>55914238

Yeah, but we already knew that Klabnik loves big SJW dick in his ass.
>>
>>55914267
"a set of tuples" should be "a tuple", sorry.
>>
File: dasjws.png (95KB, 765x437px) Image search: [Google]
dasjws.png
95KB, 765x437px
>>55914250
mozilla and by extension rust are very SJW

they even included this for their state of rust survey
>>
>>55914268
>>55914290

http://forum.dlang.org/post/[email protected]

kek
>>
>>55914290
m8, I'm a brown as fuck mestizo born in tacoland.

I'm brown as a piece of shit.
Why these faggots keep talking shit about being inclusive?

I don't give a fuck if more colombians want to be into drug trade or some shit like that rather than being programmers?

do you think me or my coder friends do give a fuck?
>>
CHI
>>
I'm bored /dpt/

What should I do?

Tuple<Tuple<Tuple<string, string>, Tuple<string, string>>, Tuple<Tuple<string, string>, Tuple<string, string>>> help;
>>
>>55914366
write a program that given a text input, returns a summary of the text to output
>>
>>55914366
kys
>>
File: 1470314550799.gif (2MB, 320x384px) Image search: [Google]
1470314550799.gif
2MB, 320x384px
Say your government is giving you 2000 euros/month to make open source software for them(in a country where net salaries of programmers don't usually go above 1500 even for seniors)

What would you make?
>>
void func(std::vector<int>&);

func({1, 2, 3});


why is this not possible?
>>
File: 63e9YE9.png (152KB, 514x204px) Image search: [Google]
63e9YE9.png
152KB, 514x204px
>>55914366
Analyze this map to find out where the player is, and move the player to a certain location within that map

red bars are platforms which needs to be recorded as well, player is the yellow object

Let's say it updates every second so you can track the player position

and it takes ~10 seconds to reach one end of the map to the other
>>
>>55914440
Literals don't have memory addresses
>>
>>55914421
2000 euros per month, I think.
>>
http://stackoverflow.com/questions/15567794/how-to-get-rid-of-the-warning-when-comparing-final-variables

fucking pajeets i swear, of course you can compare static final values, like compile-time configurations which can be optimized out by proguard or whatever, am i seriously gonna have to live with this warning??
>>
>>55912188
woosh
>>
>>55914498
KEK
>>
File: 1470190679274.jpg (384KB, 900x800px) Image search: [Google]
1470190679274.jpg
384KB, 900x800px
>>55914498
>>
>>55914508
ok it turns out it's dead simple to configure eclipse to ignore specific warnings, fucking pajeets
>>
File: Screenshot_2016-08-04_09-48-46.png (56KB, 755x426px) Image search: [Google]
Screenshot_2016-08-04_09-48-46.png
56KB, 755x426px
>>55914508
I don't think I could expect anything less from SO
>>
File: [sql injecting intensifies].png (17KB, 683x450px) Image search: [Google]
[sql injecting intensifies].png
17KB, 683x450px
>>55914508
>>
>>55914191
How is /dpt/ suddenly full of F# coders? Did it become a meme overnight?
>>
>>55914599
/dpt/ isn't suddenly full of F#.

There's like 2 posts in this thread about F#, sans replies to responses.

You clearly weren't here a few months ago when it was being actually spammed.
>>
>>55914224
On an unrelated note: I like Rust but what the fuck is with all of the people trying to make web frameworks in it?

Rust can be useful in a lot of niches but that isn't one of them.
>>
>>55914312

So fuckin' based. Not only is D less of an eye-cancer than Rust, less annoying to use than Rust, but the developers are also not complete fags.
>>
>>55914631
it's a language made by web devs, for web devs, it is/was supposed to be used in mozilla firefox or something
>>
>>55914421
software for handicapped people.
>>
>>55914654
[spoiler]so project management software?[/spoiler]
>>
>>55914663
You have to go back.
>>
>>55914335
Here's a little spoiler as to why SJWs do SJW things:

SJWs are people who are tryhards at "not being an asshole."

They're people who hear that it's a bad idea to be an asshole and go "well then I'm going to be the least assholish person ever. I'm going to go make 500 spreadsheets to inform me how best to not be an asshole, motherfucker. I'm going to use South Korean Starcraft micro on my tumblr posts to not offend anybody or make them feel bad ever.

p.s. I'm going to expect literally everybody to do the same thing."

So, the goal is a good one, they're just being a bit... overachieving.

Thus we get things like "let's try to include a clause in our code of conduct for being nice to every theoretically possible gender identity. Hey guys, is it possible to make a gender monad?" and such.
>>
>>55914599
>>55914627
that's haskell...
>>
>>55914663
no, I mean deaf, blind people.
>>
>>55914645
>it's a language made by web devs, for web devs, it is/was supposed to be used in mozilla firefox or something
But that's wrong.

It was supposed to be used in Mozilla Firefox's *rendering engine*.

It was made by people who want performance and stability at the same time. The thing they threw under the bus is making it easy for developers to write something that justwerks in about 5 seconds - which, coincidentally, is what everybody wants for web development.

Writing a web framework in Rust is the same shit as writing a web framework in C, except slightly less stupid.

You'll end up having to think in-depth about memory management and the type system while you're just trying to serve up helloworld.html
>>
>>55914684
america is fucking trash.
I'm glad I don't live in that shithole.
>>
>>55910998
>Russians are the best programmers edition

Americans are too busy doing actual work to compete in things like this.
>>
File: wtf.png (20KB, 538x442px) Image search: [Google]
wtf.png
20KB, 538x442px
What the fuck am i doing wrong?
>>
>>55914730

I mean, we also have guns & hate speech is a common pastime, so maybe it's not all bad.
>>
Any rustaceans want to explain lifetimes to me? It's fuckall confusing when it's so simple in every other language.
>>
>>55914635
But D is exactly like C++ except with less developer attention.

What does D have that C++14 doesn't?

Why the fuck would I ever use it?
>>
>>55914747
sure, it can be nice.
But I'm happy in my taco shithole.
at least I only need to make 10k a year to be able to live on my own, compare that shit to americans who need 50k a year.

I'm happy I can make in internet in some patreon shit, like an american wage while living in tacoland.

also, I don't want to get shoot by the police or some shootings.
>>
>>55914765
the prestige of having used it since before it was cool
>>
>>55914765

garbage collection :^^^)
>>
Has anyone here hacked into a major company's accounting books?

I need sample data for an application I'm developing.

I just need like...all of their IT spending and ROI.
>>
>>55914740
Connect doesn't take 4 args
>>
>>55914599
All F# code on this thread was my fault. Probably always is, and when I seldom post usually no one cares.

I didn't learn do program UI's yet, but been using for some unattended projects, like stream downloaders and html generation from csv files.

It's a productive language at least.
>>
Is haskell the future of programming or should I learn D instead?
>>
>>55914751
A lifetime is a compile-time variable that tells you when memory is going to be freed.

So when you have &'a foo, &'a bar that means that the memory foo and bar point at will both get freed at the same time.
>>
>>55914784
>also, I don't want to get shoot by the police or some shootings.

I'm pretty sure the homicide rate where you live is higher by a non-trivial amount, so that ship may have sailed, buddy.
>>
>>55913666
I think the borrow checker is the biggest thing that scares of people from the language, so you should be fine if you're okay with it.
>>
File: record12.webm (2MB, 1364x764px) Image search: [Google]
record12.webm
2MB, 1364x764px
>>55910998
> want to able to play mp3
> have to download proprietary libs to do that

webm not related
>>
>>55914786
ayyyy

>>55914788
std::shared_ptr
>>
>>55914799
yes it is
languages (C#, rust, swift) in the next 2 years will finally have HKT and typeclasses
>>
>>55914823
>std::shared_ptr

Is not the same thing. I think smart pointers are really great, but they are not garbage collection.
>>
>>55914809
>I think the borrow checker is the biggest thing that scares of people from the language, so you should be fine if you're okay with it.
Okay, cool.

I know there are some gotchas in languages when you try to make them scale to big projects. Vala, Go, and Python come to mind.
>>
>>55914837
They provide the same logic but have different performance characteristics ... and you shouldn't be using automatic memory management at all if performance is that important.
>>
>>55914784
>who need 50k a year
Wildly varies between states and cities.

$30k would be upper-middle class for some rural areas in the US, whereas to live in San Fran you need to make like $120k.

It's like comparing eastern Europe to western Europe.

Ironically, you're much more likely to get shot in an expensive city than you are in the inexpensive rural areas. Contrast this to your chance of being shot in relation the poverty of a given country, which generally shows a positive correlation.

tl;dr: C# is the language for patriotic Americans.
>>
>>55914805
my country homicide rate is 30 or something.
but you seem to ignore something.

99% of the time is:
drunk fights
opossing armed robbery (utterly fucking retarded)
opossing armed thieves after you do a bank money retirement
walking into some hobo guetto (oposing armed robbery)
living in some nigger poor favela
getting into gang shit
getting into crime and gang fights
getting into drug trade

as you can see, nothing of the previous shit means I will get shot by the police or some random crazy dude while I shop on the mall.

is funny how sometimes I feel safer than in the usa.
>>
File: Starvation.NET .png (217KB, 993x889px) Image search: [Google]
Starvation.NET .png
217KB, 993x889px
>Hey, there's lots of Ethiopians who really want to program in .NET
>I know, we'll create this monstrosity!
>>
>>55914907
I have seen universities using spanish programming languages dude.

I'm sure japs have some gook programming language to teach programming.
>>
>>55914897

You are a fucking moron if you don't think that most of the homicide in the US has to do with gangs/career criminals as well.
>>
File: unicode.png (4KB, 442x98px) Image search: [Google]
unicode.png
4KB, 442x98px
Why the fuck haven't Europeans exterminated all these savages and their savage scripts?
>>
>>55914977
You're a fucking deluded burger if you don't know you can get targeted because of racial hate crimes, police shooting you or some random mall shooting.

those clearly involves random average civilians.
>>
>>55914882
>C# is the language for patriotic Americans.

I have yet to meet anybody who really hates C#. Sure, it doesn't do anything radical or creative in language design. It's just a Java that's subtly better than Java in a million little ways, and comes together into being a very comfy language.
>>
>>55914897
>opossing armed robbery (utterly fucking retarded)
Is your country so bad that you get robbed on a regular basis?
>>
>>55915025
>I have yet to meet anybody that has actually used C# who really hates C#.

FTFY

People love to hate it just because it was created by Microsoft.
>>
>>55914907
>>55914926
Meanwhile, Go inherently just supports Unicode characters in identifiers in source. This is as part of the spec.
>>
>>55915010
Oh god, you consumed the media.

It's too late for you anon.
>>
>>55915010

Those are also so rare that the likelihood of it happening to you is, near as makes no difference, ZERO.
>>
>>55915042
is not common but is usually the news TV channels making everything seems more dangerous.

imagine a city of two millions and there's two armed robberies per day.
of course watching the news will make you feel insecure, even if stadistically you have very little danger.

is like being afraid of car crashes.

there's always the news about some dude getting killed because he opposed an armed robbery.
>>
>>55915025
a lang being "comfy" isn't good, may as well use some even worse shitlang like python then, kill yourself you delusional cunt
>>
>>55915062
>>55915068
unless your country is literally a failed state like venezuela or some civil war shit, there's very few chances to get killed by criminals.

most of them don't want to kill you, they only want to get money.
>>
>>55915068
The same can be said of Islamic terrorism, conserva-kun. 'w`
>>
>>55915101

In the U.S., perhaps. It's on the rise in Germany and France. Refugees welcome :^)
>>
>>55915083
So instead of revealing any flaws in C# you're just going to tell me to kill myself and meme about python.

2/10 very poor bantz see me after class
>>
>>55915126
you're right there are no flaws in C# that's why it's the #1 language ranked above java, C, C++, python, oh wait...

http://www.tiobe.com/tiobe-index/
>>
is funny how most americans think any non first world nation is suddenly a crimen riddlen hellhole.

funny how they overblow the stats to think the average life is pretty shit.

they get extremelly butthurt when you remind them USA has also poverty and crime.
>>
Europoors get extremely butthurt when you remind them about the US
>>
>>55915158
No one said there are no flaws in C#.

It's a language that's enjoyable to write in and has tons of support.

If a language is comfortable, that means you can actually create working programs without pulling your hair out over unintuitive syntax and esoteric bugs.

What specifically do you not like about C#?
Is it memes?
Personal preference?
Concerns about the direction of the language or the .NET framework?
>>
>>55915158
let me reveal a secret:

I have barely used C# at all.

So I'm very receptive to you point out any actual problems in C# if you're actually going to do that.

Like, show me where the type system gets in your way or the performance goes to shit. Anon, I'm counting on you to be informative.

But, instead, you're just shitposting.

So I'll keep saying positive things about C# because all you're doing is memeing at me.

(Tiobe index is a non-argument. If popularity == quality, then we should all use iTunes on Windows 10 to listen to Justin Bieber all day. Also that would imply that PHP is good.)
>>
>>55915190

You're the one who's getting butthurt, cochise. All I said was that your country has a higher rate of intentional homicide.

You can talk all the shit you want, but it doesn't change the truth.

For a nominal fee, we can annex your country and fix it up so that it's NOT a complete shithole.
>>
>>55915283
https://codeblog.jonskeet.uk/2014/07/16/micro-optimization-the-surprising-inefficiency-of-readonly-fields/
>>
>>55914267
>How do I do this?
Maybe try formulating a precise query next time. Remove the last $ in solveDE1
>>
>>55915158
Justin Bieber has 23 million subscribers on his youtube account. Elton John has 240 thousand. Being popular is not relevant.

If you account for licensing reasons, as C# was not an entirely free to use language for any project, it's well placed. Being cheap is sometimes preferable to being better.
>>
/dpt/ is shit today.

I guess the janitors are asleep because this big old /int/ fight on the wrong board is totally the kind of thing you get a 3-day ban for.
>>
>>55915285
I'm not butthurt.
;)
I like to talk shit to burgers.
>>
>>55915283
>>55915297
It's also worth noting that C# has a higher number of jobs than C, C++, and Python (not combined, of course).
>>
I'm pretty new to github and open libraries. What do I need to do when I add a library with an MIT licence to my project? Do I need to copy the licence to my project, provide a screen with the licence in the app or what?
>>
File: 1470159415847.jpg (65KB, 600x450px) Image search: [Google]
1470159415847.jpg
65KB, 600x450px
>>55915303
>implying it's not always shit
>>
>>55915332
license.txt in root directory
>>
/g/ what should i use for building android apps on arch linux.
I want to use js,html5,css
>>
>>55915010
Except I can actually shoot back lol
>>
>>55915331
>C# has a higher number of jobs than C, C++,
What, really?
This is very surprising. When did that happen? Is it all winforms applications or is C# finding a bigger niche?

>>55915334
It's usually shit about programming. Today it's shit about le ebin trump wall taco crimes. At least be on-topic idiots, people.
>>
>>55915310

Whatever you say. Your women are pretty good looking, though, so you've got that going for you.
>>
>>55915332
Just have a general file with licenses of third party libraries, do not include the entire license though, just the header.

So for example if it was GPL licensed software, you'd use this (with their name/authors of course):
one line to give the program's name and an idea of what it does.
Copyright (C) yyyy name of author

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


Rather than the entire license information.
>>
>>55911445
I don't get what you are trying to do, point it here please : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/Babbfdih.html
>>
>>55915344
What if there is more than one?
>>
>>55915377
Will you mentor me in C#, mummy?
>>
I'm a noob here learning Java. What the fuck can I actually do with it besides make Minecraft mods, that other languages can't do better? Should I learn C++? What IDE do you recommend for linux?
>>
>>55915366
I fucking asked some hours ago what was the lowest shit I could study and nobody replied.

fuck you.
>>
>>55915403
nothing
>>
>>55915403
it's "comfy" for making mobile and enterprise software application solutions

but learn C++ too
>>
>>55915406
???
You mean this:
>>55912053
?

I would suggest a code bootcamp instead of a CS degree if your goal is "find a job, any job, ASAP." But if that's what you want to do while getting a CS degree, just be sure to take as many programming classes as possible while ignoring the gen-eds for your first year.

Note: There are more Java jobs than webshit jobs, so focus on Java.
>>
>>55915403
Learn Clojure and/or Scala too. Every IIT graduate can use Java, you want to stand out from them.

IntelliJ IDEA is the best Java/Scala IDE (get the free 'community' edition), not sure what's best for Clojure.
>>
>>55915403
>What the fuck can I actually do with it besides make Minecraft mods
I see somebody else fell for the Forge mod development meme.

Lucky for me I'm totally fucking burnt out on Minecraft, so I have no reason to return to that spaghetti code hell.

[spoiler]do your machines run on RF?[/spoiler]


To the original point - Java is normally used for making desktop applications with GUIs. So, maybe make a personal calendar program for yourself, or something.
>>
>>55915436
I'm not him, and I'm planning on self teaching myself a CS degree.
>>
>>55915403
Android
>>
Slowly picking up SQL; what level of competency do I need to be at before i can list it on my CV and go for jobs that list that on job requirements?
>>
>>55915403
Like any other programming language, pretty much anything with enough practice and experience. Here is how it goes :
> define a clearely what you want your program to do
> define clearly what you would like to write yourself and what you would like to not bother with and use a library for
> get cracking

don't use IDEs or automated building tools when starting out it. It's better the understand why they are useful first by for example struggling with manual builds for a bit.

this is not specific to Java.
>>
>>55915459

The Minecraft modding community is so cringe and toxic. I used to make plugins for servers back in the 1.4-1.6 days. 90% of "modders" are kids who barely know what the fuck they are doing. They don't even understand basic naming conventions or how licences work. They will copy and paste half of their code, upload it as GPL, then say "no copying my code!". It's fucking ridiculous man. The Forge community may be different, but I am never going back to that cringe city called Bukkit.

Also, use Java to make mobile apps, or as another guy said, enterprise software. Java development literally the most employable field right now, despite it's reputation.

There's really no need to learn C++ just because it's C++. Decide what you actually want to and enjoy programming, and then find a language that best suits that. Don't waste your time learning a language just for the validation of others.
>>
>>55915590
Depends on the job.

Basic understanding of
SELECT FROM WHERE
and joins is enough to get by if you just need to do basic reporting.

If you're going for a junior DBA, go take at least the MTA certification.

If you get your MCSA, that's like a guaranteed $60,000+ job, because it's actually really fucking difficult.
>>
>>55915262
memes
>>
>>55915597
>don't use IDEs or automated building tools when starting out it. It's better the understand why they are useful first by for example struggling with manual builds for a bit.
Oh god, not you again.
>>
Where should I get a CISCO cert? Because none of the schools near me offer it.
>>
>>55915676
wat?

If it's the silly mistakes, I'm sorry it's my fucking autocar rectangular.
>>
>>55914740
You dont need to pass the address of w and b.
Just pass w and b directly as values, they're pointers already.
You only would have to &b or &w if they're allocated on the stack.
>>
>>55915741
One more thing: connect isn't a global function, the simplest fix is to call QObject::connect here.
>>
>>55915720
There are probably multiple testing centers around you for the certification test.

Just look up CCNA testing centers or whatever.
>>
I live in a shitty rural state with an economy that is almost exclusively tourism, and I don't have a degree. I want to get a coding job so that I can have disposable income.

What do?

Do I just have to move out of my rural state somehow?
>>
>>55915793
Yes, you will probably have to move to find work. But you need skills first. Have you taught yourself any programming?
>>
>>55915396

Use the MSDN tutorials.
>>
>>55915834
>you need skills
not for web dev
>>
>>55915875
that's like learning programming from guido van rossum
>>
>>55915875
But mummy, I want you to help me. MSDN tutorials are not very good.
>>
>>55915898
cringe
>>
>>55915834
>Have you taught yourself any programming?
A whole bunch.

I've been fucking around with code in my spare time for 13 years.

I have a reasonable grasp on Java, Python, and C++, and I'm messing around with Rust now. I've written a Conway's Game of Life implementation in C, and for my workplace I wrote a little html parsing thing in Python (nobody told me to but I was tired as shit of copying those values over by hand).

The problem is, I have no nest egg and no rich relatives, and my expenses are too close to my income for me to save. So, moving to another place means either taking on a huge loan or, I don't know, couchsurfing with internet friends?
>>
>>55915834
>>55915924
...the other problem: Certain technologies that fucking everybody asks for in job descriptions, I have very little or no experience with - I have never touched JavaScript, I have no idea how to use SQL, and I'm still not quite sure what the fuck AJAX is.

that might be fine because I don't really want to do webdev but SQL at least is also used in a ton of enterprise shit
>>
>>55915924
Some companies will reimburse travel expenses incurred going to interviews with them, or they'll do interviews over Skype. Some will also give you a signing bonus, which you can use to get set up in a new place.
>>
>>55915898
Suicide's always an option
>>
>>55915898

They're good enough, lad. I figured out C# using them (and my existing Java knowledge). You can do it, too.
>>
>>55915952
Most IT job descriptions are full of buzzwords that nobody has used all of. It's a tedious, shit game.

You could try getting in touch with a recruiter.
>>
>>55915898
call me daddy instead so I can give you the cummies more easily
>>
>>55915975
But mummy, I want to do it with you.
>>
>>55916002

I'm honestly shit at teaching. That's why I leave it to professors.
>>
>>55916013
Can I sit on your lap while I read tutorials then, mummy?
>>
Do function attributes have to be in both the declaration and the definition, or just one of them?
C btw.
>>
>>55916043
Yes
>>
File: should have been a weebm.gif (3MB, 240x239px) Image search: [Google]
should have been a weebm.gif
3MB, 240x239px
>>55916029

Maybe if I were gay, but sadly I'm not. Best of luck.
>>
>>55916043
Just the definition.

This is alright:
void something(int, int *, const char *);


Then:
void something(int a, int *b, const char *c)
{
// ...
}


You can skip them completely if you're not using a parameter at all.
>>
>>55916067
But mummy, you're presuming things about me.
>>
>>55915980
Well depends on the position.

If someone hires a java developer or a webdev with SQL experience(both skills you also acquire in a CS meme degree) you can bet your ass that those skills are actuallly required.
Or as a embedded system
developer you will at least have to have some basic theory knowlegde.
>>
>>55916177
she wasn't alone
>>
>>55916374
Well that's creepy, what?
>>
>>55916559
bring them on board I'll call it in
>>
File: index.jpg (10KB, 225x224px) Image search: [Google]
index.jpg
10KB, 225x224px
>>55916585
>>
Holy fucking shit I hate using Python for OOP. It's fucking hideous and confusing

>self self self self self XD
>>
>>55916677
welcome to duck typing

quack quack
>>
>>55916677
 self.kill = True 
>>
>>55913487
fast fibonacci in 68k
>>
>>55914837
reference counting is garbage collection
>>
>>55913487
GameBoy emulator. It's the most fun use case for bitshifting desu
>>
>>55916069
ATTRIBUTES, you dumb shit!
>>
>>55916992
Do you even cyclic references
>>
I'm trying to program something that has to do with IPv4 addreses and subnet masks, but I'm running into a weird error.

I have the user input a multiple of 8 (for the subnet mask) and store it in a vector of type "byte" (I have the statement somewhere in my program:
 using byte = unsigned char

)
But when it runs, the program outputs the value "/377" which I've read is octal for 255

std::cout << "Please enter the subnet mask" << std::endl;
int subMask;
std::cin >> subMask;
std::vector<byte> subnetMask = {0, 0, 0, 0};

if(subMask%8 == 0) //If it's a valid subnet : "Classful addressing prescribed only 3 possible subnet masks (8, 16, 24)
{
int subCounter = 0;
for(int i = 0; i < subMask; i+= 8)
{
subnetMask[subCounter] = 0xFF;
std::cout << "SUBNET MASK AT " << subCounter << " is " << subnetMask[subCounter] << std::endl;
subCounter++;
}
}
>>
>>55915403
>What the fuck can I actually do with it
A whole fucking lot. There's libraries for pretty much anything you'd want to do. That's one of the JVM ecosystem's main draws.
>>
Dear /dpt/,

I've made this XInput class in C#
The class contains an array with 4 Gamepad objects
To make sure the array is never set to null / something else I've made it a { get; private set; } property
However, I noticed the individual objects inside the array can still be set to null from outside the class

Is there any way I can prevent this?
>>
File: image.jpg (64KB, 400x500px) Image search: [Google]
image.jpg
64KB, 400x500px
>>55916705
kek
>>
>>55917183
No, just live with it. Are you going to sabotage yourself?
>>
>>55917055
collecting all possible garbage isn't a requirement for a garbage collector.

conservative collectors are still garbage collectors and they don't collect all garbage.
>>
>>55917183
You could use something that's not an array. Consider IEnumerable<GamePad>? However, nothing stops people from using reflection to change things. They can even get at your private setter and invoke that, so to some extent you just have to live with the possibility of misuse.
>>
>>55917255
Collecting all possible garbage is a requirement for a good garbage collector. :^)
>>
>>55917285
Reachable is just a heuristic for garbage so i'm pretty sure no collectors actually do this.
>>
>>55917241
>>55917267
I guess I'll just live with it if there's no easy way that doesn't make my class more complicated to use
I just wanted it as idiot-proof as possible before publishing it
>>
>>55917308
>current year
>defending garbage collectors that break whenever a cycle happens
>>
>>55917404
you know weak references are a thing right?
>>
>>55916692
Fucking duck typing.

I mean, yeah the
EconomyState
and the
AngryMuslim
objects I passed both have a .Boom() method, but they certainly don't do the same things given that particular verb.
>>
>>55917366
There's an utility function AsReadOnly. It should be pretty easy to make a getter for like m_mySikritArray.AsReadOnly<>();
>>
>>55917433
>requiring the programmer to spot every single cycle and put in a hack every single time
>>
>>55917457
When does this ever happen in practice?
>>
>>55917459
This is also required with a normal gc to avoid space leaks in data structures that maintain references internally
>>
>>55917507
Not for every cycle.

WeakMaps are needed far less than explicit weak references.
>>
dumb question: in c++ if i want to use the [] operator for my custom class does my class need to be an aggregate?
>>
Is OCaml good, despite lacking the sexiness of Haskell?
>>
Is it worth learning Java as my first programming language if Oracle is going to kill it in the next seven years?
>>
>>55917637
operator[] can do whatever the fuck you like
>>
>>55917658
Java won't be dead in 7 years.

C# is a better beginner language, though.
>>
>>55917637
An aggregate? You mean non-trivial or what? Just define the operator[] and you are done.
>>
>>55917683
>c#
what's its usefulness? Is it at all related to c++?
>>
File: F.png (144KB, 600x500px) Image search: [Google]
F.png
144KB, 600x500px
Any idea what is wrong with my code?

Error is


Exception in thread "main" java.lang.Error: Unresolved compilation problem:
No enclosing instance of type Main1 is accessible. Must qualify the allocation with an enclosing instance of type Main1 (e.g. x.new A() where x is an instance of Main1).

at Main1.main(Main1.java:8)



But I can't figure it out. I'm new to programming. I tried to match all brackets. Literally no clue.

Trying to play around with constructors



g to play around with constructors


import java.util.*;


public class Main1 {

public static void main(String[] args) {

People classroom = new People();
classroom.addPerson("John");
classroom.addPerson("Sue");
classroom.addPerson("Billy");


}

public class People{
public ArrayList<String> classroom;

public People(){
this.classroom = new ArrayList<String>();
}

public void addPerson(String name){
this.classroom.add(name);
}
public void printClass(){
for(String person : this.classroom){
System.out.println(person);
}

}
}
}



It high lights


People classroom = new People();



but i dont know why
>>
>>55917705
C# is basically a fork of Java on a different VM

On a basic level it's the same (everything is a class, practically identical syntax, etc.) but it has a lot of features that Java doesn't have and misses some features that Java does have.

It's not related to C++ in any way really, though Microsoft wants C++ to be phased out for application development in favor of C# on their platforms.
>>
>>55917649
Not really, it was good 15 years ago but now it's just inferior.
>>
Practicing some Haskell. Below is a function for generating all perfect numbers up to n, slow as fuck when trying to get the 5th one though. I think it's coming up on ten minutes.

factors :: Int -> [Int]
factors n = [x | x <- [1..n - 1], n `mod` x == 0]

is_perfect :: Int -> Bool
is_perfect n = sum (factors n) == n

perfects :: Int -> [Int]
perfects n = [x | x <- [1..n], is_perfect x]
>>
>>55917745
make the inner class static, i.e. static public void.
>>
>>55917787
Which class exactly? What is the reasoning behind adding 'static'? The tutorial I'm reading hasn't covered this yet.

Thanks
>>
>>55912474
data tables and shit should be globals, of course
anything regarding program state should avoid globals unless you really, really, really need it (and even still, you could probably pack that into an object/struct to pass around)

like, the one thing for global use that comes to mind is when writing an emulator, the machine's registers and memory
but you could easily consolidate that into a struct or an object and pass the address of it around
which lets you do shit like run multiple emulation instances in your program with little effort, since there's no global state to deal with, just your little packaged objects

>>55913229
>winmm
it's been the standard way of wave output from Win95 onward (replacing mmsystem.dll)
but it's definitely legacy

look into WASAPI -- Audacity on Windows uses this to record whatever sound is being played back, you could analyze the data from that and easily just adjust the system volume
>>
>>55917649
>>55917772
See
>>55917569
>>
>>55917569
>>55917859

>I was too retarded for Haskell so I needed to attack it on the internet to defend my ego
>>
>>55914820
You don't have to do that.
>>
>>55917749
>C# is microsoft
What if I don't use windows?
>>
>>55917808
make class People static
>>
>>55917808
Not him but make the people class static. Static basically means it's the same for every instance of the object. So if it's not static, you could have two Main1 objects with different People classes I think.
>>
>>55917934
Use Mono, or a different language
>>
>>55916677
This is literally one of the few good decisions by Python, fag.
>>
>>55917934
http://www.mono-project.com/
>>
>>55917938
>>55917937
Ok that worked. Thanks.

>>55917938

What do you mean by having the same for every instance object? Do you mean the instance variables are the same for each People class object? I'm going to look this up shortly..
>>
>>55917883
>implying Haskell isn't just shit

Monads aren't scary.
>>
>>55915025
if I could write everything in C#, I would (Mono kind of sucks though)
it's just a language with features I want, familiar syntax, good tools
>>
>>55917938
No, this is different kind of static. Read up: https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
>>
>>55917981
>Monads aren't scary.
They're not supposed to be
>>
>>55917745
just add another curly bracket before public class People
>>
>>55918000
>https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

I'm new to java, trying to read through this to understand why I need static in my people class. But confused me more.

Can you explain?
>>
>>55917783
You are around O(n^2) and the 5th number is ~30, 000, 000 (if i am not mistaken) so it taking quite some time is reasonable.
And Haskell is not exactly known as the fastest language either.
>>
>>55917808
Change "public class People" to "public static class People".

By default, an inner class can only be instantiated inside an instance of its enclosing class. Static methods (like public static void main) aren't associated with any single instance of a class, so they can't directly call on non-static methods or classes.
>>
>>55917980
>>55918047

Static inner class: inner class works just as a normal class.

Non-static inner class: inner class instances are associated with the parent class, i.e. they kinda "capture" the "this" of the enclosing. You can do fun stuff with those like (bad example):
class Encolsing
{
private: int m_enclosing_val;
public:
Accessor getAccess() { return this.new Accessor() }
class Accessor
{
void inc(void) { ++m_enclosing_val }
}
}

..
Encolsing foo
Encolsing.Access fooAccess foo.getAccess()
fooAccess.inc()


Any way, since they "capture" this, you need to give the enclosing instance when you create them. Like outerinstance.new InnerClass() or in this example "this.new Accessor()"

See https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
>>
File: 1468866470632.png (342KB, 1000x1012px) Image search: [Google]
1468866470632.png
342KB, 1000x1012px
>>55910998
I wanna build my website using C#, should I look into ASP? Or there's a greater framework?
Don't redirect me to /wdg/.
>>
>>55917783
You're using list comps, what did you expect?
>>
>>55918075
>>>>>>>>>>>/wdg/

Also ASP.NET is the way to go. Not the .NET Core version though, it's barely usable at the moment.
>>
>>55918090
It's a new thread guise
>>
What is the best way to do this?

In WPF I compare 2 selected image "controls'" by opacity, so the program will check if their content id is "equals" to each other.


Basically a doubleanim happens that increases the selected images opacity to 100% and then a timer compares their content, if it is not equal then their opacity will change back to 25% and the selection disappears.

Cannot post the aource code cause i am on mobile, but how would YOU do it?

My solution seems to complex and I feel there is a way to make it more "lightweight".
>>
>>55918102
Thanks lad.
>>
>>55917934
C# is open source.
>>
>>55918071
>>55918057
Thanks.
>>
>>55918204
C# is not a software thus it does not have a source and thus it is not open source.
>>
>>55915532
>learning Java is equal to a CS degree
Wew.
Take a look at a plan of study from a university with a CS degree known to be great.
>>
>>55912053
I bet you selected some shitty uni.
Thread posts: 317
Thread images: 28


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