[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: 23
File: 1456037941464.png (227 KB, 443x443) Image search: [Google]
1456037941464.png
227 KB, 443x443
Previous thread: >>54761124

What are you working on, /g/?
>>
if i declare uint16_t *__restrict__ foo, why can't i pass it to a function as uint16_t *&f
>>
>>54771122
so thats it, C18 will have hyphens in variable names. whoa.
>>
>>54771146
ok kid
>>
First for assembly.
>>
File: gles.webm (2 MB, 1280x720) Image search: [Google]
gles.webm
2 MB, 1280x720
/dpt/-chan, dai suki~

Ask your much beloved programming literate anything (IAMA).
>>
>>54771146
really? Finally catching up to lisp.
>>
>>54771196
kys
>>
>>54771190
How many test cases should I write for trivial methods like joining file paths or returning the absolute path of a file?
>>
>>54771209
none
>>
>>54771202
Now they just need to allow other characters in identifiers like ? and !.
>>
>>54771190
>>54771142
>>
>>54771209
One for any issue you have encountered, plus test cases for any potential issues.
>>
>arguing with statist
>"muh roads"
>literally all he's got
>BTFO him with logic and science
>leaves the debate thinking he won because he called me racist for saying niggers should go back to africa
Get praxed negro lover
>>
Ok gents I was in an interview yesterday and couldn't finish the last question I was working on because I ran out of time.
My answer was incorrect because it didn't return the proper number.
I felt pretty bad about it so I just coded it at home, and now I'll post the problem 1st in case any of you guys want to solve it.
The interview was 30 mins, 3 questions, and this was one of them.
I'll post my answer in 10 minutes.

Here's your prompt:

/*
Given a string of uppercase characters, and an array of target characters,
find the length of the longest consecutively repeating substring of target characters.

For example:
longestStreak("AABGZZZARRRRRR", ['A', 'G']); // returns 2
longestStreak("AABGZZZARRRRRR", ['A', 'G', 'R']); // returns 6
*/
>>
>>54771499
Please don't bully OSGTP.
>>
>>54771500
Ah, I forgot to mention, you must use the array function '.forEach'
In case u guys don't remember foreach is
[].forEach(function(element, index, array){});
// they didn't give this tidbit btw, gotta have memory!
[/spoiler]
>>
File: 1463058542240.jpg (81 KB, 467x700) Image search: [Google]
1463058542240.jpg
81 KB, 467x700
is it convenient to develop a offline application with node.js?
I know Ruby and Python but most GUI libraries piss me off and i don't like how they look, I'm tempted to to do the job with HTML5.
>>
>>54771500
package main

import (
"log"
)

const (
stack = "AABGZZZARRRRRR"
)

var (
needles = []rune{
'A',
'G',
'R',
}
)

func main() {
max := 0

for _, needle := range needles {
hits := 0
for _, item := range stack {
if item != needle {
if hits > max {
max = hits
}
hits = 0

continue
}
hits = hits + 1
}
if hits > max {
max = hits
}
}

log.Print(max)
}

2 minutes maybe?
>>
>>54771500
k it's been 10 mins, here was the answer i came up with
function longestStreak(s, tar) {
var ar = s.split(''),
curs = 0,
lons = 0,
last;
ar.forEach(function(e, i, a){
if (tar.indexOf(e) == -1)
curs = 0;
else
curs = e == last ? curs + 1 : 1;

if (curs > lons)
lons = curs;
last = e;
});

return lons;
}
>>
>>54771624
cool what language?
>>
>>54771687
Looks like Go senpai
>>
>>54771687
Go famalam.
>>
>>54771500
did you get the job?
>>
>>54771734
I've never used or seen Go, and it looks weird.
what's []rune and 'for _,' ?
and is := "assign if null" ?

>>54771746
well interview was yesterday evening, but no i don't think ill be getting a call back.
it was a 2 hour interview and i gave 2 lectures, i prepared for two, more like 2.5 days, and i was working my parttime job too so i didn't even have a full day to make the lectures...
i'm pretty salty about sinking that much time and effort into an interview. not to mention i had to drive an hour to get there, and got stuck in traffic so bad i had to turn my engine off multiple times just to sit in the road
>>
File: 1456727681521.jpg (186 KB, 690x460) Image search: [Google]
1456727681521.jpg
186 KB, 690x460
>>54771209
>not formally proving your code correct with regard to the underlying architecture in a higher-order intuitionistic logic
>>
>>54771778
>job interviews
>gave 2 lectures

what, where the fuck did you apply to
>>
File: convex_or_concave.webm (1 MB, 720x720) Image search: [Google]
convex_or_concave.webm
1 MB, 720x720
>>54771778
>:=
It's for type inference.

>>54771578
https://facebook.github.io/react-native/

>>54771254
Restrict is non standard C++. You are not allowed to discard it probably due to methods and class fields.

>>54771263
>One for any issue you have encountered
TDD is about writing tests first.

>>54771209
Write the specification of your procedure then the tests based on that specification.
>>
>>54771800
a teaching gig. i have a few years of ta experience and have lectured about half a dozen times. still work at a job equivalent to flipping burgers though
>>
>>54771778
>what's []rune
Array of UTF-8 characters
>and 'for _,' ?
_ is a placeholder variable because of muh multiple rvals.
>and is := "assign if null" ?
It's a short hand notation for a variable declaration.
>>
>>54771834
nigga why not go into the industry?
>>
Anyone here applying for the Karelia AMK Tiko exam? Any code ready?
>>
File: 1448730710021.jpg (28 KB, 277x277) Image search: [Google]
1448730710021.jpg
28 KB, 277x277
>>54771578
Do you want cancer? This is how you get cancer.
>>
>>54771852
ive interviewed so many times, every time it's always the same
>oh anon you're so smart
>we like you, what you talked about, your personality, etc
>never get a call back
EVERY fucking time

probably has something to do with my liberal arts degree and nearing 30's age
>>
>>54771578
is that a man?
>>
>>54771875
i know this feel, i think the worse was when i was a jurior looking for an internship and the guy straight out told me "Anon I think you can do better than this, im not sure if youd like it here. are you sure you want this internship?"

neddless to say he never called back after that.
>>
>>54771819
>https://facebook.github.io/react-native/
thank you
>>54771860
i just want something that is relatively easy and provides good looking results
most "classical" GUIs are difficult to make and feel simply outdated
>>
>>54771875
Seriously, I've seen the absolute worst getting hired. The only thing you have to be is a smooth talker.
>>
>>54772021
life is hard when youre anti social
>>
>>54771500
maximum $ map length $ group $ intersect "AABGZZZARRRRRR" "AGR"
>>
Dubs chooses what I program
>>
>>54772079
a program that programs
>>
>>54772079
A Calculus of Construction interpreter
>>
>>54772079
Automatic music generator based on machine learning.
>>
>>54772091
reroll
>>
>>54772079
Le fizzbuzz meme :^)
>>
>>54772102
rereroll
>>
>>54772090
this
>>
>>54772133
Dubs decides what it programs
>>
>>54772059
Not sure if you're him. Work on that shit nigga. Travel to some far away place on your own where they don't speak your language. China for instance. Reflect on your life.
You either become more social or end up killing yourself.
>>
>>54772137
it should program bots that learn from 4chan posts and posts back
>>
>>54772143
id end up becoming a hermit
>>
>>54772151
Pro tip: feed it /pol/
>>
>>54772171
>>54772151
this, tay tay 4chan edition
>>
>>54771534
Was this a language specific question?
What language is [].forEach?
>>
>>54772137
It should compute safe passwords that are unable to be found, and store them in an encrypted file.
>>
>>54772163
That's why you have to force yourself. Travel by bus so you have to ask for directions. Take creepshots.
Or get breast implants, problem glasses and start forking irrelevant Github repos.
>>
>>54772228
It's js, never mind. Read over it.
>>
>>54772228
JS
>>
>>54772078
holy what
>>
>>54772236
i do take a bus everywhere already, no one talks on them.
>>
>>54772302
Haskell, mate. Shit's cash.
>>
>>54772309
I mean asking which bus you have to take to reach your destination.
>>
>new thread
>old thread still has 308 posts
what the fuck have you done you piece of shit
>>
>>54772387
Welcome to the concept of ego, and how it affects humans. Enjoy your stay.
>>
>>54772412
fuck off i'm not replying to you
>>
>>54772420
you just did
>>
>>54772302
>>54772311
Perhaps I should give you an explanation:

