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

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

Thread replies: 255
Thread images: 18
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>51898447

What are you working on, /g/?
>>
>>51901537
you should use python imo (in my opinion)
>>
>>51901537
typedef U32, U16, I8, F32, etc.

imo
>>
>>51901578
python is garbage fact (fact)
>>
>>51901563
Please do not use an anime image next time, thanks.
>>
http://pastebin.com/hi1R4LAk
One last try, failing this I'll just dump the project and move onto something else because I can't find an answer anywhere.

Need to bind listboxes to this data class in WPF/C#.

Each ObservableCollection should bind to a listbox, and all the children should represent their parents correctly. I haven't a fucking clue how to do this, not one single idea. I've tried more or less everything and it hasn't worked, so I need someone to just spoonfeed me because I'm losing my mind.
>>
>>51901631
you didn't post much code. How are you binding this to your window? What is not working exactly?
>>
File: xh21bJD.png (2 KB, 203x201) Image search: [Google]
xh21bJD.png
2 KB, 203x201
>>51901698
I'm not binding it at all, the methods I've used so far involve using
        public static Mod mod;

public ModuleConfigWindow()
{
InitializeComponent();

lstGroup.ItemsSource = mod.Groups.ToString();
this.DataContext = mod;

This, and all I get is this.

System.Collections.ObjectModel.ObservableCollection.1[SimpleFOMOD.Group]
With one character per listbox entry.

I'm not sure how I'm meant to set the binding up so it reads the observable collections values as opposed to just giving me the name of the property.
>>
best book to learn java as a programming newbie?
>>
9th for D.
>>
>>51901789
Go outside and shit on the pavement.
Holy Krishna will accept you as an honorary member of the people of India and endow with full knowledge of Oracle Java 8 and all of it's best practices.
>>
>>51901750
>>51901698
                if (txtAddGroup.Text != "")
{
e.Handled = true;
mod.Groups.Add(new Group(txtAddGroup.Text, (rboSelectAny.IsChecked ?? false) ? "SelectAny" : "SelectExactlyOne"));
lstGroup.SelectedItem = txtAddGroup.Text;
txtAddGroup.Clear();


This is how I add a new group, just in case you need to know the context in which the Groups exist.
>>
Stacks give me a major hard-on
>>
>>51901840
but im a white neet just looking to get a job maintaining some shitty business app so i can stop being such a drain on society (uk btw)
>>
File: pBeB4X2.png (10 KB, 524x167) Image search: [Google]
pBeB4X2.png
10 KB, 524x167
>>51901698
>>51901750
>>51901843
And this is what I get if I do it this way.
>>
>>51901750
is mod not null there? Where is it initialised?
>>
>>51901888
I'm not really seeing enough code to be able to understand where the problem might be.
>>
>>51901900
At the top here
public static Mod mod;

I seem to be able to add values to it just fine when I set it up like this
>>51901888
I add a value to the object and it just displays "SimpleFOMOD.Group" but not the name of the property.

Here's my github - https://github.com/sirdoombox/SimpleFOMOD

https://github.com/sirdoombox/SimpleFOMOD/blob/master/SimpleFOMOD/ModuleConfigWindow.xaml.cs
and
https://github.com/sirdoombox/SimpleFOMOD/blob/master/SimpleFOMOD/Class%20Files/DataObjects.cs
are the relevant files.
>>
>>51901976
Is there a reason for Mod to be static?
>>
>>51902038
Not that I can think of... Would that make any difference?
>>
>>51902054
Do you know what static is used for?
>>
>>51902038
>>51902054
>>51902060

I tell a lie.

In MainWindow.xaml.cs I pass over inputs, I remember why I made it static now. Apologies I've been working on this specific issue for so long that I'm starting to forget my own code.
 ModuleConfigWindow.mod = new Mod(txtModName.Text, txtAuthor.Text, txtVersion.Text, txtURL.Text, cboCategory.SelectedItem.ToString(), new ObservableCollection<Group>());
>>
>writing code for assignment
>works for all test cases I can throw at it
>send to eval
>10/100 with WA on everything

the fuck am I supposed to do now
>>
>>51902054
Not sure. It should be null is you don't give it a value either way, so not sure why you're not getting errors already.
>>
>>51902070
post all the details and we'll see, otherwise manually compare the answers with what you think the answers should be

most cases I get is that I forget which collection types in python are sorted or unsorted
>>
>>51902074
>It should be null is you don't give it a value either way

If you see: >>51902069

It looks like he does give it a value.

Still shouldn't be static, though.
>>
>>51902116
I get it. how are you binding the DataObject fields to the controls? I'm probably just not seeing it. I was expecting to see it in the xaml.
>>
>>51902149

I'm not him, dawg. Just pointing out that he's got an object there.. just not a good design choice.
>>
>>51902319
oh right, getting mixed up.
>>
django lads
>>
>>51901563
What a cutie
>>
>>51901563
Do not undermasturbate language of Go. It's so simple. It's great.
>>
>>51901789
anyone?
>>
>>51902473
http://progzoo.net/
>>
>>51902522
any book recommendtions?
>>
>>51902539
What do you look for in a book?
Basically, tell us about how you learn and why a book is important to you.
>>
>>51902539
My Java course used this book, it was pretty good
http://www.amazon.com/Java-Introduction-Problem-Solving-Programming/dp/0133766268
>>
>>51902572
i like to read. i learn better from reading something than watching a video for example. i am looking for a book that will teach me java for a total beginner to programming.
>>
>>51901563
I'm getting into internet programming. Currently learning PHP and so far its been indescribably easy. I mean, its kind of a mess at its whole in my opinion, but for someone used to the complexity of C / C++ (and a specially regrettable experience with, ugh, C++ CLI), PHP is quite comfortable.

Anyone got any advices?
>>
>>51902687
Stop learning PHP, it's on the way out for new projects, unless you really really like maintaining early 2000s sites, or competing with the loads of WP developers who do it for free.

Ruby, JS, and Python are where it's at for web development.
>>
Just finished job interview question. Have fun
Your task is to write a program (Linux application in C) that takes a text
file and prints out the number of occurrences of each word.
E.g:
test.txt <<<
Hello, this is a "Hello world"
text file, it is!
>>>
$ occurrence < test.txt
Hello 2
is 2
a 1
file 1
it 1
text 1
this 1
world 1
>>
>>51902735
That's pretty easy. Haven't done C in a while, but can't you just stick a string and an int in a struct, then just keep an array of those?
>>
>>51902735
strtok on space and punctuation, dump tokens into add-or-increment hashmap.
>>
>>51902735
>strip anything that's not a-zA-Z
>strtok and count werds

What do I win?
>>
>>51902757
>>51902758
>>51902760
Efficiency/10
I wrote a trie that sorts itself alphabetically on key insertion.
>>
>>51902770
>I wrote a trie

You're fired.
>>
>>51902735
>it is

Bigfoot?
>>
>>51901563
>>51901563

What language is used for inputting commands in Windows PowerShell?
>>
>>51902770
That sounds like you're making it overly complicated just to show off.
>>
>>51902795

I wrote a Trie in C a few weeks ago (first time ever doing one, and in C to boot) and it wasn't that difficult.

Still, it wouldn't have even crossed my mind for something like this.

It's overkill.
>>
I want to make some shitty websites in python,
What do I need to download so I can mess with django locally?
>>
>>51902846
Python
Django
>>
>>51902770
>Implementing overcomplex datastructures for the task by hand
lmao 0/10 maintainability, and enjoy fixing bugs that the stdlib already covers.
>>
>>51902862
That's all I need to test my websites?
I don't know, I haven't messed with django yet.
>>
>>51902879
Also a web browser
>>
>>51902879
Django comes with a local webserver for development testing.

>>51902891
This too. I recommend Internet Explorer 6.
>>
>>51902891
god damn it
>>
>>51902904
>This too. I recommend Internet Explorer 6.
u cheeky little cunt
>>
>>51902879
If you want to do proper testing, Selenium is a useful tool to have. Again, there are python bindings.
>>
>>51902920
do you mean io.lines or file.lines?
>>
>>51902877
And which stdlib function would that be? The output is sorted by occurrence and alphabetically. I am pretty sure to test it they feed the entire Aspell dictionary into it. The trie stores common characters in each string efficiently.
>>
>>51902934
>>51902920
>>
>>51902937

desu fambly, I would just use kvec.
>>
Working on a skillpoints module for my D&D rip-off. I'm using an AND-style validation system to check if both the character has been named and all skillpoints have been used. If both conditions haven't been met, you can't finalize changes and begin the game.
http://pastebin.com/es2ytTTA

Code would've been too many characters to past here

I'm writing the game in
>VB

I'd like to write it in C++ but I feel intimidated to learn it - it feels really complex in comparison to VB and I'm worried it's going to be too hard for me to learn. Not to mention I have more experience in VB from learning it at school
>>
>not learning c#
>not having fun
>>
>>51903020
As somebody who has programmed in fucking VB until like 8 years ago. Make the change. Go to C# if the change to C++ feels too steep. But dont stay with VB.

VB teaches you bad practices, has partially stupid syntax and there is literally no advantage.

I can only recommend you to switch to C#. Thanks to Microshit monopole, knowing VB will actually make it easier.
>>
>>51903051
>learning c#
>not learning lua
>not making programming great again
>>
>>51903020
Guess insecurity is really a huge barrier to cross.
>>
>>51903065
I have to learn VB for my computing class - I can't avoid it. I want to learn C++ and it's not going bad so far (then again I just learnt how to declare variables) and what puts me off is I look at C++ code and it looks so complex and intimidating to me, so it puts me off. Whereas if I look at VB it doesn't look that intimidating. Is it just a matter of learning C++?
>>
>>51903074
>1-based arrays

ban this sick filth!
>>
>>51903118
Only some arrays are 1-indexed.
>>
File: bjarne2.jpg (25 KB, 293x324) Image search: [Google]
bjarne2.jpg
25 KB, 293x324
>>51903103
>it looks so complex and intimidating to me, so it puts me off.

"I did it all for a laff"

t. Stroustrup
>>
File: gross.jpg (116 KB, 640x480) Image search: [Google]
gross.jpg
116 KB, 640x480
>>51903131
>only some arrays are 1-indexed
You mean indexing conventions aren't consistent across the language? Fucking disgusting.
>>
True or false: the only reason C++ is so successful is because it has some modern features and C compatibility
>>
>>51903163
False.
The reason C++ is so successful is because it's one of the best languages ever made.
>>
>>51902735
Did you have to produce working code, did they give you a computer, or did they just want to see your thought process on a whiteboard with psuedocode?
>>
any links to recent humble books bundle? the avr/Rpi one.
>>
/g/ Which would you say is the hardest programming language to learn?
>>
>>51903190
take home and produce working code
>>
>>51903194
apl
>>
>>51903194
Not sure, but I'd vote ASM as the most challenging to work with.
>>
>>51903152
Perhaps it's like Pascal or Ada, where array indices are consistently bound to arbitrary indexing, and it is therefore standard to use something like Array'First instead of Array(0) or Array(1).
>>
>>51903194
Assembly language for a dialect/processor that isn't popular.
>>
Alright, someone find a hole in this please.

require "sequel"
require "scrypt"

module User
DB = Sequel.sqlite "users.db"

def self.create params
logindata = DB[:login_data]
username = params[:username]
scrypt_hash = SCrypt::Password.create params[:password]

logindata.insert username: username, scrypt_hash: scrypt_hash
end

def self.authenticate params
logindata = DB[:login_data]
username = params[:username]
entry = logindata.where(username: username).first

# Can't find entry
return nil unless entry

# Validate password
password = SCrypt::Password.new entry[:scrypt_hash]
return nil unless password == params[:password]

# Give User ID
entry[:id]
end
end
>>
>>51901563
Please stop this programming trap meme.
Thanks.
>>
what naming convention do you use for member variables?
Some people use an underscore before or after, some prepend m_, some use c-style names like variable_name.

this will throw a shadow warning with -Wshadow:
class Foo
{
int wat;

int setWat(int wat){
this->wat = wat;
}
};

I'm gonna go full autist and try to get literally 0 warnings.
>>
>>51903252
class _
{
int __;
int ___(int ____){
this->__=____;
}
}
>>
>>51903283
>__=
>>
>>51903252
>>51903252

class Foo
{
int _wat;

int setWat(int wat){
this->_wat = wat;
}
}
>>
>>51903310
>
>__=

same desu
>>
>microsoft brings back nsi memory leak

oh wow, I missed this shitty bug.

thanks migroshift
>>
I wanna write a substantial project, what's a good resource for getting started with SDL?
I wanna do a gui and I've never done them before.
>>
>>51903283
this is my new naming style for when I want to get fired.
>>
/g/, pleb here just a small question

if a chained hash table has an array size of x, would that also imply the maximum numbers of entries that can be placed in the table also be x? Or is there no limit?

Like really it feels like I'm asking something retarded but I'm still wrapping my head around this, sorry /g/
>>
File: ItemsTemplate example.png (105 KB, 1620x994) Image search: [Google]
ItemsTemplate example.png
105 KB, 1620x994
>>51901888
If you just set ItemSource to an enumeration of objects, it tries to populate the text by unboxing the item as a string, or failing that, using .ToString(). In order to make it understand what you want to display as the item in the list box, you have to provide an ItemsTemplate...
>>
>>51903315
b-but thats similar to standard names
>>
>>51903352
So long as you can append new items onto the end of your chain for a particular hash value, there is no limit. But your performance will get increasingly shitty the more collisions you have.
>>
What are some neat things I can do with python? library wise
>>
>>51903583
https://automatetheboringstuff.com/
>>
why do people like python so much. Give me one good reason.
>>
>>51903555
Yeah that's what I thought

thanks man
>>
>>51903604
>webbrowser.open
holy fucking shit
thanks a bunch anon
>>
>>51903629
Hi! I like python! It's comfy and easy to use!
>>
>>51903629
I can open a fucking page in my fucking web browser with one fucking line
how fucking cool is that
I come from a couple years of C and some C++ so this is mind blowing
Also, regexes are incredibly easy, comprehensions, etc
Other languages have the tools like comprehensions and whatnot but python is so huge in the industry so there are loads of fucking libraries/frameworks/modules/whatever to do anything you want
>>
Anyone with experiences in linked lists here? Working with it for the first time

I'm trying to make a size() function with O(1) time

Would the best way of doing this in c++ just add a counting variable and make the function return it?

I also thought of using the tail of the linked list, but idk if that would be a good approach
>>
>>51903727
Just store the count. Really you should have two classes, one for all members with just the value and next pointer, and a head for all the methods, metadata, etc.
>>
>>51903727
>Would the best way of doing this in c++ just add a counting variable and make the function return it?
seems like the best way to me. Using tail would be O(n), unless you're doing some weird shit like pointer arithmetic or using an array implementation of a linked list.
>>
>>51903784
>using 2 classes when you can use 1 and static variables
>>
>>51903794
>>51903784
Thank you anons
>>
>>51903194
If we're not counting purposefully so, J,. Otherwise malbolge
>>
how do I get started with embedded C.
>>
>>51904175
Buy some AVRs and a good in circuit programmer.
>>
Whoever was helping me with lua a few weeks back. I have not had the chance to do much programming for a couple of weeks because work and the holidays, but an idea just popped into my head. I've read some stuff before that it's not a good idea to run lua through the graphics/render loop, which is what I was doing. The game logic would update at 60 ticks a second, and the output would vsynch, interpolating the coordinates. Could the bottlenecking have happened in this part of the code?

With programming I have been able to do, I may not have worked so much on the lua, but I did an audit on my code and optimized/re-organized large chunks of my code.
>>
Is anyone experienced in computer vision? I'm trying to develop an implementation of structure from motion but the maths is killing me. Has anyone been successful in implementing a pipeline or using someone elses?
>>
>>51904246
>an implementation of structure from motion
???
>>
/g/, I just want to confirm whether I understand this quicksort thing, idk why but this pivot thing took awhile to get in my head

I'm making the implementation, and I got the following numbers
8 45 2 77 3 88 99 1

I only did the first partition of the implementation so far and it gives me

3 1 2 8 77 88 99 45
am I on the right track? This recursion thing is killing me, I'm trying to get better though
>>
>>51904429
everything to the left of the pivot is smaller than the pivot and everything to the right is greater than it, so the first partition is right I think

it seems you're on the right direction
>>
>>51904429
The pivot is 8?
>>
>>51904429
Divide and Conquer, baby! Did you learn mergesort first? :3
>>
>>51901631
>WPF
There's a reason Mono supports the whole .NET framework except for WPF, you know
>>
>>51904481

Their official stated reason is that it's extremely large, and there isn't enough interest. Large is understandable, especially when there isn't really much of any funding to get them to expend the workload on it, but as for interest... well, given the choice between WPF and Windows Forms, who in their right mind wouldn't take WPF?
>>
Why is this "average 2 ints" thing so big deal? Isn't it simply
a/2 + b/2
?
>>
>>51904598

stop
>>
>>51904598
>anon_takes_the_bait.rtf
>>
>>51904619
(a+b)/2 = a/2 + b/2

The latter doesn't overflow. So will you stop being a retard and give an answer?
>>
>>51904620
>>51904619
>everybody who has been giving stupid solutions for several threads was just trolling
don't give me that shit
>>
>>51904598

a=3
b=3
average = ... 2?

So we have to take into account evens/odds.

And then we may have to take into account one number being positive and one being negative. It's not "hard", it's just that there's more edge cases than would appear to be on one's initial approach.
>>
>>51904306
building a reconstruction of a scene by taking pictures from multiple views and then projecting points from the image plane
>>
>>51904554
There isn't enough interest because there's no reason to use it over WinForms unless you create web sites for a living and wanna try programming
>>
>pedestrian problems like averaging 2 numbers
wew
what's next fizzbuzz to 200?
>>
>>51904702
Fuck me I didn't think of this in practice at all. I guess you could use doubles but that would require you to implement a rounding function first. Why doesn't C have fractions

thanks for answering tho
>>
Any recommendations for free online classes?
>>
>>51903194
GLSL, though it's not the language itself that is the problem
>>
I AM FREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE


FUUUCK

FOR 4 YEARS
I'VE BEEN LEARNING UNDER GRAD SHIT ON A FUCKING SHITTY COMMUNITY COLLEGE

BECAUSE I'M A FOREIGNER PIECE OF SHIT AND THEY WOULDNT TAKE MY GRADES FROM HIGH SCHOOL

NOW I CAN FINALLY
FINALLY
STOP GIVING A FUCK ABOUT GETTING As

AND FINALLY

LEARN THE FUCKING MATERIAL
WITHOUT HAVING TO JUST CRAM FOR GOD DAMN FINALS AND EXAMS I WOULD FORGET THE NETX FUKCING DAY

AND MAY I FINALLY GO TO A UNIVERSITY WORTH A DAMN

AND FINALLY START LEARNING SOMETHING

I FAIL TO FIND A PICTURE TO EXPRESS
HOW IT FEELS TO BE FREED FROM THE CHAINS WE CALL "GPA"
>>
>>51904818
congrats. Why did you move somewhere shitty?
>>
>>51904818
Shut up and finish that login page code monkey.
>>
>>51904837
life
>>
>>51904818
Felt the same when I transferred to uc berkeley desu

then you realized community college doesn't prepare you well enough for these universities and see yourself dying anyway
>>
>>51904858
Where did you move then? Depending on the country the university grades might matter a lot too, so there's that.
>>
>>51904554
>well, given the choice between WPF and Windows Forms, who in their right mind wouldn't take WPF?

Smart people. WinForms is superior and also mature.
>>
>>51904884
This

I got fucked up by the higher standard
>>
>>51903194
The languages itself aren't really what's difficult to learn
>>
>>51904920
depends on the language :^)
>>
>>51904818
>>>/poointheloo/
>>>/curry/
>>>/wearpolostothegym/
>>>/rapewomen/
>>>/smallcondomstoobig/
>>
>>51904939
Most languages are almost identical
>>
>>51904787

>Why doesn't C have fractions
There are about a billion things that could be in the C standard library, that aren't. If you want fractions, you make them yourself.

struct rational {
int numerator;
int denominator;
};
>>
>>51904787
>why doesn't a systems programming language from 1969 have useful modern features
>>
>>51905051
C    C    C
1 1 1
1 1 1


C11 11C


1 1 1
1 1 1
C C C
>>
>>51904990

It also doesn't have vectors. :^^^)
>>
>>51905122
wewwwwwww >:^^^D
>>
>>51905127

desu kvec.h is a godsend. thank u klib.
>>
>>51904754
cool - are you computing the distance from the viewer with parallax?
>>
>>51903194
Haskell
>>
>>51905122
to be fair, if you can't implement vectors yourself, you don't deserve to use them.
>>
>>51905170

Fair enough, but it's nice there are """"generic"""" vectors that people have hacked-in via macros.
>>
Has anyone had success using COOPS (chicken scheme OOP system) across compilation units?
>>
>>51902735
>>51903207

Did you get it working? I'm sort of stumped... I'm trying to loop through the document using AWK
>>
>>51902735

Hash maps are your friend :-D
>>
>tfw you want to use
{-# LANGUAGE QuasiQuotes #-}
but it feels dirty for whatever reason.
>>
whats the hardest sorting algorithm to implement
>>
>>51905285
out of the popular ones, probably quicksort
>>
>>51905285
QuickSort is rather complicated
I've implemented it in different ways but still don't get what it does exactly
>>
>>51904598
> Why is this "average 2 ints" thing so big deal?
Because of overflow, which is undefined behaviour. Basically, C's arithmetic is designed around the assumption that overflow never happens. If overflow occurs, all bets are off, and you can't easily detect overflow.
> Isn't it simply
> a/2 + b/2
That just discards the least-significant bit.
> 4/2 + 6/2 = 2+3=5
> 5/2 + 7/2 = 2+3=5 (it should be 6).
>>
>>51902735
>>51905242
 $ cat input.txt | sed 's/[^a-zA-Z0-9]//g’ | awk '{
for (i = 1; i <= NF; i++)
freq[$i]++
}

END {
for (word in freq)
printf "%s\t%d\n", word, freq[word]
}'

Hello    2
world 1
is 1
this 1
a 1
>>
>>51905346
reading comprehension senpai, output is sorted alphabetically and by occurrence.

Also I'm pretty sure you're not supposed to just use sed and awk..
>>
>>51905346
oops, copied an old version. That should be
sed 's/[^a-zA-Z0-9 ]//g’
>>
>>51905317
Quicksort is the textbook example of a divide-and-conquer algorithm.

Choose a break-point or "pivot". Partition the list into values which are less than the pivot and values which are greater than the pivot. Sort both halves, and concatenate the results. The two halves are sorted and don't overlap, so the overall result is sorted.

All of the O(n.log(n)) sorting algorithms have a similar structure based around recursive subdivision.
>>
I fucking hate this whole python2/3 thing.
I install a bunch of packages with pip and it turns out they were for python 2.

So, I try apt-get install python3-modules etc etc and aptitude gives me fucking 404 on everything.
So I go to the repo in my browser, download the .deb's, and they don't fucking install.
Fuck this shit.
>>
>>51905404
yet another reason python is garbage and shouldn't be recommended for anything but single file automation scripts
>>
>>51905393
Quicksort is really cool. However, despite knowing the concept and pseudo of it really well; I always stuff up the implementation at least a few times.
>>
>>51905374
>output is sorted alphabetically and by occurrence.
it doesnt say that anywhere.
>>
>>51905428
All I want is fucking BeautifulSoup for python 3. Just for a single file automation script you autismo.
I blame my distro more than I blame python.
>>
>>51905443
Look at the sample output. :)
>>
>>51905428
The Python 2/3 split is the major reason for the growth in popularity of Golang
>>
>>51905482
>no generics
I would but I won't
>>
>>51905346
cat test.txt |sed "s/[^a-zA-Z0-9]/ /g" |tr " " "\012" |sort |grep -v "^ *$" |uniq -c |sort -rn
>>
quick question: any good materials for practicing/learning java?
>>
File: slowpoke.png (56 KB, 402x391) Image search: [Google]
slowpoke.png
56 KB, 402x391
Note the branchless implementation

#include <stdio.h>

int main(int c, char** v) {
int a = atoi(v[1]);
int y = atoi(v[2]);
int myResult = a/2.0 + y/2.0 + 0.1;
printf("Your average, friend: %d", myResult);
}
>>
>>51905393
You lost me at "concatenate the results"
>>
>>51905757
get a dictionary

https://www.youtube.com/watch?v=XE4VP_8Y0BU
>>
>>51905775
>computerphile
dropped
>>
>>51905748
int averageInts(int a, int y) { return a/2.0 + y/2.0 + 0.1; }
>>
>>51905821
why
>>
>>51905870
do you not see all of the green on black
>>
File: quicksort.png (47 KB, 2273x2298) Image search: [Google]
quicksort.png
47 KB, 2273x2298
>>51905757
>>
>>51905775
That helped me understand it a bit better, thanks
It also made me realize that my implementation is bad since I'm using the (random) number in the middle of my array as a starting pivot
>>
>>51905905
They're appealing to normies while providing advanced content. Anything else would be college lecture tier
>>
>>51905952
That's a terrible explanation
Please don't try to help me again
>>
>>51905952
i appreciate that you went through the effort to do that, even having gray numbers for the steps and text and whatnot, even if anon doesn't appreciate it
>>
>>51905825

>conversion to IEEE and back
So what do you do when you want to average two 64-bit signed integers?
>>
File: yui.png (633 KB, 1366x768) Image search: [Google]
yui.png
633 KB, 1366x768
anyone have the pic edit of Yui hugging the C Programming Book?
>>
File: ss+(2015-12-15+at+03.14.53).png (17 KB, 564x292) Image search: [Google]
ss+(2015-12-15+at+03.14.53).png
17 KB, 564x292
post grades
>>
>>51906239
Just edit it yourself.
For your sake, get a copy of that image without the subs.
>>
>>51906244
screw grades; post code
>>
>>51906244
>college algebra
retard lol
>>
>>51906244

None because I'm not in college anymore
>>
What is some good language to make a GUI.

I want to learn visual basic family.

can I still make classes like normal languages and use them like other languages?
>>
KEK KEK KEK cuck cuck cuck
>>
File: 1305522698838.jpg (67 KB, 500x334) Image search: [Google]
1305522698838.jpg
67 KB, 500x334
>>51906287
I second this sentiment.
>>
>>51906244
more like lelgebra
>>
>>51906244

>College Success

Now what is that all about? It doesn't look like you've even gotten into the hard stuff yet.
>>
>>51906310
fucking sort your filters out hiroshima
KEK KEK
>>
>>51906329
he's a first year so obviously that's some required course for some program he's in (hopefully)
>>
>>51906244
Only the final grades matter or what?
>>
>>51906244
>tfw A in assembly class but B in java classes taught by poo in loos
I hate pajeets so much.
>>
>>51906342

>College freshmen today were born in 1997
>>
>>51906363
Make no mistake, it's definitely your fault you got a B.
>>
>>51906244
Is this what Americans call "high school"? Pretty cool that you do programming stuff so early.
>>
>>51906373
They're also 18 and can browse this board; reply to your post, even.

:%)
>>
>>51906397
thanks sanjeep
>>
>>51906411
Nah, this is college, also known as university.
The high school (ages 13-17) programming classes are always shit.
>>
>>51906460
Why are there English and history classes? Don;t you specialise in one major?
>>
>>51906477
They force you to take unrelated classes so they'll make more money.
>muh well rounded education
>>
>>51906477
Students have to complete 'General Education' courses in college, which is sort of like a list of required courses in math, science, social studies, etc. Depending on how many credits a student brings in from high school, a university student may only have to take a few Gen Ed courses in college, or may have to take many.

