[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: 318
Thread images: 50

File: Homura_DPT_rust.jpg (128KB, 563x712px) Image search: [Google]
Homura_DPT_rust.jpg
128KB, 563x712px
Old thread: >>57955720

What are you working on /g/?
>>
>>57959249
First for D
>>
File: 1471120613083.png (56KB, 625x333px) Image search: [Google]
1471120613083.png
56KB, 625x333px
>>
Fucking hell, missed the AoC leaderboard today because of a stupid mistake (missing minus sign in my regexp).
>>
>>57959086
>poor design
Sure there's some terrible choices you can make that makes programs horrendously slow. But when you consider larger applications the penalties you take with higher level than C languages get fairly significant.
>>57959086
>the choice of python was also made considering cost
I just find that hard to believe. You're dealing with processed input. What can you possibly do that'd be so much easier in python than it is in C or even C++ if you're naughty.

Of course I can't actually know because I don't know all the details but in the general case python especially (a slow interpreted and or poorly compiled language) doesn't seem to fit that use. I can see it work well for things like IRC bots. They almost exclusively deal with input and output and very few transformations are made.
>>57959218
All this seems to be presuming the software has barely anything to do. For me performance expectations are set by the competition.
>C can't be written quickly compared to higher level languages
I can't honestly say my experience with higher level languages is deep enough to argue on this point but there is some universal rules for software development you can apply to gauge. The programmer has to tell the computer what to do in some way. With C I write quite a few lines that would probably be unnecessary in other higher level languages. But they're often just filler time that doesn't really have significant impact on development. Its the thinking that goes behind the general decisions of what to do that is the hard work. And while I can appreciate that the filler does take time the gains are rather large in quality for the end users if they only have to wait a second instead of 30. Or we can send them updates every 5 seconds rather than every minute.
I'm not part of marketing or UX research but I'd imagine that's greatly appreciated.
>>
>>57956096
Doesn't the first option create four new functions every time you run it while the second only create "static" functions on the prototype that are then referred to when you create an object?
The second option would theoretically only use a fourth of the memory used by your first option to create new lolies (I know VMs would probably optimize but let's focus on semantics).
>>
>>57959272
Surprised 'expensive disaster' isn't on there.
>>
>>57959322
>All this seems to be presuming the software has barely anything to do.

This is why I mentioned embedded and gamedev specifically as exceptions. If you're working on something that's going to be straining its devices resources just to accomplish its basic goals, then you need to care much more about performance to get your program to function and respond without any lag. That's the kind of context where C++ and fine tuning memory allocation is appropriate. Most programs are not doing anything that's inherently going to push the limits of whatever they're running on, though (think Slack, Steam, Spotify, etc) and that's what I'm talking about. Those apps are absolutely not competing on hardware performance, the average user doesn't even know what that means.


>With C I write quite a few lines that would probably be unnecessary in other higher level languages. But they're often just filler time that doesn't really have significant impact on development.

Take this with a grain of salt as I've only professionally really been using C++ for a few months now and worked in mostly high level languages before that, but in my experience this isn't true. It's not just the few extra lines for converting ints to floats or dereferencing pointers, it's the whole ecosystem and intellectual overhead you have to deal with when you're manually managing memory. You have to structure your entire APIs around dealing with it, there's a whole host of potentially fatal bugs spawning from it you always have to code defensively against it, and entire possible program structures are impractical to try and actually implement because of those issues.

I could write a simple JSON returning CRUD API server endpoint for a resource within fifteen minutes with RoR, maybe an hour or two if you added user authentication with email validation. I am a shit C++ dev still so I'm sure that's part of it, but I just don't ever see myself getting to that level of speed with it.
>>
>>57959470
>I could write

(I'm using the term "write" here loosely, since
rails g
at the terminal would handle 99% of what I'd need to do. But the general point stands.)
>>
My WebGL isn't behaving how it's supposed to, and I can't tell why.
It's like the camera is orbiting objects when it rotates, even when the objects are distributed randomly around (0, 0, 0) and the camera is also at (0, 0, 0).

Anyone able to look and tell what's wrong?
https://mega.nz/#!h99xmI5R!kFdiStdXPdt3MW6O7-0daTiL_Buqva1hIPA0-tuM6c8
I've currently got it so that things are coloured by their z position, but the objects have individually coloured faces if colour = position.zzz; is taken out of the fragment shader.

The mistake is probably in renderBuffer.
>>
>>57959586
why not pastebin
>>
>>57959322
>Sure there's some terrible choices you can make that makes programs horrendously slow. But when you consider larger applications the penalties you take with higher level than C languages get fairly significant.
What I'm trying to say is that slow down from language implementation does not scale, but slow down from algorithm and data structure choice does scale.

>I just find that hard to believe. You're dealing with processed input. What can you possibly do that'd be so much easier in python than it is in C or even C++ if you're naughty.
It's a distributed system. The other Python program is a server that processes the data and forwards it somewhere else.
>>
>>57959612
To save the trouble of creating the 4 files needed, it's not all in one file.
>>
>>57959825
>all that effort
>>
I need a little help /dpt/... Whats the best way to take the values from one dict and turn them into the keys of a new one, as well as taking the matching values' keys and turning them into a list of values for the new keys... I'm trying to use dictionary comprehension, but it only returns a single value instead of all the matching ones... heres the code:

def group_by_owners(files):    
grouped = {key: value for [value, key] in files.items()}
return grouped

files = {
'Input.txt': 'Randy',
'Code.py': 'Stan',
'Output.txt': 'Randy'
}

print(group_by_owners(files))
>>
Trying to make a 3d rail shooter for fun

I've run in to a dilemma deciding how to control enemy movement, and its a problem I feel stems from a lack of research, but i don't know where to begin.

I want a system that makes it easy to define enemy movement, something as simple as moving in a straight line. But i want the flexibility to combine several behaviors such as an enemy that follows a curve, speeding up and slowing down to maintain a distance from the player. i originally though of making a Controller class that produces behaviors based on a string, like "s[10,3,5][5,3,9]" could just be a straight line movement. I decided against it because i was afraid it would get excessively complicated for things like bosses, which might also need to react to events and have defined states.

Is there some obvious pattern that i'm clearly overlooking?
>>
File: 1347254586576.jpg (162KB, 600x631px) Image search: [Google]
1347254586576.jpg
162KB, 600x631px
I have a revolutionary idea of unifying all programming languages, /b/!
We could have a couple of shared files, so (probably already compiled) program modules would process them in an unified way! Then everyone could choose her* favorite HLPL and write big programs!
* - Because we are all ice fairies here!
>>
>>57960133
>/b/
>>
>>57960196
/g/ is just /b/ rotated a bit
>>
>>57960287
No, that would be /q/.
>>
>>57960297
/g/ is just /q/ with a longer curlier tail
>>
>>57959249
can somebody do that, but with nice haskell code?
>>
>>57960404
The rust code in that picture was chosen for a particular reason.
>>
merci beacoup, je t'aim un omellete du fromage
>>
>>57960407
Why was it chosen?
>>
>>57960418
https://doc.rust-lang.org/rustc-serialize/rustc_serialize/json/
>>
>>57960460
explain
>>
>>57960460
I love Rust now.
>>
>>57960473
The example under "Using Autoserialization".
There is also another bit under "Verbose example of ToJson usage".
>>
>>57960407
>>57960460
Haskell has a 3rd party JSON library that does this.
>>
>>57960518
what does it mean?
>>
>>57960537
here's a link
https://wiki.haskell.org/GHC.Generics

GHC.Generics is not 3rd party, but I mean 3rd party libraries like Aeson (which use GHC.Generics to provide stuff like autoserialisation)
>>
>>57959318
>Using a regex
There's your problem.
>>
>>57960537
>>57960543
I can't really get any closer without explicitly telling you what it is.
It has nothing to do with the fact that it's JSON.

>>57960592
>I'm too stupid to use regex
Regular expressions are fucking magic and are an extremely elegant way to solve some problems.
>>
>>57960612
explain
>>
>>57960629
Explain what?
>>
>>57960612
>Regular expressions are fucking magic and are an extremely elegant way to solve some problems.
I'd rather just code up an applicative parser using ReadP or -- if the situation warranted extra complexity -- Parsec.
>>
>>57960612
>It has nothing to do with the fact that it's JSON.
No, I'm saying Haskell has a 3rd party JSON library that does autoserialisation.

GHC (the main Haskell compiler) has an extension Generics which includes the GHC.Generics library, which lets you (or others) program generically on datatypes, so 3rd party libraries like Aeson can write their own autoserialisers

For instance, you have this:

data MyType = MyType { x :: Int, y :: String, z :: [Double] }
deriving Generic


deriving Generic exposes a bunch of information, so that libraries like Aeson can create generic default implementations

So then you do

instance ToJSON MyType

And this is like an interface, except because of Generics, you don't actually have to implement the methods. Aeson can do it for you.


as for regex, use parser monads instead
>>
>>57960637
explain it
>>
>>57959586
Anyone able to take a look at it?
I've done what the best WebGL tutorial I can find says to do, but still I get weird results.
>>
>>57960663
Haskell also has had built-in auto-implementations for certain typeclasses for a while
But those are done by the compiler (while in this example, deriving Generic is done by the compiler, and libraries can do everything else, including those old auto-implementations)


Eq (Equality)
Ord (Ordering)
Enum (Enumeration, like a C enum)
Show (toString)
Read (from a string)
Bounded (has a minimum and maximum value)
>>
>>57960663
Nobody fucking cares about your JSON autoserialisation.
>as for regex, use parser monads instead
And what advantages does this have over regular expressions for parsing a regular language?
Don't bring up context-free languages or any of that shit.
>>
>>57960697
Parser monads can parse HTML


and you were pretty ambiguous about what you meant
i thought you meant you were referring to autoserialisation or auto implementation rather than it being about JSON
>>
>>57960705
>Parser monads can parse HTML
A non-regular language. I told you not to bring that shit up.
Regular expressions are for regular languages. Of course they suck for context-free languages; they weren't designed for that.
>>
File: 1476456024903.jpg (44KB, 639x628px) Image search: [Google]
1476456024903.jpg
44KB, 639x628px
trying to pass an array of void pointers as a function parameter and then iterate through them but i cant get it to work like i want

void func(void *ptr, int amount)
{
int c = 0;
while(c < amount)
{
cuckme((t_1 *)(ptr++));
c++;
}
}

void main()
{
void *a, *b;
void *ptr = {a, b};
func(ptr, 2);
}


anyone have any ideas?
>>
>>57960697
>And what advantages does this have over regular expressions for parsing a regular language?
A well-written monadic/applicative parser is going to be easier to maintain than a well-written regular expression. I also like that I can easily parse strings into more complex datatypes.
>>
>>57960730
It's been awhile since I've worked seriously with C, but shouldn't that be void **ptr
>>
>>57959249
So I've never learned a language without GC. Most of what I learned was all shit related to webdev type stuff (or at least I chose them because of web-related stuff).

I was thinking of jumping into Rust, mostly because the Redox project interested me, and I wanted to be apart of something.

That said, is there anything I should know, before throwing myself into this seriously?
>>
>>57960730
>ptr++
Pointer arithmetic on void pointers does not work, because 'void' doesn't have a size.
There is a GNU extension making size(void) to be 1, and have pointer arithmetic work, but don't do that shit. It's stupid.
What you actually want is
void func(void **ptr, int amount)

>void main()
Please don't do this shit.
main returns an int.
>>
>>57960721
a parser monad can do both, and uses do notation rather than insane escape sequences and arbitrary letter combinations

plus you can actually compose stuff and do computations
>>
>>57960750
right sorry ptr is void **ptr

>>57960763
okey, how do I increment ptr correctly in the loop though? its 32-bit
>>
How did you guys learn to program? I've been trying for months to learn but I don't feel like I'm getting any better or learning anything. How do I get over the hump? Why am I having so much trouble if children can do this shit?
>>
idea:

to use facebook messenger whilst offline, set up a bot on computer or heroku to wrap messages back and forth from phone using some free texting platform

facebook already has an API for messenger, so the only obstacle is finding a texting service with an api or just bruteforce it (the much worse option but oh well)
think this is pretty good lads

maybe impractical because you have texting already but would be nice for long road trips
>>
>>57960814
Stop, if you can't do it, then stop.
You haven't even tried, btw, you think you have, but you haven't.
Apply yourself you stupid niggr.
>>
>>57960737
>>57960775
With more power comes more complexity.
Regular expressions are very "dense", so you can write them very compactly and very quickly. That's probably why they are so popular in shell scripting.
They are also very efficient to execute, assuming you don't do any retarded non-regular things, like using back-references.

Also, monadic parsing is tied to Haskell (and maybe some other obscure functional languages), a language that barely anybody uses.
>>
>>57960789
void func(void **ptr, int amount)
{
for (int i = 0; i < amount; ++i) {
cuckme(ptr[i]);
}
}
>>
>>57960838
And with your compact code that you wrote very quickly, you lost your spot on the AoC leaderboard
>>
>>57960859
I'm not the original person who mentioned.
I not a part of the Allegiance of Cucks or whatever the hell that reddit shit is.

I'm just someone who uses regular expressions a lot in shell scripts.
>>
>>57960872
>who mentioned
who mentioned regex*
>>
>>57960872
are they always more efficient? I remember during my compilers course in second year that they aren't poly-time. Please correct me if I'm wrong. Actually I'll just google it.
>>
>>57960872
>>57960888
oh fuck I'm dumb. I didn't notice this
> don't do any retarded non-regular things, like using back-references.

Seems WITH back-references there is a reduction to 3SAT. u rite.
>>
>>57960838
you can implement the parser monad in any language, but it looks less like

(\w+)*
and more like
many (many1 word)
>>
>>57960850
alright ill try it, thx
>>
>>57960908
or for instance, if you LITERALLY wanted (\w+)*

with parsec this is just
string "(\\w+)*"
-- that \ is escaped into a string literal

with regex this is something like \(\\w\+\)\*
>>
>>57960902
Yeah, with those retarded "non-regular" regex implementations, the worst case is atrocious.

Note the logarithmic scale.
Source: https://swtch.com/~rsc/regexp/regexp1.html
>>
>>57960918
>"(\\w+)*"
>Stop using regex by using regex instead
What?
>>
>>57960958
If you wanted to match the string "(\w+)*" or do some operations with it using regexes, you'd need escape characters out the ass. With Parsec, you just need to escape the slash
>>
>>57960958
I think you misunderstood what I meant by literally

see >>57960969
>>
>>57960969
>>57960972
and the only reason you escape the slash is because it's a haskell string literal
you don't need to worry about the string having the parser built into it, as in regex
>>
>>57960969
>you'd need escape characters out the ass
Oh well. That's not a particularly big drawback.
>>
File: 24231.jpg (54KB, 500x500px) Image search: [Google]
24231.jpg
54KB, 500x500px
>>57960993
>That's not a particularly big drawback.
>>
>>57961000
Right. That is exactly what I said.
>>
>>57960818
aight guess I'll just do it

unforunately textfree has no api so this goin take a while
>>
number = read <$> many1 digit
parser = do
n <- number
replicateM n letter
>>
>>57961071
That is non-regular.
>>
>>57961104
it's just a demonstration
>>
how the fuck do I bring back my fork in sync with the actual project on github?
>>
File: parsec.png (10KB, 374x249px) Image search: [Google]
parsec.png
10KB, 374x249px
>>57961104
Oh, and unlike regex, you'll get error messages, including source position

For instance, that particular one expects a number n, and then n or more letters
>>
>>57961141
rebase? pull?
>>
File: 1476701925359.jpg (17KB, 250x250px) Image search: [Google]
1476701925359.jpg
17KB, 250x250px
Is Haskell still shit at realtime?
>>
>>57961155
I do all my realtime work in node.js
>>
>>57961155
It's garbage collected
>>
>>57961155
haskell is shit at anything but masturbation so yeah
>>
>>57961148
Wow, your context-free language parser has the features that a context-free language parser usually has!
So amazing!
>>
File: 1476818921741.jpg (621KB, 1920x1080px) Image search: [Google]
1476818921741.jpg
621KB, 1920x1080px
>>57961160
is this viable?
>>
>>57961175
why are you so mad?
>>
>43 code review comments

>HURR YOU SHOULD BIND THIS TO YOUR ANONYMOUS FUNCTION INSTEAD OF STORING IT AS A VAR AND USING JAVASCRIPT'S CLOSURE INHERITANCE

>YOUR WHITESPACE IS WRONG!!!!!

> THERE NEEDS TO BE A SPACE AFTER THIS IF BECAUSE OF OUR RETARDED CODE CONVENTIONS

Someone kill me.
>>
>>57961218
>waaah i'm so popular

>you will never know this feel
>>
>>57961202
He's too intelligent to learn haskell
>>
>>57961218
>I submitted some code while ignoring all contribution guidelines
>why do these people tell me that there's something wrong with it?
>>
>>57961238
>Standalone project in a language that hasn't been used before by this company for which there are no guidelines
>WAH WHY ARE YOU NOT USING OUR JAVA GUIDELINES FOR JAVASCRIPT
>>
>>57961251
Start maintaining a fork then where you decide what goes into the project.
>>
Just wok up, what am I looking at here?
>>
>>57961351
>>57961218
for this
>>
>at University for CS
>never really programmed but have always been interested and figured I'd get taught
>lecturer is a pretty autist tier, has a big beer gut, about 50 years old and only gives help to the two females in the class
>ask a question get slammed for not knowing the answer already
>have his BO ridden pits right next to you as he points to some code on the screen or snatches the keyboard off of you
>never actually answers your question
>goes back to semi-sexually-assaulting the two females in the class
>the two poor third year tutors desperately run around trying to help everyone but even in a two hour class they get around to maybe helping 20% of the class
>have to program in Java
>have to use Vim
>can't touch the GUI at all
>the first few weeks were easy just designing a program to calculate various measurements of shapes given user input
>after a poor lecture on looping we are told we must implement it into our code to do some pretty fucked shit
>try and fail, ask for help - get none
>live an hour away from Uni so can never get to the after class 1-on-1 tutor
>fuck this it's not for me
>everyone is 104392435245345354x more autistic than I anticipated
>I don't want to work professionally with people like this
>drop CS related subjects
>keep my Math/Stat related subjects and absolutely fucking ace them
>changing degrees

Has put me off programming, at least in that environment for a good while
>>
>>57961364
Jira comments.
>>
>>57961375
>>everyone is 104392435245345354x more autistic than I anticipated
>>I don't want to work professionally with people like this

At least in my experience the autistic people never got jobs
>>
>>57961398
Yes they do, usually as supervisors or some shit.
>>
>>57961398
I thought about that-
And then I thought about having to withstand another three years with classrooms full of people who don't shower, wear deodorant and can barely socialise. Would have to do group collaborations/assignments with these people-
And then I switched degrees.

Despite saying it was open to people at a beginner level it was clear they wanted to wean out the people who were just curious and only wanted to keep the most autistic of the bunch. Think University's ties with the CSIRO was requiring them to push for autistic CS students in an attempt to make a breakthrough reflecting well on both of them
>>
>>57961375
>>57961450
>complain about autists on Autism Central
wew
At least you've made what's good for you, anon.
>>
>>57961375
>>drop CS related subjects
>>keep my Math/Stat related subjects and absolutely fucking ace them
>>changing degrees
Good choice
>>
>>57961513
Yeah, I sort of figured it would be full of autists but I COMPLETELY underestimated it
>>57961532
Cheers, will probably learn some sort of programming in new degree but it won't be autistically focused around it
>>
>>57961375
>americans pay tens of thousands for this
>>
What's the point of teaching yourself to code if you don't want a job in it? Can you make cool things that are useful? What can you even do with it? Is it fun?

Dumb math major asking. We dont take any CS classes in my major
>>
>>57961676
I only did a semester but wasted about $4k on the classes I dropped. Don't have to pay it upfront though because not American so it's an interest free loan with the government that only gets paid once you make over like $50k a year and even then it's only taken out in very, very small amounts over decades. Government still can't supply good internet though
>>
>>57961695
Yes, you can make cool things that are useful
>>
>>57961695
> Can you make cool things that are useful?

The computer is the universal machine you can do (almost) anything you want.
>>
>>57961695
>What's the point of teaching yourself to code if you don't want a job in it? Can you make cool things that are useful?
You can write some neat automation stuff for your computer.
I have a bunch of little scripts that I have written that do things like fetching and sorting files, and a few other things.
I've written some more complicated programs to deal with IRC and some other things, but I don't use them anymore.
>What can you even do with it?
Practically anything which is computable, which is quite a lot.
There is actually a bit of imagination that goes into this, because of how much you can do.
>Is it fun?
I consider it to be fun. It's sort of like a problem solving exercise.
>>
>>57961695
Writing a program is almost the same thing as writing a proof. If anything, it's good practice, and you actually might end up with something useful or cool.
>>
File: fragzeichen.jpg (91KB, 1280x720px) Image search: [Google]
fragzeichen.jpg
91KB, 1280x720px
Why is it that when you ask people to justify OOP, the first argument they reach for is "employment?"

That seems like a really bad argument.
>>
>>57961773
it's the only half decent reason
>>
>>57961773
It is a really bad argument. It just boils down to "It's good because we use it".
It shows that they really don't think critically about anything they do, and are just code monkeys.
>>
Has anyone read a book on making games in C?
Or are all of the good books in C++?
All I know is python at the moment and it's shit for games.
Or should I learn opengl? I'm not sure what to learn.
I want to start out making a side scroller.
Any advice?
>>
tfw worked too much last week so have 3 days off

I woke up at 9am and already bored but I'd want to hack on work project... Kill me
>>
tfw when writing a seasonal content system for a game for 3 days now and its finally working on all platforms n shiet.
>>
File: 37256.png (899KB, 1200x675px) Image search: [Google]
37256.png
899KB, 1200x675px
>>57961864
>>>/v/

man children out
>>
>>57961761
>>57961737
>>57961733

Thanks for the answers guys. I guess I'll start looking into it a little more. >>57961767 intrigues me a little bit
>>
>>57961893
if you write in Agda or Coq or Idris then writing a program literally is writing a proof
>>
>>57961887
since when do gamedevs not belong on /g/ fagget ?
>>
>>57961911
4chan is 18+
>>
>>57961155
Haskell getting linear types soon to deal with GC latency, can't tell you details because I don't think it was announced publicly yet

t. inside source
>>
>>57961931
https://ghc.haskell.org/trac/ghc/wiki/LinearTypes

i hope at some point it becomes possible to write GC-less Haskell
>>
File: you-re-gonna-need-a-bigger-bait.jpg (45KB, 1000x1000px) Image search: [Google]
you-re-gonna-need-a-bigger-bait.jpg
45KB, 1000x1000px
>>57961929
>>
>>57961948
that page was written on a payroll bit the person in question no longer works there; AFAIU he's continuing research but what that page lacks is motivation for linear types in GHC which has been written and will be implemented (and paid for) separately
>>
>>57961931
Are you ekmett's fluffer or something
>>
/dpt/ how do you come up with projects to work on?
>>
>>57962018
I had to look up fluffer but no, I just work in a Haskell shop where it's relevant
>>
>>57962043
Neat. What kind of work do you do?
>>
>>57962035
Every now and then, I just get an idea for something I want to do.
>>
>>57962052
This and that, rather not say because it'd be easy to figure what shop it is. For most part anything we're contracted for; personally working on longer term project running on clusters interacting with C component
>>
>>57962094
Makes sense. I wouldn't want anybody here to know where I work either.
>>
>>57962194
I mean it doesn't really matter but if I don't say so then it's easier to answer questions without having to worry about some busybody running around yelling "hey guy from X said they do Y on 4chan!!!"
>>
File: link_waker.jpg (10KB, 250x250px) Image search: [Google]
link_waker.jpg
10KB, 250x250px
Is it possible for uni drop-out to get a job?
It's not like I want to pay for the reentry or get three years spent for nothing because I'm on the first year again.
>>
>>57962255
Absolutely.
Though you will most likely have to start with a low-pay one and work your way from it.
>>
I have a really simple hash function. It just starts with an initial value, iterates through a string, and modifies the hash based on the letter indices.

Is there any easy way to reverse a simple hash like this? My goal is to find a specific string that would lead to a predetermined hash function. The only other thing I can think of off the top of my head would be to brute force it.
>>
>>57962299
Depends on how it modifies the hash. Use a real hash function for whatever it is you're doing
>>
>>57962255
Learn OLAP Cubes, get an MS cert and do Business Intelligence?

It's a relatively large field, there isn't any real course for it at universities, and you do actually useful stuff.

And you get to choose: Do you want to make all-cloud tools (chart with high-chart) that are HTML only and work with any device, do you want to make reporting services that files taxes and shit automatically, or a mix?

Just get in touch with some BI consultancy firms and ask them what you need to get a job there.
>>
File: 1476192694539.jpg (42KB, 380x400px) Image search: [Google]
1476192694539.jpg
42KB, 380x400px
how does one check if 2 4d vectors are on the same line? Im at a loss.
>>
>>57962383
Divide pointwise and check if you get whole number I guess
>>
>>57962299
>Is there any easy way to reverse a simple hash like this?
depends, is there any "loss of information"? if yes, then it's a one-way function.

for example

in f(X) = 1 where f(X) -> X % 2, it's impossible to say what exact value X was. (but, it's easy in this case to find a collision)

now, if you start playing with bit shifting, then the lost of information become too much to find a collision easily.
>>
>can't find solution to math-related WebGL problem
>try see if I can inspect already existing WebGL applications for the answer
>they all use three.js
>>
How to you assign input keys to console commands in C#?

I know ReadKey () means any key, but how do I assign a specific one?
>>
>>57962640
if (ReadKey() == Keys.A)
>>
>>57962413
One way function means that you can't "easily" reverse it. That is, given Y, it's almost impossible to get an X such that f(X)=Y unless you brute force it. It may very well even be bijective on some interval (that is, permute it).
>>
>>57962658
>>57962413
By "very simple", here's the hash function in question:

def hash(s):
h = 321
letters = "rstlne"
for i in range(len(s)):
h = (h * 666 + letters.find(s[i]))
return h


I can obviously brute force it but it's going to take hours. It's just for a puzzle so I was trying to be clever and reverse it. Which might be obvious if I'm retarded since it does seem quite simple of a hash function.
>>
>>57962383
cross product and check if zero
be aware, cross product is different for 4-dimensional manifolds
>>
object-oriented code is easier to maintain, reuse and scale than any of your meme functional code but i guess you guys will come to realize that when you finally get employed.
>>
File: calc.png (13KB, 470x257px) Image search: [Google]
calc.png
13KB, 470x257px
>>57962653
Come again? Sorry for being a gigantic newfag, I'm trying to learn from scratch. Exactly where would I insert your line? I thought it would just go next to the function but it returns errors and the built-in solutions don't look right.
>>
>>57962811
replace the line
Console.ReadKey if (ReadKey() == Keys.A)

with
if (Console.ReadKey() == Keys.A) {
//do shit here you want to happen when A key is pressed.
}
>>
File: calc2.png (11KB, 676x244px) Image search: [Google]
calc2.png
11KB, 676x244px
>>57962843
How do I create context for Keys?
>>
>>57962901
right click it in muh ide and click "fix"

or import it
>>
>>57962803
but you never maintained functional code, how would you know, if it is harder otherwise?
>>
>>57962803
>object-oriented code is easier to maintain
How so? I've always found the opposite to be true, which is why functional programming has been picking up in recent years.
>>
>>57962803
Nice baseless conjecture you have there.
>>
>self paid haskell dev
>any jon i want
>800k started
>>
AoC day6
What I'm doing wrong? result is "gggggggg" because there are letters with same frequency.
Also, advice on coding style, it's shit.
fp = open("input6.txt", "r")

freqs = [dict()]*8
for line in fp:
line = line.rstrip()
for x in range(len(line)):
if line[x] not in freqs[x].keys():
freqs[x][line[x]] = 1
else:
freqs[x][line[x]] = freqs[x][line[x]] +1
result = ""
for d in freqs:
d = zip(d.keys(), d.values())
char = max(d, key=lambda x: x[1])
result += char[0]

print result
>>
>>57962901
Use
ConsoleKey.A


Why are you not using Visual Studio?
>>
>>57962982
>AoC
>>
>>57962995

Maybe he is using .NET Core or Mono on Linux?
>>
File: calc3.png (2KB, 279x67px) Image search: [Google]
calc3.png
2KB, 279x67px
>>57962995
Because Xamarin is cross platform apparently. I'm just following this guy's tutorial: https://www.youtube.com/watch?v=udoMi4mGYYw
>>
Posted in the last dpt but I'm looking for more feedback on a new project idea

essentially you store the files encrypted on a raspberry pi, hook it up to a battery pack and leave it at a location then tell the second party the location, once they confirm they've got it you give them the decryption code

FAILSAFES:
on power loss it wipes
if you plug in any usb without the authentication file it wipes

then you setup a usb with two folders
push
pull
script.py
the script will identify with the device so you know it's authentic, then pull the encrypted files from the PI to the USB then securely delete them from the PI, then it pushes your encrypted files from the USB to the PI then securely deletes them

specifically I want to know if you think it's worth doing to begin with, I mean I'd probably use it a fair bit and is it worth open sourcing it? would anyone actually care about this project or use it?
>>
File: anal beads.png (23KB, 791x313px) Image search: [Google]
anal beads.png
23KB, 791x313px
>>57963076
Console.ReadKey().Key == ConsoleKey.A
>>
File: calc3.png (12KB, 968x97px) Image search: [Google]
calc3.png
12KB, 968x97px
>>57963133
Again, sorry for coming across as retarded. Still trying to understand how basic functions work.
>>
>>57963169
if (Console.ReadKey() == ConsoleKey.A) {
//do shit here you want to happen when A key is pressed.
}
>>
>>57963169

I think the problem is that you don't understand what an if statement is. Think logically about what you are doing; don't just copy paste code without understanding what that code means. You are reading a key from the console. You are asking whether that key is equal to A, and if it is A, you are going to launch some other function.
>>
>>57963169
That goes in your if statement.

Is this your first programming language?

The result of comparing two things ("Is the key they pressed equal to the A key?") returns a boolean, and that needs to be assigned to a variable, or used for something like an if statement.

Look at the screenshot I posted; I'm assigning the result of the keypress to a variable called "input".

Then, I'm comparing that variable (which holds the key they pressed) against the
ConsoleKey.A
value.

If that's true, I write a statement confirming it happened. Obviously, you could do anything you wanted there.

In any case, you need to start reading.

Go here: http://www.robmiles.com/c-yellow-book/

There's a free PDF on the page, plus plenty of code samples. You need to read a little to get a basic understanding of what you're doing.
>>
I'm doing a little something in mysql.

If I make a trigger after update, can I still access the old values before the update with old.column?
>>
>>57963217
>using triggers in a relational database
>ever

There are a few cases where you want them, but I guarantee whatever you're doing should either be done with constraints, or on the application side.
>>
>>57963225
>Implying relational databases aren't great at solving certain problems
>>
>>57963225
Well I'm glad I'm being told this right now by someone on the internet, no one told me that either on the introduction to relational databases course or the database design course I'm doing this little something for.

Seriously though, I can't hassle with the application side right now, and the reference manual is not clear enough, so this is the only thing I need.
>>
>>57963247
I don't believe he implied that at all
>>
>>57963267
Try it out. It would literally take 30 seconds to write the SQL for that trigger, update a row, and verify if you can do that.

I don't think you can get the old values if you're doing an AFTER UPDATE, but I don't understand why you're not just trying it.
>>
>>57963225
I didn't mean to sound sarcastic though, I'm well aware everything I'm being taught is shit and outdated, so if you could you could explain in short why are triggers so bad?
>>
>>57960663
Yeah, same as the rustc-serialize stuff (serde also does the same thing).
>>
>>57962719
this would need 3 additional vectors. where should I get 2 more when input is just 1?
>>
>>57963325
How does Rust expose the info? Macros?
>>
>>57960665
Newfag or dense as diamonds?
YOU decide!
>>
>>57963306
First and foremost, they're sneaky. If you're writing on the application side, and you're inserting/updating values in a table with the application, a trigger could fuck with things very subtly. For example, I saw one person automatically truncate values to fit a format when inserted/updated. On the application side, there's no warning that what you're putting in isn't actually going to be what's there; that should have been done as a constraint, and only accepted values that fit the requirements. Then, the app dev side KNOWS that the input is not okay and they can account for that.

Also, some DBMS have quirks that allow you to avoid them. For example, (not sure if you still can) in MSSQL if you're creating a temp table within the same transaction, it disables trigger activity, so then your trigger gets avoided and you get an application crash later because something didn't happen that was supposed to.

There are also many cases of a trigger fucking up and throwing an error like "arithmatic overflow", so when you do a simple query and get that bullshit, you have NO IDEA what is going wrong, because you don't get any feedback that it's the trigger that's failing, not your query.

They're tools, and they can be put to good use, but more often than not, it's an easy cop out for something that should have been done in a better way.
>>
File: calc4.png (7KB, 642x304px) Image search: [Google]
calc4.png
7KB, 642x304px
>>57963209
Alright, I've now gotten it to recognize 'a' using a variable. However, if I press any other key, it still triggers the "goto start" command, just without the period being generated by my Console.WriteLine; command. How can I stop the program from resetting the calculator by pressing any key other than 'a'?

Also, is it absolutely necessary to have a variable?

Yes, this is my first language, and I'm completely new to programming, unless you count the triggers, events and data sources from Trials Fusion.

>>57963205
>I think the problem is that you don't understand what an if statement is
At this stage, yes, I'm trying to gauge what everything does.

I'm trying to make it so the calculator doesn't reset until 'a' is pressed. If any other key is pressed, nothing should happen.
>>
File: c4.png (6KB, 377x233px) Image search: [Google]
c4.png
6KB, 377x233px
>>57963409
>period
And by that, I mean paragraph, or whatever you call it. (sorry).

Also, forgot to post pic related.
>>
>>57963409
It is impossible to tell what your issue is if you don't post your code.

It is necessary to have a variable if you want to use that value for two things, such as the if statement comparison, and also in the output telling the user which key they pressed. If all you care about is A or not A, then you don't need the variable.

Also, DO NOT USE "GOTO".

You should be using a "while" loop.

while (Console.ReadKey().Key == ConsoleKey.A)
{
// do calculator things
}

// when you get here, that means something other than "A" was pressed
>>
>>57963439
var input = Console.ReadKey().Key;
if (input == ConsoleKey.A)
{
Console.WriteLine("Pressed A");
}
else if (input == ConsoleKey.B)
{
Console.WriteLine("Pressed B");
}
else if (input == ConsoleKey.C)
{
Console.WriteLine("Pressed C");
}

etc
>>
>>57963439
>
if (condition)
{

};


That semicolon isn't necessary...
>>
>>57963374
I'll save this post somewhere. Thanks.

Right now I'm doing something a simple constraint can't and I'm not yet using the applicative layer. I'm automatically calculating rent someone needs to pay after a number of days of renting a storage upon insertion and deletion, and that was pretty easy. But I'm now trying to calculate the new rent if the dates of renting out the storage and freeing it up get changed so that's why I needed to check if after an update on the rentee's table his old and new dates are different.
>>
>>57963333
It's a feature called compiler extension (or syntax extension). It's a system that allows processing the AST at compile time. Here, it automatically generates trait definitions for arbitrary structs:
#[derive(RustEncodable,RustDecodable)]
struct MyStruct {
...
}

where RustEncodable enables struct -> format and RustDecodable enables format -> struct. Libraries can then use the interface provided to implement arbitrary format support in either direction.
The same mechanism allows automatic Eq, PartialEq, Clone, Debug, Display, etc. trait generation.

syntax extensions:
https://www.gulshansingh.com/posts/how-to-write-a-rust-syntax-extension/

Rustc{Enc,Dec}odable ToJson impl:
https://doc.rust-lang.org/rustc-serialize/src/rustc_serialize/json.rs.html
The functions decode (for RustcDecodable) and encoder (for RustcEncodable) are defined automatically by #derive. They take a Decoder or Encoder instance as input and fill the struct, or convert the struct, to the target format. This ToJson implementation shows what Decoder and Encoder may look like.
You can see this as exposing the AST to user code via Rustc{Enc,Dec}odable in a structured and limited way.
>>
>>57963453
Code is here >>57963439

I only want to use the value for one thing: resetting the calculator. Every other key should do nothing, 'a' should trigger "goto", which should reset the calculator.

'While' works, but I also have to press 'a' to activate it at the start. Is there any reason I should be staying away from goto? (which is what the tutorial instructed).

As seen here >>57963409

'a' triggers the Console.WriteLine () before resetting with "goto".
'any other key' skips the Console.WriteLine (), but still resets with "goto".

All using this >>57963439

Again, just trying to understand how it all works.
>>
>>57963573
What tutorial are you using?

If they're recommending goto statements, you need to avoid that tutorial like the plague. goto is incredibly difficult to reason about, and as your program grows, it becomes unmaintainable due to being near impossible to actually read the flow of the code. Don't use goto.

If you need to step into a while loop without checking the condition on the first go, you can use a do-while loop:
do
{
// do calculator things
} while (ReadKey().Key == ConsoleKey.A);
>>
>>57963604
>>57963453
>Also, DO NOT USE "GOTO".
There is literally nothing wrong with thoughtful use of goto statements. Their thoughtless rejection is almost as bad as their thoughtless misuse.

http://web.archive.org/web/20130731202547/http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf
>>
>>57963604
This: https://www.youtube.com/watch?v=udoMi4mGYYw

It's just a multiplication calculator tutorial. My question starts directly after 13:00. He was just using Console.Readkey (), which just means press any key, and I was wondering how to assign a specific key. He uses the "goto" at the very start of the next video tutorial:

https://www.youtube.com/watch?v=OXTK7cnphYY

to reset his division calculator.

Anyway, thanks for the help. My understanding has definitely improved, although I have a long way to go.
>>
File: 1472746453140.jpg (49KB, 600x488px) Image search: [Google]
1472746453140.jpg
49KB, 600x488px
>lispfag and Cfag arguing
>lispfag says that Cfag values speed over correctness
>Cfag immediately posts a reply which makes it clear that he has misread lispfag's post
Glorious.

>>57958867
>>57958883
>>57958950
>>
>tfw few days off work

I should probably do something productive
>>
>>57963665
>being a lispfag
>get into argument
>run to another thread to get backup while pretending to be a third party
>>
>>57963643
Much like the discussion about triggers earlier, the vast majority of their usage is irresponsible and would have been better represented with another design with other control statements.

It's fair to tell a complete newbie that they should not use them, because the likelihood is too high of them abusing them, whereas they would be better served by understanding how to use a better control statement for a situation.

Personally, I use them in one place: doing explicit switch block fall-throughs. I only use them there, because you can guarantee that the goto target label is going to be immediately visible.

I do understand where you're coming from; gotos get an almost dogmatic hatred. That being said, they almost deserve the reputation.
>>
>>57963665
If this is really what gets you your kicks, I pity you.

Fuck C, and fuck Lisp.
>>
>>57963678
Like fapping on /y/?
>>
File: 1472024041354.jpg (342KB, 978x1390px) Image search: [Google]
1472024041354.jpg
342KB, 978x1390px
>>57963688
>getting backup for someone else's argument that happened 12 hours ago in the previous /dpt/
>>
>>57963762
Actually it looks like they carried on in this thread, too.
>>
>>57963761
nyo 'w'
>>
Is there a language with the relative ease of use and features like C# (garbage collection, OOP, etc.) but that is more-lightweight, preferably not tied to one specific platform? I thought of Java, but Java doesn't seem to have any positives except the fact that it is popular. Any suggestions?
>>
>>57964203
d, ocaml
>>
>>57962689
are you still here?
>>
>>57964203
C# runs on loonix, bra.

How about CL?
>>
File: 3dfullmoon0611-0701_laveder.jpg (231KB, 1024x768px) Image search: [Google]
3dfullmoon0611-0701_laveder.jpg
231KB, 1024x768px
Doing some SQL here and I'm trying to change all records that are 'dublin' in the column 'county' to 'lienster'.
SELECT county as provience,price,description_of_property from sales20102016
where county = 'dublin', as 'leinster'
limit 20;


Also note i don't want this to be a permanent change just for a query
>>
>>57964249
>d
But the syntax is shit...
void main() { // Replace anything that looks like a real // number with the rounded equivalent. stdin .byLine .map!(l => l.replaceAll!(c => c.hit.round) (reFloatingPoint)) .each!writeln; }

(Sorry if the code tag fucks up, mobilefagging right now)
>ocaml
Can't into functional yet, need something to work with in the very short future
>>57964288
>CL
^^
>C#
Shit, I didn't know. To what extend is the code portable?
>>
I'm using WinSock 2 to create a SYN portscanner.

Is it just me or is the MSDN documentation and coding style confusing?
>>
>>57964328
Very fucking confusing especially when they have a poorly named type for literally everything and use polish notation or however this is called.
>>
>>57964314
CL's multi-paradigm but mainly imperative, duders.

No idea where this 'LISPs are functional' meme came from. Fucken Scheme.
>>
>>57964294
SELECT 
CASE
WHEN county LIKE 'dublin'
THEN 'leinster'
ELSE county
END AS 'provence'
,price
,description_of_property
FROM sales20102016
limit 20;
>>
>>57964343
Yeah I seem to have the impression that LISPs are functional from Racket. Any idea about C# 's portability?

>>57964341
Opsie, got it wrong...
https://en.wikipedia.org/wiki/Hungarian_notation
>>
>>57964203
>>57964314
Literally .NET Core.

.NET Core is a lightweight implementation of .NET that is also cross-platform.

Runs on pretty much anything, I think it even comes pre-installed on Red Hat Enterprise Linux servers now.
>>
>>57964369
Thanks man! Will look into it.
>>
>>57964314
>But the syntax is shit...
Looks pretty dank to me senpai, of course you don't have to write in a functional style like the front-page examples
>>
>>57964367
Yeah, Racket definitely leans toward functional. Fair enough.

Use Mono on loonix.
https://en.wikipedia.org/wiki/Mono_(software)
>Mono can be run on many software systems including Android, most Linux distributions, BSD, OS X, Windows, Solaris, and even some game consoles such as PlayStation 3, Wii, and Xbox 360.

Also what that dude said about .NET Core, that sounds pretty good.
>>
how do i move objects between two jlists?

.addElement & .setListData dosnt work
>>
File: baka_big.png (2MB, 2000x2000px) Image search: [Google]
baka_big.png
2MB, 2000x2000px
>>57964203
>>57964379
http://www.omnisharp.net/
https://dotnet.github.io/
https://www.microsoft.com/net
>>
File: 1478386544669.jpg (3MB, 2250x3000px) Image search: [Google]
1478386544669.jpg
3MB, 2250x3000px
>>57964354
Hey man thanks, works great I'm trying to add more conditions and would love some more advice.
My attempt:
SELECT 
CASE
WHEN county LIKE 'dublin','meath'
THEN 'leinster'
WHEN county LIKE 'cavan','monaghan'
THEN 'ulster'
ELSE county
END AS 'provence'
,price
,description_of_property
FROM sales20102016
limit 20;
[spoiler][/spoiler]
>>
>>57964472
Seems well enough, but I feel like you should have tables somewhere storing the location information.

For example, two tables called County and Province.
ProvinceID ProvinceName 
1 leinster
2 ulster

CountyID ProvinceID CountyName
1 1 dublin
2 1 meath
3 2 cavan
4 2 monaghan


Then sales would have the countyID on each line and you could do:
SELECT 
p.ProvinceName
, c.CountyName
, s.price
, s.description_of_property
FROM sales20102016 s
JOIN County c ON c.CountyID = s.CountyID
JOIN Province p ON p.ProvinceID = c.ProvinceID


t. bored database guy
>>
If you use OOP or any of its ideas in your code, you're officially the sheep
you so greatly describe about when you say things about Apple fans.

Join the rebels, the one who think different, join the Functional Programming rebels!
Overthrow Codecuckism!

For starters, if you like Java (Ugh!)
- Learn Clojure or Scala!

If you like Python or Javascript (Double ugh!)
- Learn Elixir!

If you like C# or any .Net OOP language (Triple UGH!)
- Learn F#!

Otherwise, read the bible that is SICP!

There's also the Holy Language of Haskell!
>>
>>57964624
/thread
>>
>>57964624
This is pretty good bait, however obvious it may be.

Also, most of the languages in that post, "functional" and "OOP", are multiparadigm anyway.
>>
File: format.png (41KB, 696x383px) Image search: [Google]
format.png
41KB, 696x383px
>>57964570
I get it man, im just a newfriend to this and have other assignments as well; taking my common sense. Thanks for the advice man; means a lot.

Two last question, I also have a year column as shown in pic related, I want to create a query where it groups by year, How would I format the date to only use the year ignoring month and day.[spoiler][/spoiler]

After I get this, I'll be getting the mean and std; I know how to get those but not the median. Do you have an easy way to get it? I've tried COUNT(*) DIV 2.

Thanks again bored database guy

t. stevie wonder
>>
File: homura string.jpg (26KB, 313x500px) Image search: [Google]
homura string.jpg
26KB, 313x500px
>>57960407
What I don't get is why you chose that picture.

Shouldn't you have used something more like this, for example?
>>
>>57964723
>How would I format the date to only use the year ignoring month and day.
>I know how to get those but not the median. Do you have an easy way to get it?

Both depends on the DBMS. Also, is the column actually a date format, or just a string (varchar, text, etc.) that looks like a date?

Are you using MySQL, SQL Server, or what?
>>
File: 1478445807268.jpg (170KB, 750x950px) Image search: [Google]
1478445807268.jpg
170KB, 750x950px
>>57964818
Its type is DATE, and I think its MySQL; XAMMP.
>>
>>57964861
>MySQL
Fuck off
>>
File: calc5.png (40KB, 1257x517px) Image search: [Google]
calc5.png
40KB, 1257x517px
>>57963133
Noob here again. Can you explain why the Console.Write ("Pressed A") isn't showing up?

It was earlier, but ever since I exited the program and re-loaded the file, it stopped.

Just to clarify, it's the same with WriteLine.
>>
File: 1477763922962.jpg (791KB, 1920x1080px) Image search: [Google]
1477763922962.jpg
791KB, 1920x1080px
>>57964875
Why? :^)
>>
File: anal beads.png (5KB, 391x173px) Image search: [Google]
anal beads.png
5KB, 391x173px
>>57964861
>XAMMP
irrelephant

Put your data as CSV in a pastebin and I can write up some SQL statements easy.

Already made the table on my end, just need data and I'm lazy.
>>
What does dpt think of the following
>unless you can make a living off programming you're not a programmer, you're a hobbyist
>>
>>57959249
Game engine in (chicken) Scheme as an excuse to learn:

Natural Language Processing
Speech recognition
Network programming
Functional methods (CPS, ect...)
Machine Learning on a large scale (all NPCs are part of a gene pool with the fitness function being the game itself/player)
Physics (always wanted to learn properly as I stopped too early)
Calculus (yes I'm behind)
Lambda Calculus (well lambda elimination methods since I already use it)
Just In Time Compilers/methods (NPC code is compiled to native at runtime when taken from the dead pool if it's a new configuration)
SDL2, OpenGL and OpenAL (no choice)
Web servers (building because why not when I have half the tools already)
Sandboxing (for mods, loading assets, ect...)


So far I'm learning call/cc properly, have JIT working for simple programs, basic OpenGL code working, OpenAL being less of a pain, Swarm algorithms with SVMs on the way.

Will answer questions if you have any
>>
File: 1475683869969.jpg (550KB, 2113x1309px) Image search: [Google]
1475683869969.jpg
550KB, 2113x1309px
>>57964911
226053 rows; you sure?
>>
>>57964967
I agree with it I mean programmer can mean anything from I wrote one hello world program to I made my own OS, whereas if people used hobbyist and programmer it'd give more information, programmer would mean they're good enough to make money off it and hobbyist would mean they either don't want to make money off it or they're not good enough to make money off it
>>
>>57964983
A sample of 1000 rows will be sufficient. Select and limit 1000, export to CSV.
>>
>>57964967
No, that's just the difference between a professional and a hobbyist.

programmer = person who programs
professional programmer = makes a living off programming
hobbyist programmer = programs for fun

And, you can be both at the same time, becoming a professional programmer doesn't make you not a hobbyist programmer if you write programs in your own time that you do not make a living off of.
>>
>>57965062
hmmm I don't think I've ever heard the term professional programmer, is it a common term?
>>
File: FhV0bMU.png (3MB, 1920x1080px) Image search: [Google]
FhV0bMU.png
3MB, 1920x1080px
Anyone decent in VB.net here?

How do I access this variable/DataTable in another form.

Dim musicalPieces As New DataTable("MusicalPieces")
>>
>>57964624
as soon as you implied that functional programming and oop are exclusive to each other, i knew you were just another cs101 college retard.
>>
>>57965010
http://pastebin.com/nj5dxtsQ
Like this?
>>
File: anal beads.png (39KB, 987x457px) Image search: [Google]
anal beads.png
39KB, 987x457px
>>57964896
You're probably still in your calculator loop. It hasn't gotten to that line of code yet.

You should also learn how to use TryParse to prevent user retardation.

I've written some code for you that does basically what you're doing, just in a more recommended way. Still not great, but this should give you some things to think about:

do
{
float dividend;
float divisor;

Write("Enter the number to be divided:");
if(float.TryParse(ReadLine(), out dividend))
{
Write("Enter the number to divide by:");
if(float.TryParse(ReadLine(), out divisor))
{
WriteLine($"{dividend} divided by {divisor} equals: {dividend/divisor}");
}
else
{
WriteLine("Invalid input detected. Please try again.");
continue; // goes back to the beginning of the while loop
}
}
else
{
WriteLine("Invalid input detected. Please try again.");
continue; // goes back to the beginning of the while loop
}

WriteLine("Hit the 'A' key to quit, or any other key to divide again.");
WriteLine();

} while (!(ReadKey().Key == ConsoleKey.A));
>>
>>57965099
Baited! :^)
>>
File: db0.jpg (40KB, 349x642px) Image search: [Google]
db0.jpg
40KB, 349x642px
>>57965139
>>
>>57965093
>her college still teaches VB

I feel for you, anon. Someday they'll switch over to C#, but unfortunately, that is not today.
>>
anons, I worked at a relative's company as a front end about 4 years ago whilst I was at uni, but havent touched anything since then, and have changed careers.
What's a good language to start out in again, with someone who's coded before?
>>
File: saddogo.jpg (87KB, 600x590px) Image search: [Google]
saddogo.jpg
87KB, 600x590px
>>57965177
everything I google is from fucking 2006-2013 I can't get anything working in this shitty language.
>>
>>57965099
kek

>>57964624
you have no idea what you are even on about... OOP is IN SICP you retard.

Closures == poor man OOP
OOP == poor man closures

You would know this if you actually got past the first chapter of SICP but of course you didn't. You are just one of those "Hurrr fucking durrrr Haskell, Lisp, F# oiewfjorj" retards who talk but never use the tools.

Scala is shit unless you import Cats/Scalaz which is just Haskell with awkward syntax and slow, Clojure is better but painful, Haskell is great for learning and can get you the odd job but you need months of study to even produce simple programs, and F# is pure garbage.

If they use python then great, they are learning. I hate it too (no case/switch, awkward syntax, ect...) but it has it's uses. Yes Scheme is much better for learning for some but not everyone.

Go back to your mother's basement and jerk off to chinese cartoons, you've already shown you can't add anything useful to this thread.
>>
>>57965257
Baited! :^)
>>
>>57965321
Needed to vent from dealing with uni students code so this was perfect.
>>
File: anal beads.png (36KB, 547x797px) Image search: [Google]
anal beads.png
36KB, 547x797px
>>57965100
>>57964723
Aye, that'll do.

Something like this gets the overall median (see pic):
SELECT s.price as 'Median Price'
FROM sales20102016 s, sales20102016 med
GROUP BY s.price
HAVING SUM(SIGN(1-SIGN(med.price-s.price))) = (COUNT(*)+1)/2
>>
File: anal beads.png (21KB, 491x781px) Image search: [Google]
anal beads.png
21KB, 491x781px
>>57964723
>>57965416
So by county:
SELECT s.County, med.price as 'Median Price'
FROM sales20102016 s, sales20102016 med
GROUP BY s.County, med.Price
HAVING SUM(SIGN(1-SIGN(med.price-s.price))) = (COUNT(*)+1)/2
>>
>>57965455
Actually, don't use this one by county; it's fucked up.
>>
Are there any recommended standards/good practices for what the order of functions in a C source file should be?
>>
>>57965479
From smaller functions to big functions using those smaller ones.
>>
File: anal beeds.png (5KB, 569x99px) Image search: [Google]
anal beeds.png
5KB, 569x99px
>>57965477
Yeah man, I ran the overall median, And can't tell if its still running or crashed.

Also I created the two other tables, and was wondering how I place CountyID into sales and have the ID's match up. I have the ID's matched up like here:
>>57964570
>>
Hi guys, there has to be a better way to do this
#include<stdio.h>
void main()
{
int vector[9]; //Array del Vector (N=10)

printf("x1: "); //Pedir Coordenada
scanf("%d",&vector[0]); //Recibir Coordenada
printf("x2: ");
scanf("%d",&vector[1]);
printf("x3: ");
scanf("%d",&vector[2]);
printf("x4: ");
scanf("%d",&vector[3]);
printf("x5: ");
scanf("%d",&vector[4]);
printf("x6: ");
scanf("%d",&vector[5]);
printf("x7: ");
scanf("%d",&vector[6]);
printf("x8: ");
scanf("%d",&vector[7]);
printf("x9: ");
scanf("%d",&vector[8]);
printf("x10: ");
scanf("%d",&vector[9]);


printf("(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
vector[0],vector[1],vector[2],vector[3],vector[4],vector[5],vector[6],vector[7],vector[8],vector[9]); //Imprimir coordenadas


return 0;
}
>>
>>57965852
BUILD THE FIREWALL
>>
>>57965852
yes

I won't say it because you keep spamming /dpt/ with your dumb questions that can be looked up easily
>>
>>57959249
>json

go to wdg fag
>>
>>57965852
what the actual fuck use a loop
>>
>>57965852
print =<< replicateM 10 ((read :: String -> Int) <$> getLine)
>>
>>57965976
readLn = read <$> getLine
it's in prelude

replicateM 10 (readLn :: IO Int) >>= print
>>
>>57966011
That shows how often I do I/O in Haskell.
>>
>>57966033
mapM (\x -> read x :: Int) $ replicate 10 getLine
>>
>>57966076
wrong
>>
>>57966076
Where's the ouput?
>>
If I'm writing C99 should I use _Bool or include <stdbool.h> and use bool?
>>
>>57966103
enum { false, true}
>>
>>57966103
Use Haskell and argue about the Prelude like the rest of us.
>>
>>57966092
>>57966098
print =<<

and haven't used it in over a year

>>57966103
stdbool.h
>>
>>57966128
still wrong
>>
>>57966128
Where's the input?
>>
>>57966103
Just use an int, bool was kind of a pointless afterthought for C
>>
>>57966166
I figure a public interface function explicitly returning a bool is clearer at first glance than one returning an int.
>>
I'm creating a little lottery program on java that randomly generates 5 numbers in an array and then checks them against 5 user inputed numbers in an array and outputs the similar occurences. Problem is - I don't really know how to make the two arrays check each other for similar numbers.
I wrote something like this but all it does is give me a complete random result at the end
     public int Check(){
int [] lotarr=lottery.getlotArr();
for (int i=0; i<plyarr.length; i++){
for (int j=0; j<lotarr.length; j++){
if ( plyarr[i]==lotarr[j])
count++;
}
}
return count;
}
>>
File: shot0033.jpg (310KB, 1920x1080px) Image search: [Google]
shot0033.jpg
310KB, 1920x1080px
/dpt/-chan, daisuki~

Anything interesting in this thread?
>>
>>57966137
fine: print =<< mapM (\_ -> readLn :: IO Int) $ replicate 10 ()
>>
>>57959260
Seconded.
>>
Regarding OOP and SOLDIE, should dependency injection be used for every class I create?
>>
>>57966288
Haskell-kun desu~
>>
>>57965852
if it works then no problem
>>
Lisp > Haskell
>>
File: 1007.gif (3MB, 400x200px) Image search: [Google]
1007.gif
3MB, 400x200px
>gcc -Ofast
>152073367 nanoseconds to 648 nanoseconds

holy fuck...
>>
>>57966447
Lisp <*> Haskell

:^)
>>
>>57965543
Went to lunch, hope you're still lurking.

You'd probably rename the 'county' column as 'CountyID' and do a big conditional replace.

Pseudocode:
UPDATE sales SET county = CASE WHEN county = 'Cork' THEN 1 ... .etc.

Might not be worth it though, and I'd avoid unless this is your project and there isn't anything already developed and running on it.

Hard to say, it's one of those things that would be good to have from the get-go, because otherwise you're doing a lot of modifications. It'll be more maintainable in the long-run, but you have to decide if the value is worth it based on the work now.

There's probably better examples of a median; just google MySQL median groups or something and hit the stackoverflow posts.
>>
>>57966451
Is there any more badass feel in programming than turning -Ofast on?
>>
>>57966475
Lisp $> Haskell
>>
>>57966485
changing a lisp system from interpreted to compiled while it's running by implementing a jit compiler and replacing eval with it
>>
>>57962689
def unhash(hash):
str = ""
while hash > 321:
letters = "rstlne"
char = hash % 666
if 665 == char:
str += "*"
hash += 1
else:
str += letters[char]
hash -= char
hash //= 666
return str[::-1]
>>
>>57966487
Lisp <+> Haskell

:3 <3
>>
>>57966505
(mplus lisp haskell)
>>
File: 1477192042346.jpg (19KB, 500x500px) Image search: [Google]
1477192042346.jpg
19KB, 500x500px
>>57966483
Thanks man you've been a big help :^)
>>
How does call/cc work?

I understand the basic examples (call/cc (lambda (k) (/ 5 (k 0)))) but the others where it calls call/cc inside and set! `k`... just what is going on?
>>
got completely stumped on the last question on a final i took today. you had to use purely equational programming to convert a binary tree to a list without using concatenation in O(n) time where n is the number of leaves

i came up with about 3 ways to do it that each didn't abide by one of the rules, so i ended up turning in a solution that abided all of the rules except the one where it had to, you know, work
>>
File: 1478810833300.jpg (159KB, 544x841px) Image search: [Google]
1478810833300.jpg
159KB, 544x841px
>>57966483
Hey man if your still there. Do you have a job with Data Science; if so would you recommend it.

t. 1st year Computing
>>
>>57965257
Objects =/= OOP though
>>
>>57966356
You should always pass dependencies in. Doesn't have to be in the constructor to be stored, could be in the individual methods.
>>
>>57966574
anyone got a solution? just so i can see it. one way i thought of doing it was traversing the tree and printing nodes to an output buffer, and then reading the buffer. but that's not equational. i also did
treeToList leaf(a) = [a]
treeToList node(x,y) = treeToList(x) ++ treeToList(y)

but that uses concatenation.

i also thought of doing
treeToList' leaf(a) = a
treeToList' node(x,y) = treeToList(x) : treeToList(y)
treeToList' T = treeToList'(T):[]

but that wouldn't compile

i ended up doing
treeToList' leaf(a) zs = a:zs
treeToList' node(x,y) zs = treeToList' x (treeToList y zs)
treeToList T = treeToList' T []

but i don't think that's right because i don't think it does anything
>>
>>57966574
>>57966977
What does equational mean here?

Pretty sure they want you to use a fold or something…?
>>
>>57966849
I mostly do business intelligence, but I do the whole chain.

Basically, we'll find a business case to visualize some data, or do some automation based on data we could potentially get.

If we don't have the data, I'll write a scheduled C# bot to troll for or suck the data from an API, and get it into our DW.

Otherwise, I spend the time joining tables and formatting the query in a way that gives results that our BI frontends can use.

From there, it's working with internal management or the client to display the data aggregated on a pretty dashboard or report.

I like it. I get to play with lots of cool tech and essentially dictate where our company spends money and what tools we use. Been learning Azure things, very cool stuff.

I switch between C#, SQL, and other general application management and network disciplines to make it all happen. Jack of all trades, master of none, so to speak.

Pretty good pay for my area, low cost of living (somewhat rural area) and I'm making well over my bills.

I would just say this: get data analysis, general app-dev, and sysadmin/networking know-how under your belt, and you'll be an easy hire in any city.
>>
>>57967034
equational was something he defined in class. from what i understood it was just another word for functional, removing the possibility of doing something that can be construed as "functional" while really being imperative, like a do block in haskell
>>
>>57967080
…? There is *nothing* imperative about do… To use lists as an example, how is this imperative?

do x <- [1,2,3]
f x


It literally just translates to concatMap f [1,2,3]

How is concatenation not functional in any way?

I'm just really confused about the requirement here
>>
File: 1478979147578.jpg (19KB, 480x361px) Image search: [Google]
1478979147578.jpg
19KB, 480x361px
>>57967037
Thanks for the advice, you didn't have to help at all; but you did. You're Gold in the mountain of Pyrite that most just call /g/. Have a good day Anon :^)
>>
>>57967117
you can read about what he means as equational here
http://www.cs.ecu.edu/~karl/ProgrammingLanguagesAugust2016.pdf
chapter 9
>>
File: 1478283256181.png (125KB, 256x256px) Image search: [Google]
1478283256181.png
125KB, 256x256px
>Install android-studio from the AUR
>After finish downloading, it takes 10 minutes to compress the whole package
>Only to decompress it immediately afterwards to install the package
>Package was 700mb