An array of character is just a string in Haskell, so
['A', 'G'] is the same as "AG".

'intersect "AABGZZZARRRRRR" "AGR"' returns the list in which the character of the second occur in the first, giving "AAGARRRRRR"

'group' returns that result grouped by characters: ["AA","G","A","RRRRRR"]

'map length' returns the length of each string in the that list, giving [2,1,1,6]

'maximum' find the largest number in that list, giving 6.
>>
File: 1447124961854.jpg (58 KB, 500x581) Image search: [Google]
1447124961854.jpg
58 KB, 500x581
i = 1;
i = ++i++;
printf("%d\n",i);

You should be able to solve this.
>>
TEACH ME
>>
>>54772438
undefined
kill yourself weebposter
>>
>>54772420
What the fuck? You're not me >>54772387
>>
>>54772188
osht nigga
>>
>>54772447
I want to learn programming
>>
>>54772438
3. The second statement ends after the postscript increment, making it effective
>>
well /dpt/
I'm going over on a vacation that i don't want to, and i'm going to use that time to learn how to program on android.
I'm downloading android studio and setting up my phone so that it'd work.
But i won't be able to access the internet while i'm gone, so i'd appreciate if there are any android programming books out there that cover a great deal of it, and anything that revolves around handling Database related Data, stuff like JSon or whatever.
>>
>>54772438
Error.

i = ++i++;

i = ++1;


