[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: 29
File: 1414529586851.jpg (42 KB, 479x513) Image search: [Google]
1414529586851.jpg
42 KB, 479x513
What are you working on, /g/?

previous thread: >>51298891
>>
First for COBOL
>>
>>51304231
Associate's is like 2 years of full-time schooling.
>>
Third for Haskell :3
>>
File: noice.png (649 KB, 1920x1080) Image search: [Google]
noice.png
649 KB, 1920x1080
Rate my creation, /g/
>>
File: black_shiba_inu.webm (717 KB, 640x640) Image search: [Google]
black_shiba_inu.webm
717 KB, 640x640
Ask your beloved programming literate anything.

>>51304261
>What are you working on, /g/?
The /dpt/ general utility, state of art, C library.
>>
>>51304341
it tries to find shapes that will fit the hole?
now this is pretty darn nice, anon
i rate 7/10, 8/10 with source
>>
>>51304341
What the hell, what algorithm is this? Link to the paper?
>>
File: 1431068804240.png (263 KB, 397x583) Image search: [Google]
1431068804240.png
263 KB, 397x583
I haven't programmed in half a week.
Help me dpt.
>>
File: 1445549787669.jpg (46 KB, 600x378) Image search: [Google]
1445549787669.jpg
46 KB, 600x378
any ideas for linux projects? i havent coded for myself in almost a year

>tfw
>>
>>51304394
I'm ashamed of how it's right now, It's disorganized as fuck. Maybe later when I adjust some things.

Also, it's detecting some false positives and I just don't know what the fuck do to.

>>51304394

Paper, lol. That would be too good.
Basically: Color separation + Contours. A lot came from my stupid mind.
>>
>>51304261
What does this C program print?

#include <stdio.h>

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}
>>
>>51304502
114, obviously
unless gcc, 115.
>>
Alright, time for a programming challenge.