Why go through the trouble
>>
>>57960133
>/b/
Kek
>>
having some toruble trying to understand java technologies
what exactly is tomcat?
i get that its a server of some sort that can host other apps, but from what i read it can only host web apps
i thought nobody used java for web stuff though
and what the fuck is servlet?
>>
File: 2677067_orig.png (239KB, 710x750px) Image search: [Google]
2677067_orig.png
239KB, 710x750px
I started learning Java and I'm absolutely loving it
is it normal
>>
>this thread lasted 14 hours
Man, /dpt/ is really dying, isn't it?
>>
>>57967393
No
Java's a meme
>>
How should I put curly braces:
main ()
{
// stuff here
}
or
main () {
// stuff here
}
>>
>>57967448
Doesn't matter, just keep it consistent
>>
New thread:

>>57967490
>>57967490
>>57967490
>>
>>57967423
Everybody's coding. Only you are here without something to do.
>>
File: wrong.png (234KB, 500x400px) Image search: [Google]
wrong.png
234KB, 500x400px
>>57967344
>nobody used java for web stuff
>>
>>57966977
>>57967192
Yeah I don't know how it was expected to be solved. You could define difference lists to fulfill O(n) time but to build those you need append (your concat) so maybe not allowed anyway.
>>
>>57966475
>lisp is a function of haskell
>implying
>>
>tfw java midterm today
it was okay.
how many points do u think ill lose if the logic is ok but for some fukin reason it didnt do what it was meant to do. I didnt have time to find the mistake.
>>
>>57968995
>mid term in the middle of december
>>
>>57969032
when do u niggers have ur midterms?
dont u do 2 semesters? if yes from which month to which?
Thread posts: 318
Thread images: 50


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