1 isn't a variable you can increment.
>>
>>54772508
Fuck computers, just enjoy yourself.
You're probably never going to have it this good ever again, neetboy.
>>
>>54772449
>undefined
nope, char* can alias anything
>>
>>54772438
fuck off with this ridiculous blushing, fucking autist
>>
>>54772524
I'd love to, the reason i'm being deported like this is because i'm wasting too much time with people.
>>
>>54772508
Don't forget to download the SDK documentation, libraries and an emulator.
>>
>>54772558
It sounds like you're not painting the whole picture.
>>
>>54772554
>beyond my abilities
anon...
>>
>>54772512
B for trying, but read some more C m8, the result of expressions such as i=5 can be more than a numerical value, think a = b = c (no it's not a special case) or *it++
>>
File: scheme master race.png (14 KB, 812x555) Image search: [Google]
scheme master race.png
14 KB, 812x555
this is so retarded
>>
>>54772577
>a = b = c
>*it++
Just realised both my examples are out of topic
>>
>>54772572
kill yourself smug fag, you got absolutely rekt on the aliasing issue
>>
>>54772596
>hundred spaced indentation

No anon, you are the downs.
>>
What does DPT hate in code?

>100+ line functions
>global variables disguised as singletons and command line flags
>returning null instead of empty results
>>
>>54772577
Whatever.

$ cat g.c 
#include <stdio.h>

int main(void){
int i;

i = 1;
i = ++i++;
printf("%d\n",i);

return 0;
}
$ gcc g.c
g.c: In function 'main':
g.c:7:6: error: lvalue required as increment operand
i = ++i++;
^
>>
>>54772631
your mom
>>
import task
task1 = task.Task()



What should i name my variable task1? I want to name it task, but that creates conflicts with the module name.
>>
>>54772570
I know.
But i'd hate to waste my time, the vacation is going to be atleast a month or two long. so i'd hate to not have atleast got something out of it.
>>
>>54772596
Lacks more brackets this m8
(cond [(test args) (body)*]*)
did you come from Clojure or wh@?
>>
>>54772650
How old are you?
If you really don't want to go, they can't force you to.
>>
>>54772649
fuck off

obviously something that describes it like niggerTask or fagTask
>>
>>54772649
task_to_do_a_thing
>>
>>54772631
>other people's code
>my own code older than [CURRENT YEAR] - 2
>>
File: scheme fizzbuzz.png (31 KB, 1912x577) Image search: [Google]
scheme fizzbuzz.png
31 KB, 1912x577
i'm talking about the lack of error reporting. it's not like cond has a million different forms it can come in, yet it says nothing
>>
>>54772649
name it what it does.
transportKikesTask.
>>
>>54772630
that would imply i did that and it didn't just fuck up the formatting i made in notepad++ and not let me change it back when i entered a trace after i copied and pasted it
>>
>>54771122
not programming but op posted his image so fuck it. Does anyone follow Bill Hitchert on Normiebook. I used to be on his page all the time but deleted my facebook a long time ago, and his page is literally the only thing I miss about that website.
>>
>>54772728
No amount of laziness can justify why you have those indentations, m8
>>
File: sol.png (42 KB, 812x612) Image search: [Google]
sol.png
42 KB, 812x612
I know the total area of this polygon.

i know the area of the light blue polygon.

i also have information (the coordinates) of all vertexes in this polygon.

how can i determine the areas of A, B and C?

pic related
>>
>>54772751
are you autistic? why don't you open up dr racket, copy and paste a program with proper indentation into it, and then press enter before the (cond line and see what happens. fucking faggot i bet you don't even program
>>
File: 1463101511072.jpg (69 KB, 600x788) Image search: [Google]
1463101511072.jpg
69 KB, 600x788
>>54771500
def streak(haystack, needle):
n = 0
for h in haystack:
if h == needle:
n += 1
else:
break
return n

def longestStreak(haystack, needle):
longest = 0
for n,c in enumerate(haystack):
if c in needle:
longest = max(longest, streak(haystack[n:], c))
return longest

print(longestStreak("AABGZZZARRRRRR", ['A', 'G'])) # returns 2
print(longestStreak("AABGZZZARRRRRR", ['A', 'G', 'R'])) # returns 6


TL Note: Python's enumerate somewhat equals Javascript's foreach.
>>
>>54772783
>autistic
It's always autism. Always
>>
>>54772767
B and C are both triangles and A is just 2 triangles. you know the coordinates of all the points so just do the math
>>
https://archive.rebeccablacktech.com/g/thread/S54656366#p54658754

see, mark cuban agrees, fucking agdg kids don't know effort

https://www.youtube.com/watch?v=KYneLGRTgy8
>>
>>54772790
I copy paste a lot from stack overflow.
>>
>>54772804
didn't mark cuban make a shitty startup that was overpriced because of the tech bubble and sell it right before it went belly up?
>>
>>54772420
literally retarded
>>
>>54772050

bahahahahaha
>>
>>54772817
still took effort
>>
>>54772802
i'm suppose to write a program to solve this problem.
if it was pen and paper it would be done already.

i'm asking with the information given below how can i calculate those areas.
>>
>>54772687
26
The story involves ISIS whether you believe it or not. The reason we have to leave is based on probability which isn't even that high. But having so many of my own leave, leaves me between people who i don't trust. So i'd rather take a leave than to stay with people that are probably going to betray me and shove me into ovens for mermaids in heaven.

Now that that is out of the way, whether you believe it or not is up to you, but i'd hate to derail the thread, and i'd really like to know about some good valuable resources to study for android.
The wiki seems lacking on that front, unless i've missed it.
>>
>>54772841
yeah but why would i take his financial advice when he got filthy rich off a fluke? should i ask lotto winners for financial advice too?
>>
>>54772847
google search how to find the area of a triangle, and google search how to find the distance between two points. i'm more concerned that you don't even know what to google than you not knowing an equation
>>
>>54772850
well go ahead and take agdg's advice about making half-assed unity games that they shit out in a couple of weeks
>>
>>54772863
the only person who's financial advice i take is donald trump. he's a multibillionaire now from a million dollar loan, as a result of years of work and not making some shitty trendy tech company that he sold instantly
>>
What does it mean if I get 4 fast beeps on windows and it burps out hexadecimal stuff along with the name of my program and some other random shit from my program into the console? I know which function is causing it, but I don't understand why. What do the 4 beeps and that random shit in the console mean on windows 7? Is it a segmentation fault or something? I'm using c++ and sfml if that matters.
>>
>>54772878
you don't need a million dollar loan to dick around with the unity engine
>>
>>54772883
You're computer is being hacked.
>>
>>54772895
why do you think just because i'm shitting on mark cuban i'm from your shitty /vg/ general?
>>
>>54772907
Shit I forgot to install norton, brb. I hope he didn't backtrace my IP yet.
>>
File: help.jpg (126 KB, 795x450) Image search: [Google]
help.jpg
126 KB, 795x450
If you insert one element into a deque, shouldn't the total number of nodes in the deque be 2?

Pic related is how I think deque should work, if I were to insert an item to the FRONT on an empty deque. This way when it retrieves either the front or back, it returns the same item. Because that item is both first and last in the deque.

Or should it be, if I add an item to the front on an empty deque, back will point to nothing? So retrieving front will return the item, and then retrieving the back will be null/error?
>>
>>54772911
the entire point i'm making is about entitled indie game devs
>>
In C++, why can't I return a class via its abstract superclass?

e.g.
struct A {
virtual void f() = 0;
};

struct D : public A {
virtual void f() {
//do stuff
}
};

A g() {
return D();
}


results in

11 : error: invalid abstract return type for function 'A g()'
A g() {
^
12 : error: cannot allocate an object of abstract type 'A'
return D();
>>
>>54772613
you got raped hard tho :^)
>>
>>54772435

Is this incorrect since it won't get runs of different characters in the target set?

E.g. "ABC", "AB" will yield 1 instead of 2?
>>
>>54772712
That reminds me.

>try to figure out some code
>if (e.ErrorCode == 0x80135415) doStuff();
>jesus christ you retarded code monkey, couldn't you spare ten seconds to write a comment?
>svn blame
>written by me

another time

>need store a file in an application server
>try to figure out how other file storage code does it
>find file storage class that takes a stream and returns a UUID
>lets you give UUID to get stream back later
>no having to set up temporary directories, implement blob storage, deal with file replication, refactor shitty existing code
>saves me days of work
>this is awesome, who wrote this uncharacteristically useful marvel in this piece of trash codebase?
>svn blame
>written by me
>>
>>54772943
no i didn't, you were wrong, you're the one who got raped, you're just delusional as fuck that your weak ass trolling counts as "raping"
>>
>>54772918
Better install AVG, McAfee, and Malwarebytes too. You can never have too much protection against those gosh darned hackers.
>>
>>54772955
>>find file storage class that takes a stream and returns a UUID
>>lets you give UUID to get stream back later
We all do that. Nothing to be proud of. I hope that you have a security layer.
>>
>>54772596
>he uses begin
>>
>>54772939
Because you
cannot allocate an object of abstract type 'A'
, pajeet. Didn't you learn in Java class that you can't instantiate abstract classes?
>>
>>54772883
it's printing ascii control codes
>>
>>54772920
Since when is a dequeue circular?
>>
>>54772939
A *g() {
return new D{};
}
>>
>>54772997
return new D{};

>main wants the D
>>
>>54773018
 error: type too short 
>>
>>54771196
>lisp
*Flow-Matic and COBOL

LISP steals from everyone.
>>
>>54772988
But what does it mean?

My code works as follows, I do the pollEvent from sfml, if it's a keypressed or released event it's put into a class that has a map of keys and strings, and picks out the right string to put it into a list. Now to test the class I just get the list and print out the string that was put into the list. Then I clear the list. The list is a forward list that consists of pointers to the strings inside the map that connects the event to the strings.

The program fucks itself after the second time the list actually contained something. So the first time it will print out the string, and the second time it just self destructs.
>>
>>54772989
So on an empty list, if I insert to front, back should be null?
>>
How can I tell if a client has closed its AF_UNIX socket without communicating it?
Say I force quit my client program, how would I go about noticing this on my server?
>>
>>54773051
>Flow-Matic
>COBOL

two extremely shitty languages that can't even do a faction of the things a modern *lisp can.
>>
>>54772977
No, friend. This was in a codebase where key/value pairs were stored in an array, and EVERY SINGLE access to these values were implemented as a for loop to lookup and optionally a for loop to copy the contents to an array of size +1, adding the new element at the back.

Given that it didn't reuse as much as a C# Dictionary or even a damn List, you can imagine how uncharacteristically useful this feature was.
>>
>>54773098
Try to read or write the socket.
>>
>>54773059
maybe there's something wrong with the list like you're getting memory corruption or something
>>
>>54773123
I'll get a read error? Nice. All I needed to know.
>>
>>54773122
It's not because you did better than morons that you're a genius.
>>
>>54773059
If you print a string every character is by most defaults interpreted as Ascii char. If there aren't chars in it in the first place, but numerical values, and one of the printed byte fields is 7 (the number seven not the character '7') it beeps, because it's the control char Ascii BEL (Bell). So you might not actually have chars in there after all, or arbitrary and/or uninitialzed random data. Or it doesn't have a null determined as end and is now just reading garbage.
>>
>>54773087
First of all, why are you trying to implement a deque as a list? It's inefficient.
Second, if your deque only has a single element then both front and back should point to the single element. Meaning no.
>>
>>54772715
Well that's because the first code you posted was the correct form. It can't magically detect that you fucked up; it would have to be able to program for you to do that. AIs aren't replacing programmers yet.
(cond (= (modulo x 15) 0))

expands to
(if =
(begin
(modulo x 15)
0)
(begin))

Above code while stupid and meaningless looks pretty correct to me sempai.
>>
>>54773143
Oh FUCK now I realize what I have done. I fucking deleted the damn strings when clearing the list, but those strings were inside the map, so the map tries to read the string and boom.

Fuck that was stupid, thank you for helping.
>>
>>54773138
No, there are other reasons. The point is that I've been both negatively and positively surprised by code I forgot I had written.
>>
>>54772951
That's not what the spec asked for.
>>
>>54772939
>>54772987
I'm not trying to instantiate A, but D though.
The error message notices allocation, however I don't see the impossibility of having a function return an object via an abstract superclass.

How else would I return an object like D() without using dynamic allocation?
>>
>>54773195
You could have mimick git and use SHA1 instead of GUID.
>>
>>54773144
>First of all, why are you trying to implement a deque as a list? It's inefficient.
It's for homework.

>Second, if your deque only has a single element then both front and back should point to the single element. Meaning no.
If that's the case, then if there's only one element, front and back would have to point to each other.
This assignment is meant to be like a variation of to learn about linked lists/stacks/queues, I suppose maybe the specifications of it are more unique to the assignment itself, rather than the class/library in C++. I guess it'd be best to ask my professor, just thought I'd check here if people had to do something similar before.
>>
>>54773270
That may have been better, though you can find SHA1 collisions these days.
>>
>>54773257
Object slicing m8. When you return from a function that returns "A" (not A* or A& that's a different story) it means that the program has to construct an A out of whatever you've passed "return". It won't be THE SAME object like in Java, it will be a different one, which is an A and is NOT a D. Returning is copying because not everything in C++ is a reference. Yeah that's basically it.
>>
>>54773386
Or sha256.
>>
File: IMG-20151028-WA0025.jpg (43 KB, 440x585) Image search: [Google]
IMG-20151028-WA0025.jpg
43 KB, 440x585
>>54773386
>mixing up finding and encountering
How's that rape culture phenomenon going on gurlz?
>>
>>54773361
A deque is just a special list that only allows insert/remove at the front and rear. All the middle elements are hidden.
You need 4 functions: insertfirst,removefirst,insertlast,removelast.

Do you know how to implement a basic linked list?
>>
>>54773470
Plz explain intended burn
>>
File: 20160527_230321.jpg (235 KB, 639x555) Image search: [Google]
20160527_230321.jpg
235 KB, 639x555
>>54773386
>>54773470
Lrn2write in English GOW!
>>
>>54772767
>>54772767
>>54772767
BUMP
>>
>>54773470
kike shill go back to your pay2play hellhole
>>
>>54773388
Could theoretically C++ allow for returning instances as abstract types?
>>
>>54773629
By providing size information of the returned object for example
>>
>>54773589
https://en.wikipedia.org/wiki/Shoelace_formula

Skip the daunting parts and just look at A_tri
>>
>>54773691
yeah i used that to calculate the area of the lightblue polygon.

but i want to calculate the area of A, B and C polygon.

the thing is, i'm suppose to write a program to calculate A, B and C given the vertexes of the polygon.
in the input they give the coordinates of the lightblue polygon and i'm expected to find the areas inside the total polygon, that is A , B and C.
>>
Ok so I've progressed in compiling
http://mosra.cz/blog/magnum-doc/getting-started.html
But I still get this when compiling. It does detect clang now though.
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /c/Programs/LLVM/bin/clang.exe
-- Check for working C compiler: /c/Programs/LLVM/bin/clang.exe -- broken
CMake Error at /usr/share/cmake-3.3.1/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/c/Programs/LLVM/bin/clang.exe" is not able to compile a
simple test program.


I've checked clang.exe and it compiles C fine but when I do C++ (like include and use iostream) it goes bonkers:
http://pastebin.com/cmH7tn3T

I've tried clang++.exe and clang-cl.exe. Same exact errors.
>>
why is the heap even called the heap if it's not a fucking heap
>>
>>54773730
Area A is defined by three vertices in the light blue polygon, right? The formula would tell you the area.

Sounds like maybe the assignment is to more generally find the convex hull though.
>>
>>54773667
Either heap-allocate, or explain to me how you make an array of the type that the function returns (there can be only one eh).
Maybe the closest thing would be, given an exhaustive list of subclasses that you're interested in, a type that always occupies enough space to host the biggest of the subclasses, something like Boost.Any or github.com/lourkeur/polybox (GIVE ME STARZ PLIZ) (even tho Boost's is both more versatile and space efficient and we're talking SJWhub)
>>
>>54773778
What do you think a heap is?
>>
>>54773784
>Area A is defined by three vertices in the light blue polygon, right? The formula would tell you the area.
no area A is defined by 4 vertices (see pic)

>Sounds like maybe the assignment is to more generally find the convex hull though.
what do you mean?
i'm using the simple graham scan algorithm
>>
>>54773822
I'm talking about the heap of a program, as in dynamically allocating memory to a program in for example C, and the data structure heap.
>>
>>54773850
What do you think a heap is? Why the head isn't a heap for you?
>>
>>54773842
C is 3, and you can feed those 3 into shoelace to get the area. A is 4, and you can feed those 4 into shoelace to get the area.

If you have the path of a convex hull, you can also shoelace that to find the total area, and subtract the area of the polygon to find A+B+C.
>>
>>54773927
>C is 3, and you can feed those 3 into shoelace to get the area. A is 4, and you can feed those 4 into shoelace to get the area.
you're absolutely right. but they give me in the input the coordinates of the lightblue polygon. only.
i can calculate the area of that polygon easily. i can also calculate the total area of the polygon, finding first the convex hull.

the problem is that i want to calculate the area of the "empty spaces" inside the total polygon. But knowing the coordinates of the light blue polygon , how can i do that?

that's my question
>>
File: Untitled359874.png (129 KB, 1920x1029) Image search: [Google]
Untitled359874.png
129 KB, 1920x1029
This stuff again
>>
>>54774012
All the points in A, B and C are also points in the lightblue polygon, anon.

And if you want the sum of those areas rather than identifying and sizing each area independently of the others, that's simple and already explained.
>>
>>54774019
Are you ever planning on releasing it as OSS/commercial project or is it something internal?
>>
>>54774012
Let E be the set of edges that form polygon P
Let E' be the set of edges from Graham_Scan(P)

If you have an edge e' in E', you know that there is a sequence p_0, p_1, etc. from endpoint e'_0 to e'_1 that forms a polygon if there is a point adjacent to either endpoint that is not in V' (you should be able to see how it doesn't matter which endpoint you start at.) If that is the case, start at your arbitrary endpoint and find the cycle. You now have the points and can calculate the area for that polygon.

This is assuming you want each polygon separately. If you want the sum you can do it much faster.
>>
>>54774121
to continue: when you are searching for a cycle you need a case if you encounter a point in V' that does not make the edge in question. Imagine the convex hull of a star: from a point you could walk in either direction and find a point not in the convex hull, but if you go the wrong way you'll hit a point that makes up a DIFFERENT edge in E'
>>
No Hime no code.
>>
>>54774105
MIT license and commercial support, probably.
But by now it's far from finished.
I just want to compete against Active Directory and everything around it.
>>
File: sol.png (48 KB, 812x612) Image search: [Google]
sol.png
48 KB, 812x612
>>54774076
>All the points in A, B and C are also points in the lightblue polygon, anon.
>And if you want the sum of those areas rather than identifying and sizing each area independently of the others, that's simple and already explained.
i want to find the area of A, B and C independently of the others anon

>>54774121

>Let E be the set of edges that form polygon P
>see pic related where i added the points
E = x1, x2, x3, x4, x5, x6, x7, x8, x9, x10

E' = x1, x3, x4, x7, x8, x9

i'm trying to understand what you said anon
>>
>>54774121
>If you have an edge e' in E', you know that there is a sequence p_0, p_1, etc. from endpoint e'_0 to e'_1 that forms a polygon if there is a point adjacent to either endpoint that is not in V' (you should be able to see how it doesn't matter which endpoint you start at.) If that is the case, start at your arbitrary endpoint and find the cycle. You now have the points and can calculate the area for that polygon.
i don't understand. can you explain better anon?
>>
>>54774261
Apologies. I'll step you through what I said given your new picture.