>>51906512
this pretty much tho
(because our universities are expensive as fuck and make mad bank off of us)
>>
File: grades.png (67 KB, 973x352) Image search: [Google]
grades.png
67 KB, 973x352
>>51906244
Great quarter. Managed to fuck a hottie in my Stress Management class
>>
File: 1449198183577.jpg (38 KB, 400x388) Image search: [Google]
1449198183577.jpg
38 KB, 400x388
>>51906577
>Most points awarded is for a "stress management" class
>>
>>51906305
html
>>
Should I do all of my python in Python 2.7, because the support for Python 3 is such fucking shit and I'm tired of dealing with my shitty fucking distro?
>>
>>51902862
>>51902846

Flask too mate
>>
>>51906596
html don't export to exe
good job fag.
>>
>>51906592
GPA boosters
>>
In all seriousness guys, this is how you average in C:

#include <stdint.h>

int64_t average(int64_t a, int64_t b)
{
// If a and b are not the same sign, we can safely add without overflow
if ((a < 0) != (b < 0)) {
return (a + b) / 2;
}
// Otherwise, we take advantage of a particularly useful mathematical
// property: (a + b) / 2 is the same as (a/2) + (b/2). We will use a
// modulus to account for averaging two odd numbers
else {
return (a/2) + (b/2) + (((a%2) + (b%2)) / 2);
}
}