Background: Integer multiplication, though not the slowest operation offered by CPUs, may often take multiple cycles to complete. Optimizing compilers may therefore elect to emit different instructions than a mul/imul where integer multiplication by a constant is concerned. The obvious use of this is when multiplying by powers of 2 (i.e. left shift by 2 to multiply by 4). If a multiplication instruction is particularly expensive for a target CPU, however, it may be wise to combine instructions for the same result. For example, multiplying some number x by 5 might be equivalent to ((x << 2) + x). Here, only 2 instructions are emitted (maybe 3 for copying over the original value to another register. Similarly, you can multiply by 6 by adding a number bitshifted by 2, and bitshifted by 1, or by 31 by bitshifting by 5 and subtracting the original number.

Challenge: Design a function such that, given an integer constant, can determine the minimum number of cycles that it would take to multiply by that constant without the use of a built-in multiplication instruction. You may assume the following:

1. Bitshifting, addition, and subtraction all have the exact same time cost (one cycle)
2. You will not have to worry about register shuffling. The architecture in question will be one in which integer register instructions take three arguments -- two sources and one destination (as in ARM, MIPS, and POWER)
3. All numbers are unsigned.
>>
>>51304524
no
>>
>>51304511
isn't it a summation starting at 6 going to 17 inclusive?
>>
>>51304536

Micro-optimization not your cup of tea?
>>
>>51304578
wasting time on things by tripfags is not my cup of tea
even more so when it's likely your homework
>>
>>51304131
talk to the owner of http://it-ebooks.info/
I bet he posts in /g/

>>51304502
man, you are obsessive. have you visited a psychiatrist lately?
are you Terry Davis, by chance? if so, how are those CIA niggers doing?
>>
File: 1445548124843.gif (1 MB, 600x338) Image search: [Google]
1445548124843.gif
1 MB, 600x338
>>51304578
not him, but go be autistic somewhere else
>>
File: me.jpg (22 KB, 368x353) Image search: [Google]
me.jpg
22 KB, 368x353
>>51304524
I'm a lazy code monkey who's too lazy to think, so no.
>>
So I don't know much about java but I'm trying to learn via codeacademy, lynda, and a private tutor. Right now I was given the exercise to create a gradebook that contains 10 students who all took the same 5 subjects, I then have to pull the top 3 performers for each subject, as well as the top 3 overall students.

I'm able to store and display the students/classes/grades in an arraylist but I'm not sure how to sort it to display both of the required things.


I really don't have a complete grasp on any java concept right now so forgive me for asking such a stupid question.
>>
>>51304593
>talk to the owner of http://it-ebooks.info/
id rather not talk to anyone
heh, I wonder if I could download all the books and put them on github, then you could just clone the entire repo to get the 34k books
of course, sjwhub would probably suspend the repo after a while, but git is distributed
>>
>>51304593
Who are you? I've never seen you here before. Are you new?
>>
>>51304524

Do your own homework
>>
>>51304607
Actually, Mr. Ruby is right. If you want to be skilled, you have to be able to program anything. So, you're actually the autistic one. Go write a Hello World in Visual Basic 5.0, moron.
>>
>>51304620

What exactly is your question?
>>
>>51304620
http://beginnersbook.com/2013/12/how-to-sort-arraylist-in-java/

google and look for stack exchange links when you have questions, not trying to brush you off, but give you a great resource for the future
>>
>>51304524
integer multiplication take one cycle on intel and amd since 7-8 years.
>>
>>51304650
omg you are totally right. i dont know how i didnt see this before, and your post showed me the way. i will now only code in assembly, because to use any other language or to program anything else than pointless exercises is a waste.

fuck off nigger.
>>
File: are-you-a-magnet.jpg (77 KB, 531x513) Image search: [Google]
are-you-a-magnet.jpg
77 KB, 531x513
>>51304341
>>
>>51304589

>likely your homework
I am not in a compilers class this quarter. My homework is:

1. Adding support for reading, writing, and creating files to my kernel.
2. Implementing a program to send a message between processes using AES encryption. The AES key has to be exchanged using El Gamal Public Key Encryption. I am allowed to use libraries to handle AES, but have to implement El Gamal myself

What I tossed up there is just an interesting thought challenge I came up with.
>>
>>51304620
must suck having to use java
C# masterrace
class Grade
{
public string Subject;
public string Student;
public float Grade;
}
static void Main(string[] args)
{
var grades = new List<Grade>(); //load the grades from somewhere

var topOverall = grades
.GroupBy(g => g.Student)
.Select(g => new { Student = g.Key, Grade = g.Average(g => g.Grade) })
.OrderByDescending(student => student.Grade)
.Take(3);

var topInSubject = grades
.GroupBy(g => g.Grade)
.Select(g => new
{
Subject = g.Key,
TopStudents = g.OrderByDescending(s => s.Grade).Take(5)
});
}
>>
>>51304685

Actually, it's been around 3 or so for a while. I think I saw in a document on instruction timings that it's 2 on Haswell, but that assumes that the target binary is going to be on a relatively new CPU in the first place.
>>
>>51304620
>codeacademy, lynda, and a private tutor
oh wow

just learn by yourself

https://docs.oracle.com/javase/tutorial/

and google, stackoverflow
>>
>>51304732
Woah man, you're an expert. I haven't got a clue on how to write a kernel.
>>
>>51304620
http://stackoverflow.com/questions/18895915/how-to-sort-an-array-of-objects-in-java
>>
>>51304673
>http://beginnersbook.com/2013/12/how-to-sort-arraylist-in-java/

Thanks for the link! How would I associate the sorted grades to the student who took them? I assume I use a parallel array, but in that case would sorting the grades work the same?
>>
>>51304924
class Student {
Subject[] subjects;
int[] grades;
}
>>
>>51304924
You could try using a hash table/map:

http://beginnersbook.com/2013/12/how-to-sort-hashmap-in-java-by-keys-and-values/

the grades could be the key with the student name as the value, so you would sort the grades and then see which students the top 3 grades correspond to
>>
>>51304870
>I haven't got a clue on how to write a kernel.

Have a look at osdev and turn into a neet. You'll get into the swing of it.
>>
>>51305005
simpler to sort an array of students according to their grades. see >>51304883
>>
File: Screenshot_2015-11-11_21-23-56.png (69 KB, 1599x879) Image search: [Google]
Screenshot_2015-11-11_21-23-56.png
69 KB, 1599x879
>>51304524
I done did it
>>
What's the best way to go about?
>>
>>51305131
yes
>>
/g/ I'm doing some work reviewing binary search trees and data structures for an interview.
I've got a book for possible outcomes and questions for what data structure to use in each possible situation, here's my thoughts
Between stacks, queues, binary search trees and arrays (heaps).

You have been contracted to write a reverse look-up phone book application. This is a program that accepts a phone number as input, and outputs the person associated with that number. Many phone number objects will need to be stored. The program need to be able to search for a particular object quickly to identify the owner. (I'd use stack)

An operating system sends documents to be printed to a printer one of three printers based on the number of pages to be printed (less than 10 pages, between 10 and 20 pages, more than 20 pages). Although documents are sent to different printers, they are printed in the order in which they are received. (I'd use a binary search tree)

In each plastic container of Pez candy, the colors are stored in random order. Your little brother Phil only likes the yellow ones, so he takes out all the candies, one by one, eats the yellow ones, and keeps the others in order, so that he can return them to the container in exactly the same order as before -- minus the yellow ones. (I'm not sure about this one, what would you use /g/?)

A’s CarParts must store information for each part that they regularly stock. For each part, a unique part number, price, and quantity on hand. The application must allow employee’s to enter information for a new part, search for a part by number, and print all part information. Parts are at the heart of this business; it is important that emplooyee’s must be able to search for a part very quickly. (I'd use a binary search tree for this one as well)

What do you think /g/?
>>
>>51305088
>http://stackoverflow.com/questions/18895915/how-to-sort-an-array-of-objects-in-java
legit
>>
>>51305143
thanks man
>>
>>51305183
this is bait
>>
>>51305005
That seems a little easier to grasp for me, so would I need 5 different classes for each subject, and one for overall grades and have each class use hashmaps? Or would that even work?

I didn't think this would be so hard for me to understand but it's kicking my ass
>>
>>51305183
Well, if it's to answer seriously

1 - Stacks
2 - BST
3 - Queues
4 - BST
>>
>>51305183

attach: fishing_pole.jpg
>>
>>51305183
The one you don't know is stacks.
>>
File: afsdfadf.png (432 KB, 495x636) Image search: [Google]
afsdfadf.png
432 KB, 495x636
how does one debug a C program in Visual Studio Code?

if it's not possible what's a good development IDE for Ubuntu that has a good easy to understand Debugger?

I have used visual studio's piss easy debugger for so long I don't know how to work shit like codeblocks debugger.
>>
>>51305302
>>51305275
I agree with stacks on 3.
>>
>>51305183
Hash, queue, queue, k-d tree.
>>
>>51305319

Use CLion
>>
>>51305235
>>51305282
is /g/ allergic to data structures in general?
>>
>>51305368

The answers are:
1. Vector
2. Vector
3. Vector
4. Vector
>>
>>51305183
For the printer one, within the options given, use a heap

The heap will order the pages and give priority based on the number of pages given while still doing a fcfs order
>>
>>51305381
1. Vectors
2. Vectors
3. Arrays
4. Vectors
5. Linked lists

of arrays
>>
>>51305270
if you have an array of objects (Students) like in
>http://stackoverflow.com/questions/18895915/how-to-sort-an-array-of-objects-in-java

you can sort them like

    Arrays.sort(students, new Comparator<Student>() {
@Override
public int compare(Student o1, Student o2) {
return o1.mathGrade > o2.mathGrade ? 1 : -1;
}
});
>>
>>51305183
TL;DR
>>
>>51305420
>5.

But.. there were only 4 instances.
>>
>>51305096
x*9 = shl 4, add x = 2 cycles.
>>
>>51305437
Oh, then I guess you don't need the linked lists
ever
>>
>>51305448
Shl 3
>>
>>51305449
>I guess you don't need the linked lists
>ever

That was already the case. LLs are garbage.
>>
>>51305448
Shit, I just assumed for whatever reason I could only shift one bit at a time. Should have read the instructions more carefully
>>
>>51305270
you could have a class file for "courses". the class file could have or read in two array lists from a file. one for each student name, and a parallel arraylist for each student's grade in that subject. the class file would also have a name property for the name of the subject (ie: english, math, etc)

you could then load both the grades and the students name into a hash map/table at the same time using a for loop since the parallel arrays will have the same indexing (grade[i] and student[i]).

now you can create a function to sort the hashmap..

from here you could have get/access functions that allow access to the hash and other properities of the subject.

ie:

// create new object of class
Subject english = new Subject();
// set subject name for object
english.setSubject("English");
// sort hash by grades
english.sortGrades();
// display top 3 grades for english class
english.printTopGrades();
>>
>>51305460
ah yeah, meant 3.
>>
>tfw no motivation to program

who feels this feel with me right now?
>>
>>51305510
>tfw no motivation to anything
>>
File: Screenshot_2015-11-11_21-56-42.png (61 KB, 1600x879) Image search: [Google]
Screenshot_2015-11-11_21-56-42.png
61 KB, 1600x879
>>51305471
Easy fix
>>
>>51305183
1. hash map
2. array
3. array
4.
>For each part, a unique part number, price, and quantity on hand
object/struct
>enter information for a new part
OOP
>search for a part by number
hash map
>print all part information
array
>search for a part very quickly
array
>>
>>51305462
this
>>
>>51305510
Me. I made a program for processing and converting bmp, jpeg, png and gif files and I feel accomplished. I have a feeling that I don't need to program anything ever again. I'm just here because I'm bored.
>>
>>51305528
subtraction dawg
x*7 = (x<<3) - x
>>
>>51305530
>OOP

This triggers Linus
>>
File: e.jpg (34 KB, 337x416) Image search: [Google]
e.jpg
34 KB, 337x416
how do i into data structures using python
i can use c but i really don't want to
>>
>>51305570
everything is a dict
>>
Trying to experimentally make a GCC front end. Anyone else who has done something similar got any advice?
>>
>>51305576
is that true or are you exaggerating
it wouldn't surprise me honestly
>>
>>51304261
int main() {
doric::column_vector<const char*,double,int> v(3, "hello", 1.0, 2);
auto r = v[2];
printf("%s,%f,%d\n", std::get<0>(r), std::get<1>(r), std::get<2>(r));
}

>hello,1.000000,2
I AM THE ACTUAL DEVIL
>>
should I learn R, /g/?
>>
>>51305628
for what
>>
File: shitout.png (1 MB, 1441x810) Image search: [Google]
shitout.png
1 MB, 1441x810
I should be working on my game engine, but for some reason, I can't stop playing this hot garbage.

What's wrong with me, guys?

Am I a [spoiler]normie?[/spoiler]
>>
>>51305628
Learn all single letter languages:
B, C, D, F#, R
>>
>>51305642
You're out of area, tripfag. We discuss programming in this thread. You're looking for >>>/v/.
>>
File: intellij.png (7 KB, 603x417) Image search: [Google]
intellij.png
7 KB, 603x417
hey guys i just started using intelliJ to do some java and i come across a small but annoying problem, when i used eclipse back in the day i remember the documentation tooltip would be FILLED with information, basically everything from the API site...

however on intelliJ the documentation shortcut is rather useless and does not provide jack shit.

do i have to change something in the setting to make this work right?

picture related... how is this documentation?
>>
What do you do to avoid include guards in C++?
Putting include guards every time you include a separate class sounds dumb as hell.
>>
>>51305653
>You're out of area, tripfag. We discuss programming in this thread.

Frankly, I'm going to have to disagree with your observation, there.

Off-topic bullshittery is fairly common.
>>
>>51305682
That doesn't make it acceptable. You don't understand that you're setting a poor example for the rest of us and you will only encourage more off-topic bullshittery.
You act like posting in this thread often gives you special status to do whatever you want.
Please discuss programming and programming only. That's your only domain of usefulness. Keep it that way.
>>
File: mongrels.jpg (21 KB, 272x382) Image search: [Google]
mongrels.jpg
21 KB, 272x382
>>51305682
off-topic bullshittery is encouraged to be disencouraged
>>
>>51305096
Wrong.

x * 7 = x * 8 - x = x << 3 - x is 2 cycles.

My solution:

def get_uops(m):
"""Return the number of uops that multiplication by m would take."""
# Trivial case -- ld0, or leave as is.
if (m < 0):
return -1

bitstr = "{:b}".format(m)
print("Bitstring: "+bitstr)

# Trivial case -- this is a single shift, no addition needed.
if (countones(bitstr) == 1):
return 1

# Decide whether to add the shifted values or subtract the shifted values.
num_add_shifts = countones(bitstr)

# Ex: 7 = 'b111 = 8 - 1 = 2^3 - 2^0
# 250 = 'b11111010 = 256 - 4 - 2 = 2^8 - 2^2 - 2^1
# 493 = 'b111101101 = 512 - 16 - 2 - 1 = 2^9 - 2^4 - 2^1 - 2^0
# Subtraction gets 1 extra operation (not reflected in the number of zeroes).
# for the 2^n+1 term.
num_sub_shifts = 1 + countzeroes(bitstr)

num_adds = num_add_shifts - 1
num_subs = num_sub_shifts - 1

# Multiply by 1 means no need to shift by 0.
num_add_uops = num_add_shifts + num_adds - (1 if bitstr[-1] == "1" else 0)
# Need an extra operation to subtract 1.
num_sub_uops = num_sub_shifts + num_subs + (1 if bitstr[-1] == "1" else 0)

return min((num_add_uops, num_sub_uops))

def countones(s):
return len(tuple(x for x in s if x == "1"))

def countzeroes(s):
return len(tuple(x for x in s if x == "0"))
>>
>>51305482
Thanks for the help! I don't know exactly how to code that but it's definitely made it easier for me to google it and find out.

Pretty awesome you guys are so helpful
>>
>>51305682
>stupid comment
>tripcode
>>
>>51305665
#pragma once
>>
>>51305183

1) BST by area code, subtrees for individual numbers
2) heap
3) stack
4) BST by part number
>>
>>51305732
I remember that being nonportable but whatever
>>
File: 1437165511980.jpg (179 KB, 1920x1080) Image search: [Google]
1437165511980.jpg
179 KB, 1920x1080
>>51305719
>>
>>51305747
>non portable
>COMPILER-WISE
>this is somehow important
>>
>>51305665
>>51305747
Truthfully, #include is dumb as hell.

I use "#pragma once" because I'm never going to be putting my source files in symlinks
>>
>>51304261
Who else here is working on their own programming language?

I'm building something heavily inspired by Smalltalk. With additional ideas from everything from Go to Rust to Objective-C to Haskell to D to C++ to Forth to Scala. But mainly smalltalk.

Still working on the syntax for this bad boy. I've already got a good idea of how I'm going to implement it. I'll be generating C code that corresponds, which will call into most likely an Objective-C runtime, or maybe something custom. But for now Yacc and Flex are my friends.

It's really worth doing if you have even a passing knowledge of programming. With Flex and Yacc you can describe the syntax in a pretty simple language and it will create a parser for you. E.g.:

add:
VariableOrConstant '+' VariableOrConstant
;

Really, it's hard to explain just how fun it is and how much you learn. I've gained a new respect for programming language designers already.
>>
>>51305801
Talk more about it.
>>
If I rewrote the Linux kernel in D would you guys use it?
>>
>>51305801
How do you program your own programming language? How do you program your own operating system? How do I draw pixels on the screen in C, without using OpenGL or any other library?
>>
>>51305839
>How do you program your own programming language
Get out.
>>
>>51304261
Making a befunge-98 (http://quadium.net/funge/spec98.html) interpreter in F#.

Currently deciding between using a 2d array or a list of lists to represent the torus - I used a 2d array for befunge-93, but it's feasible that I would need to expand the size of the torus and that's uglier with arrays.
>>
>>51305847
no u
>>
how do you program a program by using a program you programmed? can i program something like that or is there already a program?
>>
>>51305801
Just "finished" a pretty big programming language I've been working on for a while now. Making a programming language really helps you understand how the programming languages you use work and why they are designed in that way.
I've used parser/lexer generators but I prefer writing it by hand; you have more control over the syntax and the error reporting. Besides C++ parser generators never work how I'd like them to. I want to write my own one day.

https://github.com/iitalics/Opal
https://github.com/iitalics/Opal/tree/master/examples

>>51305839
>How do you program your own programming language?
You make a program that reads text and does shit based on the text that it read. That's all a programming language is.

>How do I draw pixels on the screen in C
Use SDL

>without using OpenGL or any other library?
You don't. Either you find some hacky completely non portable or cross platform way to do it (which is probably twice as miserable as using a library) or you suck it up and use a damn library.
>>
>>51305836
no please rewrite in javascript instead
>>
>>51305839
not that guy, but
>program your own programming language
write a compiler based on a specification that you made
>program your own operating system
write a bootloader that your BIOS recognizes, then make a set of core utilities to manage virtual memory and execute applications

>draw pixels without OpenGL or any other library
Impossible. vendor-supplied (AMD, Nvidia) libraries (OpenGL/DirectX, et al) are the only way to interface with a display.
>>
>>51305857
This isn't even stupid questions daily
>>
>>51305866
https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
>>
>>51305859
Common Lisp
>>
>>51305877
>only way to interface with a display
having said that, if you own a RasPi or whatever the fuck, you can use the GPIO to interface directly to a display, and then you can write your own drivers for it. Obviously this driver that you make would be a library that you would use in C.
>>
>>51305860
>You don't. Either you find some hacky completely non portable or cross platform way to do it (which is probably twice as miserable as using a library) or you suck it up and use a damn library.

How did programmers plot pixels back in the days where OpenGL, SDL and other stuff didn't exist?
>>
>>51305897
Wizardry.
>>
>>51305897
the vendor supplied them with a proprietary API to interface with the display.
>>
>>51305897
>people needed anything more than text input and output
>>
>>51305801
>everything from Go to Rust to Objective-C to Haskell to D to C++ to Forth to Scala. But mainly smalltalk.
Simplicity is the most important thing to consider when you design a language.
Trashing every band-wagon programming language into smalltalk sounds terrible, to be perfectly honest.

>>51305897
Computers were different back then.
>>
Any functional programmer / lover haters here?

>>> 51305523

Looking to get some feedback on https://storify.com/realtalktech
>>
>>51305916
>>>51305523
>>
>>51305642
>Am I a [spoiler]normie?[/spoiler]
yes
>>
>>51305897
pixel buffer.

https://en.wikipedia.org/wiki/Video_Graphics_Array
>>
>>51305642
>Am I a [spoiler]normie?[/spoiler]
Your taste in girls pretty much confirms it
>>
>>51305964

My taste in women is anything but normal, my man. In fact, it's highly unusual.
>>
>>51305943
holy kek
they're so anti-fp
I LOVE THEM
>>
>>51305654
nvm found out you have to link the API url in the project settings....
>>
>>51305977
Fuck me I forgot to close the code tags. Again:

This is my code for generating a random number between MIN and MAX:
int randomRange(int MIN, int MAX){
return MIN + (rand() % (int) MAX - MIN + 1);
}


I'm calling this function 100 times, in a for loop. Every time I run the program (C++ by the way), I get the same numbers: 9, 4, 5, 5...
Why is that happening? Why isn't it different every time I run the program?
In my main.cpp I wrote:
srand((int)time(NULL)
>>
>>51306004
post main
>>
>>51305970
You're into fat women.
>>
why are searches serial, senpai ;-;
>>
>>51305977
Why don't you just add to rand() and then modulus?
(MIN + rand()) % MAX
Anyways srand should do it.
If you're using threads then keep in mind that each thread has their own seed.
>>
>>51305977
You need to use srand inside the same function where you use rand
>>
>>51306045
>>51306038
I thought I only had to seed the random one time, and then it would work for the entire program?
I know if I seed it too often, it will pick the same number every single time I call rand().
>>
>>51306029

I'm mostly into black women, m8.
>>
>>51306076
Post some black women
>>
>>51306076
lel
normie as fuck
>>
>>51306099

No, I don't want to anger people too badly.

>>51306107

Not even remotely.
>>
>>51306076
fat black women
>>
>>51306139
POST

SOME

BLACK

WOMEN
>>
>>51306076
>3DPD

>>51306139
>I don't want to anger people too badly

NORMIE
>>
>>51306076
>>51306139

I bet a fiver you're never been into any woman
>>
File: dpt roll.png (127 KB, 546x486) Image search: [Google]
dpt roll.png
127 KB, 546x486
>>
File: ano.jpg (250 KB, 1200x1350) Image search: [Google]
ano.jpg
250 KB, 1200x1350
>>51306185
>Quads : Bitch about benchmark guy
>>
Is this the place for really stupid programming questions? What do all the different text colors in the code in Eclipse mean? I tried using search engines but all I can find is how to program different font colors and shit.
>>
>>51306185
rollin
>>
Haskell is so SHIT you guys
Type systems are fucking DOGSHIT
>>
>>51306214
>Is this the place for really stupid programming questions?
>What do all the different text colors in the code in Eclipse mean?
>I tried using search engines
>all I can find is how to program different font colors
Obvious troll
>>
>>51306185
>>
>>51306205
kek he would always post those ridiculous numbers out of context and refuse to disclose any details about the benchmark because muh schrödinger
>>
>>51306214
no, this is the place for shitposting and blogging
chances are, if you ask a question, it's going to go unanswered
>>
>>51306214
Do you mean syntax highlighting?

Just google it honestly
>>
>>51306185
>>51306217
>>51306230
Bitch first then see if it lines up
>>
>>51306185
swift sucks cock fuck iOS
>>
ruby is shit
>>
>>51306241
>syntax highlighting
Yes, thank you for telling me what it's called.
>>
>>51305943
>>51305916
https://www.reddit.com/r/haskell/comments/3shren/functional_programming_a_step_backward/cwxce5p

help me /g/. they persecute me
>>
>>51306264
Functional programmers are the worst group of people in history
>>
pythonfag here

[str(x) for x in [1, 2, 3] if is_even(x)]


someone explain what this does pls
>>
>>51305819
What I'm planning is a Smalltalk with some deviations. The most significant here, and the one I'll cover in this post, is the type system. Since I'm compiling to C I intend to ensure extensive cooperation with C. That means I will be exposing the C type system as well as the conventional Smalltalk object type system.

Now this is a little more difficult here as I want to keep Smalltalk's 'everything as an object' functionality. I'm still working out what syntax I will use to differentiate object types (including objects for integers, floats, strings) from basic C types.

If I *really* have to, I will go with an @ prefix for basic type literals (since I want them to play second fiddle to the object system). I'll mitigate the trouble of interoperation by automatically boxing C types into objects whenever they're used in a context that reveals an object (i.e. sending a message, using one as a parameter to a method, assigning one to an object variable). This isn't the 1970s after all, I can freely adjust the abstract syntax tree after it's created using semantic information as a guide.

>>51305839
You build a parser, which is just a tool that takes in text and finds patterns in it somehow. There are loads of ways to do this, and there are a lot of parser generators - Yacc for C, ANTLR for Java and C#, etc.

See osdev.org for operating systems, and for drawing pixels on the screen, well, you really need a library there in any practical system.

>>51305860
Thanks for sharing this. I'm really impressed by it.

I think there could actually be quite a bit of demand for a language like this. I know a lot of people are put off functional programming because Haskell, Clojure, etc have unfamiliar syntax, whereas yours would be much more familiar to curly-braces users.

The system of operators as actually message sends is pretty cool and Smalltalky. And your interfaces system seems to be a good solution to the problem of generics in a staticly-typed language.
>>
>>51306275
Never done python here
For every value in [1, 2, 3] (i.e. 1, 2 and 3)
If it's even
str(x) (stringify it)
>>
>>51306275
https://stackoverflow.com/questions/20639180/python-list-comprehension-explained
>>
>>51306185
Roll
>>
>>51306275
>>51306290
>>51306297
desu this is massively readable and convenient, I'm impressed

python, you can stay
>>
>>51306298
10 PRINT "FUCK UNSTRUCTURED PROGRAMMING"
20 GOTO 10
>>
I don't know how, but I seem to have forgotten how threads work.

In C++11, can I assign a class to a thread, and then occasionally run various functions on it from main?

I only remember using them to run specific functions
>>
>>51306290
LINQ does it better
>>
>>51306341
>assign a class to a thread
What does this mean?

Running a thread is exactly the same as running int main() (it's the main thread, ofc). You execute one function that executes others.
>>
File: 19TFxbB.png (643 KB, 1920x1080) Image search: [Google]
19TFxbB.png
643 KB, 1920x1080
>>51306232
>refuse to disclose any details
i did share the source code but then you guys bullied me hard.
>>
>>51306362
basically have multiple threads with this class in it, and then from main you can decide which functions to run, because you're doing multiple possibly unrelated ones per thread.

This assignment is a pain in the ass because I have to force a race condition to occur. Gotta test lock validity.
>>
I'm improving but still have a ways to go.


#include<stdio.h>
#include<math.h>
#include<time.h>

int main(void) {

srand(time(NULL));

int c, total, counter = 1;
char d;
printf("Game of Dice\n===========\n");
printf("Enter interval sought: ");
while (scanf("%d%c", &c, &d) == 0 || d != '\n' || c < 0 || c > 12) {
printf("Invalid input, try again!");
}

do {
int a = 7, b = 7;
while (a > 6 || b > 6) {
a = rand() % 10;
b = rand() % 10;
}
counter++;
total = a+b;
printf("Result of throw %d : %d + %d\n", counter, a, b);
} while (c != total);
printf ("You got your total in %d throws!\n", counter);
return 0;
}

>>
>>51306384
The idea I'm having is that I'd have some number of threads lock, then run a lock tester function, and then have them all unlock.
If I rely on the threads to lock and unlock all on there own. there's no guarantee of the race condition occurring.
>>
>>51306384
You mean an object, right (one shared across the threads)?
Just pass a pointer or reference?

std::thread(function, parameters...)
>>
>>51306356
it certainly fucking does
>>51306304
>massively readable
it's backwards, though.
C# w/ LINQ has it right.
from x in new[] { 1, 2, 3 }
where x % 2 == 0
select x.ToString()


>python
>map, then array, then filter
>c#
>start with array, then filter, then map
one is in the logical order, one is dumb.
>>
File: 454.jpg (265 KB, 1920x1080) Image search: [Google]
454.jpg
265 KB, 1920x1080
>>51306388
>printf("Game of Dice\n===========\n");
> printf("Enter interval sought: ");
printf("Game of Dice\n""
"===========\n"
"Enter interval sought:");

better, no ?
>>
>>51306417

True, I think I might do that from now on, thanks anon
>>
>>51306415
that's pretty good too, but the other one is fine, I immediately understood it
it looks neater too desu

it's not really 'backwards' in terms of anything but imperative programming
f(x) = √x ∀x ∈ R
>>
How would you rate different methods of digesting(splitting, modifying, etc.) strings in C++?

I've been looking into it lately but it doesn't seem cut and dry. For example, there are multiple different regex options, the String class functions in System for Windows(I assume provided by MS), and of course crafting your own stuff or using other existing libraries. From what I've read so far the boost regex libraries seem like the fastest pre-built option.

Or, what's your preferred method when not prioritizing speed?
>>
>>51306464
>it looks neater too desu
that's because you sacrifice the power oif static typing to use a toy language, which allows for terser syntax
>>
>>51306413
Modified what I think I I'm going to do.
One (of the same type of) object per thread
Locks are static members
Run one thread for locking
Use a separate object and thread to test the lock
Run another thread for unlocking

Problem with this is that I have no idea where to put the join()s because fucking locks
>>
>>51306491
Fuck, I keep forgetting about thread_local variables. There's only one object and multiple threads.
>>
>>51306479
>toy language
>>51306185
>>
How required is java for employers these days?

I hate it so fucking much
>>
>>51306479
This could easily be static.
>>
>>51306524
feel free to fork python and make it static anon
>>
>>51306478
If anything I would have expected you to complain about the various methods of I/O.
Now that's a clusterfuck.

C++11 has regex built in. stringstreams are also breddy gud.
All in all, remembering escape codes for "whitespace" and shit like that is a pain in the ass though.
>>
>>51306544
Why do you hate me so much for saying a single part of python looks neat?

Oh right, DPT...
>>
>>51306508
There is literally nothing wrong with java.
Except swing.
And no unsigned.
And the slow/shit garbage disposal.

In all seriousness though, it depends on the job. It's one of the more used languages though.
>>
>>51306545
>C++11 has regex built in
I did not know this
I assume it's easy as fuck to write parsers, interpreters and shit now?
>>
>>51306559
>the slow/shit garbage disposal.

Java is bad at a lot of things, but garbage collection is not one of them.
>>
File: ruler.png (544 KB, 657x520) Image search: [Google]
ruler.png
544 KB, 657x520
>>51304341
It's me again, with 10% of error.
>>
>>51306580
It's not that they're bad at garbage collection
Garbage collection doesn't need help being bad
>>
>>51306585
So you wrote a computer vision algorithm to detect shapes and their dimensions?
Why is it off?

Try using three-point circles. Three points is the minimum required to derive the center and radius of a circle.
If you can detect that a circle exists in a spot, it should be piss easy to find three points of that circle.
>>
>>51306592

Hot opinions, friendo.
>>
>>51306545
I imagine I will at some point, but I wasn't complaining, I'm just researching; I'm a programming newbie to be honest and I'm just trying to expand my barely-functional C++ knowledge. Not sure how SO is looked at around here, but for example I came across this:
http://stackoverflow.com/questions/14205096/c11-regex-slower-than-python

And it seems like the results the top answer got with the boost libraries were significantly better than the others. Not that it's any bearing but I don't have that much to go on right now.

I've also heard C++11's regex is slow somehow, so I'm not sure I want to try that or not.

The System libraries seem like the most intuitive but I don't like the idea of having to deal with Strings much since apparently it can't process std strings.

Haven't looked into stringstreams much yet, thanks for the suggestion.
>>
>>51306618
>three points is the minimum required to derive the centre and radius of a circle

Two points. Centre is obviously the mean, radius is just the distance between the mean and a point. (Kinda like the variance?)
>>
>>51304524
This is actually a moderately hard problem.

The naive approach is to just perform a shift and add for each bit that's set. E.g. 10*x = (8+2)*x = 8*x+2*x = (x<<3)+(x<<1).

The simplest optimisation is Booth's algorithm, which looks for runs of consecutive ones and performs a shift+add and shift+subtract for each run. E.g. 14*x = (16-2)*x = 16*x-2*x = (x<<4)-(x<<1).

Where it starts getting complicated is when you consider using intermediate results. E.g. if the constant contains a repeated pattern of bits, you can multiply by one occurrence then re-use the result.

E.g.:165 = 33*5=(32+1)*(4+1).

Put y = 5*x = (4+1)*x = 4*x+x = (x<<2)+x. Then 165*x = 33*y = (32+1)*y = 32*y+y = (y<<5)+y.
>>
>>51306580
It's more that it's a suggestion to dispose of shit rather than an order.
>>
>>51306652
>>51306618
even an ellipse is only defined with two points
>>
>>51306618
I'm using Hough Transform with the image reduce by half to get 30+fps, it is bound to be a little off.
>>
>>51306652
right, but if you're tracing an existing circle then you need three points. It's basically the same idea as creating a curve from a spline, except that you know that the curve always closes on itself, and that the angle is always the same.
>>
>>51306628
If it's the solution to the problem then it's fine. I doubt many people here would get at you for using reddit as a source if it was the only option.
>>
more programmin in rust
>>
>>51306652
> Centre is obviously the mean
It isn't.

To find the centre of a circle given 3 points A,B,C, find the line half-way between A and B, and the line half-way between B and C. Those two lines intersect at the centre.
>>
>>51306695
Two points, opposite, on the circumference
>>
>>51306672
An ellipse can be defined by two points (the foci) and a length. Different values for the length give you different ellipses with the same foci.
>>
>>51304261
A cross platform framework for SceneKit so I don't have to wait for Epic or Unity to get off their asses and update their engines for the new cash cows Apple released.
Holy hell is SceneKit incomplete as fuck. It doesn't even have its own standard for render loops or proper collision checks (such as to tell you if you're on the ground or not). Even if you do it with a raycast, you gotta do it at the world level.
>>
>>51306714
Right, but you don't know where that circumference is until you hit it. This is a circle that already exists.
>>
>Mention an accomplished female programmer
>People in here are always quick to try and say they were a fraud

Why?
>>
>>51306714
Yeah, but that's not the problem he's trying to solve. If you only know that the points are on the circle, you need 3 points. Choosing two points which are diametrically opposed would require knowing where the centre is.

>>51306716
Same issue really. It's not about having points which have particular significance, it's about having a set of points which lie on the curve.
>>
>>51306745
Fuck off ada
>>
>>51306745
Have you considered the possibility that they could be a fraud?
>>
>>51306767
If it was a male who was mentioned no one would doubt the claim.
>>
>>51306770
>calculus, the most important invention
>>
>>51306770
Have you considered the possibility that there isn''t a rumour that the male's a fraud?
>>
Did you ever notice that haskell is really shit? I mean, it seems not shitty at first, but the more you use it, the more shit it becomes.
>>
>>51306770
If it was an actually accomplished person (meaning everyone knows who they are and what they accomplished), no one would refute the claim.
>>
>>51306787
I've never programmed in haskell, and the more I continue to not program in haskell, the shitter haskell seems
>>
how does this only have 3908 views

https://www.youtube.com/watch?v=sLmiAV-cu9c

dank as hell
>>
So I have the list
((1 2 3) (4 5 6) (7 8 9))

When I call
(setf (nth 0 (nth 0 list-above)) 10)
I get the list

((10 2 3) (10 5 6) (10 8 9))

What the hell is up? Running on clisp.
>>
>>51306807

> tfw you realize that C is the only decent language
>>
>>51304261

I'm... trying to build a website to host my data analysis.

But I don't know shit about fuck, so I'm just dicking around in visual studio and with some parsing program I got.

College literally taught me nothing.
>>
>>51306628
"C++11 regex" is whatever the compiler chooses to provide. It might be the system library, it might be Boost's, it might be one the compiler's authors wrote.

Different libraries may have different trade-offs. Fully compiling the regexp to a DFA will take longer but searches will be faster. Compiling to an NFA and converting individual states to DFA on demand (with caching) reduces the up-front cost; search speed varies, but will plummet if you start thrashing the state cache.

All of the regexp variants in the standard allow non-regular expression, which means that the implementation has to support backtracking at some level. Some implementations may detect whether backtracking is possible for a given regexp and use a faster implementation if it isn't; others will just use a backtracking-capable algorithm for everything.
>>
>>51306728
>>51306758
>>51306716
You can get two points that are diametrically opposed:
1. pick an arbituary point on the circle
2. pick another arbituary point on the circle
3. make chord point 1 to point 2
4. draw perpendicular line of chord P1P2
5. point 2 and intersection of line and circle is diametrically opposed
>>
>>51306822
it's shit
>>
>>51306838
You're using four points.
>>
>>51306787
Daily reminder: a person's opinion of a language tells you a lot about the person, but very little about the language.
>>
>>51306770
Have you considered that that's bullshit?
You're asserting something that honestly you don't have any proof of. Now more than ever, men are being discredited for the simple fact that they have a penis, and usually the argument is completely fallacious, such as what shirt they're wearing.
>>
>>51306848
no, i'm using three points
two of which are any point on the circle
>>
>>51306840
your audio gear is shit
>>
>>51306779
>>51306782
>>51306791
>>51306859
>>>/r/redpill
>>
>>51306852
this
If they don't think most other languages are shit, that means they're shit
>>
>>51306838
> 5. point 2 and intersection of line and circle is diametrically opposed
> intersection of line and circle
You don't know where the circle is yet. That's what you're trying to find.

Given two points, there are infinitely many circles passing through both points (any circle whose centre lies on the line equidistant between the two points will pass through both points).
>>
>>51306878
(it doesn't even matter which language they use and which languages they think are shit)
>>
>>51305801
Yeah I'm working on a language but every time I get something done I end up going back and redesigning something so I have to restart. It's kinda shitty but I really want to make this a language that I can enjoy using.
>>
>>51306824
Nevermind, I got it. Never initialize lists with the initial element as another list, there's no copying.
>>
>>51304261
here is your solution, friendo >>39894014
>>
>>51306884
a o b
nope
>>
>>51306076
>not Asian women
fucking disgusting
kill yourself
>>
>>51306770
plenty of males are rightfully accused of being shit/overrated
>zed shaw
>>
>>51306921
Linus Torvalds
>>
just finished pathfinding, next is using the nodes returned by the pathfinding algorithm as control points for a bezier path
>>
>>51306876
The red pill doesn't free you from the matrix, it only initiates you into a party that opposes the 1999 simulation but willfully accepts the 2199 simulation. This was explained by the architect but never fully understood by Neo and the citizens of Zion.

Neo also wasn't the One, nor was Smith, but it was the collective of the two that made the One.

Their fight only accomplished the bidding of a greater, distributed virtual entity powered by those two nodes.

The Matrix as a whole is a two party system, consisting of the blue pill Matrix, and Zion, the red pill Matrix.

To gain total freedom, you should seek a solution that both parties are opposed to. Neo sought this solution in his proposal to the master of the Sentinels. He fights the Smith virus and completes the one, in exchange for peace. Of course this has happened time and time again and the Matrix just keeps coming back because it was never destroyed, only dismantled for renovations.
>>
>>51306941

What algorithm did you use?
>>
I have photoshop/illustrator experience, can make my own music and have the general idea for a game.

what do you recommend I start with? I'm not opposed to learning a language but there's so many options and people all suggest different things so it's hard to just pick one.
>>
>>51307075
C++
>>
File: pixie is my favorite demon.gif (575 KB, 512x384) Image search: [Google]
pixie is my favorite demon.gif
575 KB, 512x384
>>51307075
butterscotch! forgot my image.
Pixie is my favorite demon.
>>
>>51307075
JavaScript (Phaser) or Python (PyGame).
>>
>>51307075
>>51307081
http://www.cplusplus.com/doc/tutorial/
>>
>>51306997
A new milestone for the official /dpt/ C toolkit library has been reached: Arraylist tests are done (I am a TDD evangelist).
>>
>>51307075
Unity is the game engine for non-programmers.
But since you said photoshop instead of 3dsMax, you'd probably be after a 2d engine (unity does 2d too, just not as well from what I've heard).
Either way, >>>/vg/agdg is probably more suited to answer the question.
>>
>>51306978
I forgot to mention, the subway is the big hint. The subway links the two simulations. You enter the subway without plugging in, and you can get to Matrix or Zion from the Subway.
The second in order from biggest hint descending, is Neo being able to see the world in code even in the outskirts of Zion city.
Finally, what really introduces you to the need to suspend your disbelief, is when you get hurt in Matrix, you get hurt in Zion. Same with the Subway. Bullet holes, cuts, bruises. All of the things that hurt you elsewhere, will hurt you where you lie, mostly causing internal bleeding, as you have a different set of skin in each world. They gradually get you used to believing that the Zionites are free.
Thread replies: 255
Thread images: 29

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.