Graham scan gave you the points that make the convex hull: V' = { x1, x3, x4, x7, x8, x9 }.

(x1, x3) is an edge in the convex hull. Let's find out if it makes a polygon. Select an arbitrary endpoint of that edge: x1. Does x1 have any points adjacent to it that is not in our set V'? Yes, x2 and x10. That means (x1, x3) must form a polygon.

We now find the cycle from x1 to x3. I won't go in too much depth here but give you the exceptional case. x1 walks to x10. x10 walks to x9. We've gone to another point in V' that is NOT a part of our edge (x1, x3). That means we've gone the wrong way. x1 walks to x2 walks to x3. That's our polygon. Now we have the points that make it up and can calculate the area.

Another exceptional case: (x3, x4) both have adjacencies to points not in V'. It will walk both directions, encounter points in V' in both directions, and return that no polygon exists.

Does all of that make sense?
>>
>>54774424
>>54774423

>Does all of that make sense?
i will try to solve the problem with the information you gave me!
it shouldn't be too much hard.
thank you so much!
>>
type 'a tree =
| Leaf
| Node of int * 'a * 'a tree * 'a tree
;;

let weight = function
| Leaf -> 0
| Node (w, _, _, _) -> w
;;

let rec insert x = function
| Leaf -> Node (1, x, Leaf, Leaf)
| Node (w, y, l, r) ->
let swap =
if weight l < weight r then
(fun l r -> l, r)
else
(fun l r -> r, l) in
let x, y = min x y, max x y in
let l, r = swap l r in
let l = insert x l in
let l, r = swap l r in
Node (succ w, y, l, r)
;;