And as a macro
#define avg(a,b) ((a<0)^(b<0) ? ((a+b)/2) : ((a/2)+(b/2)+(((a%2)+(b%2))/2)))
>>
>>51906738
fuck off
>>
>>51906738
based ruby

What's /dpt/'s next challenge?
>>
>>51906769
Maybe we can move on to advanced stuff like finding the area of a circle.
>>
whats the advantage of structuring my python scripts to be run through cron scheduling instead of putting them in a while true loop and running them in a tmux session and sleeping for intervals

it's not like there's any cpu footprint while sleeping in a thread, is it solely for trying to be a jew about memory? whats the point of going through the extra layer at the OS level instead of maintaining the logic in the script?
>>
>>51906769
strrev implementation with O(1) complexity
>>
I'm downloading Visual Studio Community with C# and F# right now. I've only done linux programming for all of my programming life (over 10 years).

What am I in for?
>>
>>51906619
why does it have to be exe? any reason?
>>
>>51906838
welcome to hell
>>
>>51906791
#define PI 3.141592653589793
double circle_area(double r) { return PI * r * r; }


>>51906807
What python scripts? I just learned python over the past couple days and I'm bored, wondering what scripts to write for myself. I could make graphs in excel, but of what, etc.

>>51906853
Because he said in the Visual Basic family, obviously. A really large family, that.
>>
>>51906853
[spoiler]It's for a game[/spoiler]
>>
>>51906867
Can you be more specific?
>>
>>51906880
...and? Games aren't required to be distributed solely as a .exe.
>>
>>51906894
for starters you need to install a program and it's dependencies that take up more room than the windows operating system
and unless you're writing standards compliant C89, your C code will not compile on MSVC
>>
>>51906807
Running with cron gives:
- More configurability
- Update your script without screwing up timing
- Can run script out of time, If you want
- Standard unix way.
- More overhead(Don't use cron for <30 second intervals)
>>
>>51906914
I want to learn something like visual basic anon.
>>
>>51906931
yeah, it's still installing even though I have a 9 megabyte/sec internet download and a fast SSD, this is kinda disappointing

i hope the programming will be cool though, F# looks good
>>
>>51906950
It will not be cool, or fun.
You will suffer for every moment spent with VS open.
>>
>>51906819

Not possible. Not even with linked lists, because even then, you'd need to swap all of the next and prev pointers.

>>51906305

Don't even bother with Basic, just use C#. It's still piss easy to make a GUI with it.

>>51906931

If he's only using it for C# and F#, it'll be fine. Visual Studio for .NET crap is a pleasant experience. For anything native though, run for the trees.
>>
>>51906979
The first element should hold the size of the string, a pointer to the first element and a pointer to the final element.
Every element thereafter should hold a next and previous pointer.

When you want to reverse the string, just follow the pointer that goes to the end and follow the back pointers.
>>
>>51906979
>don't bother with BASIC
I always hear this.
why?
>>
>>51907013
It's a waste of time.
>>
>>51906970
It can't be that bad.. right?
>>
>>51907025
good luck anon-kun
>>
>>51907022
yeah, but why?
>>
File: 2015-12-16_22-45-58.png (12 KB, 456x641) Image search: [Google]
2015-12-16_22-45-58.png
12 KB, 456x641
>>51907037
here we go familia
>>
>>51907012

Yes, but you are iterating over the entire string to change those pointers from next <-> prev. Thus, O(n).

>>51907056

Because there isn't a single use case for it that isn't better fulfilled by other languages. For simply having a beginner friendly language, there's Python and Ruby, which pretty much read like pseudocode. For serious .NET development, there's C# and F#. For scripting .NET stuff, there's F# and PowerShell.

It's a language on life support only of use to companies that have previously invested into it, and half of them are stuck on VB6 (not VB.NET) anyways. Learning a BASIC, realistically, should only be done for the same reasons one would learn COBOL -- they're desperate for a job, and don't mind maintaining old-ass code.
>>
>sending an email to myself in <5 lines of python
I love this. I have to make some program to utilize this somehow.
>>
>go to library
>go to computing section
>they literally have nothing but "for dummies" tier shit and some books on apple ecosystem crap like swift
>literally only 1 programming book and it's an outdated stroustrup C++ book

I remembered why I stopped bothering with public libraries.
>>
>>51907109
>he goes to a liberal arts college
lol
>>
>>51907105
>Yes, but you are iterating over the entire string to change those pointers from next <-> prev. Thus, O(n).
There is no changing.
The first element points to the very end, and then you read that string by traversing every back pointer till you reach the front.
>>
>>51906979
Use a doubly linked list. Wrap it in a structure and maintain a pointer to the head and tail elements. To reverse the string, just switch the pointers.
>>
>>51907105
I guess I could try C# and winforms
but I don't know how to code there.

I feel safe doing normal shit using SDL net or SFML net, but doing shit with drag and drop just confuses me.
>>
>>51906819
As you build the string, also maintain a reversed string. When you want to reverse the string, switch the representation you expose.
>>
>>51907142
The thing is, you can't JUST switch which is head and which is tail. You'd have to have an enum saying which pointer is next.

So, in your doubly linked list, you have two pointers,

node *pointers[2];

and an int, saying which pointer is next, the other being previous

int next_index = 1;

Then, you have your head and tail pointer

node *head, *tail;

To reverse the string, just do this:

temp = head
head = tail
tail = temp
next_index = (next_index + 1) % 2

And now your string is reversed
:^%)

I think I didn't smudge that up
Thread replies: 255
Thread images: 18

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

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