let rec take = function
| Leaf -> failwith "take"
| Node (w, x, Leaf, Leaf) -> x, Leaf
| Node (w, x, l, Leaf) ->
let y, l = take l in
x, Node (pred w, y, l, Leaf)
| Node (w, x, Leaf, r) ->
let y, r = take r in
x, Node (pred w, y, Leaf, r)
| Node (w, x, l, r) ->
let yl, tl = take l in
let yr, tr = take r in
if yl > yr then
x, Node (pred w, yl, tl, r)
else
x, Node (pred w, yr, l, tr)
;;
>>
>>54774492
welcome :^)
>>
>>54773778
http://grammar.yourdictionary.com/for-students-and-parents/words-with-multiple-meanings.html
>>
>>54774493
fix
let rec take = function
| Leaf -> failwith "take"
| Node (w, x, Leaf, Leaf) -> x, Leaf
| Node (w, x, l, Leaf) ->
let y, l = take l in
x, Node (pred w, y, l, Leaf)
| Node (w, x, Leaf, r) ->
let y, r = take r in
x, Node (pred w, y, Leaf, r)
| Node
(w,
x,
(Node (wl, xl, ll, rl) as l),
(Node (wr, xr, lr, rr) as r)) ->
if xl > xr then
let _, tl = take l in
x, Node (pred w, xl, tl, r)
else
let _, tr = take r in
x, Node (pred w, xr, l, tr)
;;
>>
I'm working on a multifunction tax calculator so I can figure out what my gross salary needs to be to make a living wage

fuck the US tax system, shit's way too complex
>>
>>54774537
same anon here, i'm trying to simulate what you said in python.
i already programmed the graham scan in C++.
blue_polygon = [(7,21), (12,19), (11,16), (14,17), (12,22), (14,23), (16,21), (17,24), (12,26), (10,23)]
graham_scan_polygon = [(7,21), (11,16), (14,17), (16,21), (17,24), (12,26)]


for i in points_b:
if i in points_a:
#
>>
File: bSS.png (65 KB, 1068x389) Image search: [Google]
bSS.png
65 KB, 1068x389
why aren't the results showable
I even added a Show b constraint and it still doesn't show
pls help
>>
Where the fuck can I find a basic pseudocode example of delaunay triangulation? Finding a readable source for this shit is impossible, and finding a prewritten script for it is even more impossible. Why the fuck is such a popular technique so hard to find?
>>
>>54774720
It's complaining that the type is ambiguous, not that it's not showable
>>
>>54774720
If you un-rice your desktop so it looks more like something from this page
https://anders.unix.se/2015/12/10/screenshots-from-developers--2002-vs.-2015/
Your IQ score will rise slightly and you'll be able to figure it out yourself

Until then your gaudy gap-ridden rice will bombard your brain with visual noise and subconscious thoughts of fruit, rendering you slightly dumber
>>
>>54771500
#include <stdio.h>
#include <string.h>

int longestStreak(char *source, char *target) {
int start = 0;
int longest = 0;
int i = 0;
while (source[i] != '\0') {
i += 1;
if (source[i - 1] != source[i]) {
if (i - start > longest && strchr(target, source[i - 1]))
longest = i - start;
start = i;
}
}
return longest;
}

int main() {
printf("%d\n", longestStreak("AABGZZZARRRRRR", "AG")); // returns 2
printf("%d\n", longestStreak("AABGZZZARRRRRR", "AGR")); // returns 6
}
>>
>>54773098
Still this guy.
The earlier solution did not work.

I have C code where in the main I open a pool of threads, then allocate a list, and launch a series of accept on the socket I'm already listening on in a loop, saving the new socket IDs on the list until the list is full.
Meanwhile the pool of threads I launched is waiting on a signal from the main which will tell them that there are elements on the list, and once they receive it they will go ahead, take the new socket ID my main has gotten from the accept, and start reading it. If the read fails it should set the condition for its inner loop to false and exit, going back to looking at the list.
My problem is, this condition is never set to false, because the read never fails, even if I've exhausted all there is on a socket.

So does anyone know a different way to check if a client, on a socket AF_UNIX, has been killed and/or has closed its socket?
>>
>>54774875
while (source[i]) {
i++;
>>
>>54772631
>100+ line functions
http://number-none.com/blow/john_carmack_on_inlined_code.html
>>
Are there any ASP.NET MVC 5 faggs around? I need help
>>
>>54774912
I find i += 1 more readable when it's on a line of its own, if it was a part of some bigger statement or a for loop I'd use i++
>>
>>54775033
++i;
>>
>>54774912
while(source[i++]) {
>>
>>54774875
    while (source[i] != '\0') {
if (source[i] != source[++i]) {
if (i - start > longest && strchr(target, source[i - 1]))
longest = i - start;
start = i;
}
}
>>
>>54772340
there's an app for that
>>
>>54775142
>>54775160
>lets put the increment on some random fucking place so it's less readable and straight-forward, but atleast we saved a line right?
>>
>>54775251
>butthurt
>>
File: 1410803613002.png (199 KB, 544x408) Image search: [Google]
1410803613002.png
199 KB, 544x408
>>54774825
>have spent hours googling by now
>no helpful results
>>
>>54774825
>prewritten script
babby...
>>
>>54774825

5 seconds in google

> basic pseudocode example of delaunay triangulation
https://github.com/Bl4ckb0ne/delaunay-triangulation
>>
How does one alter a 2D array from a function in C? Essencially my 2D array is in my main and I want two functions to use it. One to populate the array, and one to print a section of it to the screen. The printing one works fine. I figured I could make the function that populates the 2D array and since its all done through pointers, I wouldnt need to do any kind of return value. Unfortunately I cant seem to get the populating function to fill the array. Its important to pass the array because I need 8 values from the array to decide what the generated element in question will be. Passing in 8 values every time seems cumbersome, but if I can't alter the array from within the function I'll have to.

I may just have to read up on pointers more, or maybe make a global 2D array. Beginner in C btw.
>>
>>54775343
>https://github.com/Bl4ckb0ne/delaunay-triangulation
Thanks, hopefully I can learn something from this

>>54775314
Prewritten scripts and pseudocode examples are the most useful learning tools for me. Pages explaining graphically how a script works don't really do it for me.
>>
>>54775343
This isn't pseudocode and has a lot of problems that I've seen in other examples, where not a lot is commented properly and there's a lot of syntax making the scripts an unreadable mess.
>>
>>54771122
I wrote a calculator using my own parser combinators.
>>
tbl1 = {'alpha', 'beta', 'gamma'}
tbl2 = {'delta', 'epsilon', 'zeta'}
tbl3 = {}
mt = {}

setmetatable(tbl1, mt)
setmetatable(tbl2, mt)
setmetatable(tbl3, mt)

print(getmetatable(tbl1) == mt)

function mt.___add(a,b)
local result = setmetatable({}, mt)
-- Copy table a in first
for i = 1, #a do
table.insert(result, a[i])
end

-- Copy table b in second
for i = 1, #b do
table.insert(result, b[i])
end

return result
end

add_test = tbl1 + tbl2
print(#add_test)


>[string "stdin"]:27: attempt to perform arithmetic on global 'tbl1' (a table value)

Why am I getting this error? (Couldn't find on stackoverflow)
>>
Im curious how many of yall are capable of doing stuff like this

http://cs229.stanford.edu/materials/ps1.pdf
>>
>>54775557
good job dude
>>
>>54775611
if it is like in python you have to put the word
 global 
before the variable inside the function, so it knows it is a global variable
>>
>>54775628
I can solve supervised learning problems with my own multilayer perceptron code, though it would be better to use tensorflow and more advanced architecture.
>>
>>54775478
the pseudocode looks super clear, what are you even intending to use this for, you can't expect to get spoon fed for everything
>>
>>54771122
>>>54772767
>B and C are both triangles and A is just 2 triangles. you know the coordinates of all the points so just do the math
This
>>
>>54775654
Yup, debugging it was hard.
Now I think maybe I should do a very simple programming language interpreter.
>>
>>54775407
>>54775478
you literally only looked at it for like a few minutes jeez

apply yourself
>>
>>54775698
are you retarded?
>>
>>54775673
sounds impressive, did it take you long to learn all the necessary mathematics?
>>
>>54775406
Show us the headers of the two functions.
>>
>>54772802
this

>>54772847
solve it in the same way you'd solve it with pen and paper
>>
>>54775694
I want the user to be able to draw out a polygon, place points inside of it, and get a triangulation.

Ideally pseudocode isn't filled with language-specific syntax and explains how the data is arranged (e.g. point lists, etcetera) so that I can figure out how everything works together.
>>
>>54775715
Deep learning (also known as connectionism and artificial neural networks) is actually the easiest algorithm/method from Machine Learning theory-wise. You just code a nonlinear blackbox and tune its parameters until it solves your problem.

If you want a tutorial, play
http://playground.tensorflow.org/
and read
http://karpathy.github.io/neuralnets/
>>
newbie in python

how do i know the position of a element in a list?

example:
i want to find the number 44

my_list = [1, 55, 66, 98, 11, 44, 33, 256, 11, 77]

my_list.get(44)

??

>>
>>54775758
:= is declaration
// starts a comment until the end of the line
for each x in y do is self-explanatory
lists... you should know what a list is
>>
Sup cunts, anyone have experience with Android programming? I'm trying to get an activity to open up with a different transition (slide in from the right) but it refuses to work.

I've added `overridePendingTransition(R.anim.from_right, R.anim.to_right);` after the activity call and after the finish() in the called activity.
>>
>>54775785
https://www.google.com/search?q=how+do+i+know+the+position+of+a+element+in+a+list

read https://okepi.wordpress.com/2014/08/21/how-to-become-a-programmer-or-the-art-of-googling-well/
>>
>>54775785
don't use python it's shit
>>
>>54775785
list.index(n)

Returns the index of the first appearance of n in the list.
>>
>>54775672
Didn't work. Ty for helping
>>
>>54775777
cool thanks I'll have a look.

I was just watching the stanford lectures on machine learning last night and got a bit inundated with all the mathematics.
If I play with working examples things will probably start to make more sense
>>
>>54775611
t1 = {'alpha', 'beta', 'gamma'}
t2 = {'delta', 'epsilon', 'zeta'}
mt = {
__add = function(a, b)
local x = {}
for _, v in pairs(t1) do table.insert(x, v) end
for _, v in pairs(t2) do table.insert(x, v) end
return x
end
}

setmetatable(t1, mt)
setmetatable(t2, mt)

t3 = t1 + t2
print(#t3, table.concat(t3, ','))
>>
>wake up
>eat
>drink a ton of coffee
>waste time at the computer
>get tired
>fap
>get sleepy
>sleep
>goto start
>>
>>54775787
I understand basic syntax. I don't understand a lot of the language-specific syntax in the script - for example, it doesn't really help me understand what on earth a 'supertriangle' is.
>>
File: 1439903195165.png (536 KB, 776x840) Image search: [Google]
1439903195165.png
536 KB, 776x840
Imagine you receive an android body by mail.

It has a 48 degrees of freedom (DOF) with 12 hrs of battery life (avg physical activity) with all necessary sensors (eye CMOS cameras, microphones, gyro/accel, tactile sensors, speech dynamic) and 10-core ARM CPU inside (there is a wifi as well, so offloading computation to the cloud is possible), and a microcontroller for precise motion control linked to main CPU.

You have a full access to software and firmware, you can use standard dev tools (compilers, runtimes) and OSes for main CPU and the microcontroller.

How would you program it?
What are the main technical problems in this project?
Which approaches/methods/algorithms would you use?
Which software would you use?
>>
>>54775859
Clearly it's a triangle with superpowers.
>>
>>54775611
>>54775672
I'm a total dumbshit I used 3 underscores instead of 2 in the __add

¬¬
>>
>>54771527

I'm a negro lover, but I'm no statist.
>>
>>54775859
>add super-triangle to triangulation // must be large enough to completely contain all the points in pointList
it's a big triangle that covers all the points

https://en.wikipedia.org/wiki/Bowyer%E2%80%93Watson_algorithm
>First step: insert a node in an enclosing "super"-triangle

RTFM
>>
>>54775880
>https://en.wikipedia.org/wiki/Bowyer%E2%80%93Watson_algorithm
The pseudocode in that article might be more useful to me than the other implementation, thanks.
Thread replies: 255
Thread images: 23

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.