[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: 42
File: 1444378145195.png (2 MB, 1696x2467) Image search: [Google]
1444378145195.png
2 MB, 1696x2467
old thread: >>52056774

What are you working on, /g/?
>>
>6 memes early
>>
asked in previous one, will ask again pls ty xo

Hi
its 5 am here
Can somebody here help me with an absolute trivial question I have about something in java?

Sorry in advance to all not concerned

So, I have 3 classes, A, B and C.
Class A has a Set <B> b
Class B has a List <C>c
When I want to iterate in class A, doing:
for(B x: b)
for(C y: x.c)
result = y.variable1
//right here, when I want to access a variable from class C, it says: Cannot find symbol - variable variable1


Im a beginner and I would apreciate every bit of help
thanks
>>
Daily reminder that everything said in a premature /dpt/ thread is completely false
>>
Build chan with one main feed controlled by Board filters. you see only posts from boards active in your settings.

just a little practice site
>>
>>52060042

cuck
>>
Friendly reminder that there is nothing wrong with linked list stack implementations.
void stack_push(stack_t *stk, int data)
{
frame_t *frame = (frame_t *) malloc(sizeof(frame_t));
frame->data = data;
frame->next = stk->head;
stk->head = frame;
stk->size += 1;
}

int stack_pop(stack_t *stk)
{
if (stk->head == NULL)
printf("Stack empty.\n");
frame_t *frame = stk->head;
int data = frame->data;
stk->head = frame->next;
stk->size -= 1;
free(frame);
return data;
}
>>
>>52060068
nvm solved ty
>>
>>52060097

enjoy your cache misses, retard
>>
>>52060097
how are linked list so BASED?
>>
>>52060118
cache is a jewish scam invented by intel
>>
>>52060189
every link works together to form one unbreakable thread
>>
Are YOU in on this yet?

https://wiki.haskell.org/wikiupload/2/23/Monad-tutorials-chart.png
>>
>>52060229
Monads are just monoids in the category of endofunctors, what's the problem?
>>
IGNORE TRANNY THREADS

REPORT TRANNY POSTERS
>>
>>52060252
>he hasn't even written a monad tutorial
>what an idiot, I bet he can't even program
>he probably thinks using python is ok
>>
>>52060118
Use an unrolled linked list if you are worried about cache misses.
>>
>>52060263
There's nothing much to get about monads if you're only using them in Haskell, really. They're just glorified continuations.
>>
File: INFINITE.jpg (509 KB, 1295x1009) Image search: [Google]
INFINITE.jpg
509 KB, 1295x1009
>any year
>linked lists
>>
merry christmas fuckboyzu
>>
>>52060311
Obviously you shouldnt use a linked list for random accesss. Arrays are great for random acces; linked lists are great if you want to delete or add items mid-iteration.
>>
>look for freelancing projects
>find a relatively high paid (in retrospective... not so much) one, it's in PHP
>"OK, I guess I can do this shit easily!"
>get the project
>2 days pass
>haven't done almost anything
>shit seems to be impossible to do in PHP 5.3, at least in a decent way
kill me. fucking PHP is hell, who the fuck, ever, thought that this shit language was a useful thing
>>
File: insert.png (306 KB, 1345x752) Image search: [Google]
insert.png
306 KB, 1345x752
>>52060349
>linked lists are great if you want to delete or add items mid-iteration.
niceme.me
>>
>>52060371
>PHP5
You're not allowed to complain until you had to maintain a PHP3 codebase for 6 months or more.
>>
>>52060386
Im highly skepitcal of this benchmark. To delete an element of an array, you need to copy the whole array in O(n) time. Linked lists can have an element deleted in O(1).
>>
Oohh wow, the guy of the OP's picture is fucking right.

Traps + programming = pure horny.
>>
>>52060386
>>52060311
>>52060097

Fucking rekt.
>>
>>52060431
Complexity isn't everything.
>>
Reminder that the most effective optimizations are in proper memory access patterns. Hand written assembly won't help you with this, although you should have an idea of assembly so that you can check the compiler's output.
>>
>>52060431
I was too, especially since you got though the exact opposite in the algorithms class.

Found the old link to the talk in the catalog: https://sec.ch9.ms/sessions/build/2014/2-661_LG.mp4
>>
>>52060447
Still, the graph for deletion looks at least O(n^2). I'd like to see some code, especially because his results differ greatly from both theory and my own benchmarks on linked lists.
>>
>>52060447
>>52060431
It's a slide from one of stroustrup's talks
take it with a grain of salt, he goes around shitting on all languages and design patterns that don't fall in line with C++ features.
>>
>>52060431
>thinks he knows better than world-renowned computer scientists
Prove it by writing a benchmark and publishing the source code.
>>
>>52060486
See
>>52060487
>>
>>52060486
Or maybe he's designing a language with actual computer architecture in mind.

Why should I think some anonymous dipshit on /g/ knows better than mother fucking Stroustrup?
>>
>>52060483
Cache thrashing is a bitch, anon. Though what's probably happening is that most of the time is being taken up by traversing through the list to get to the right spot in the first place. So there's a similar amount of complexity in both cases, but the array approach plays well with the cache.

>>52060486
That has nothing to do with what he's talking about.
>>
To delete the millionth element from a linked list, you need to walk a million elements

(doubly linked might not, also if you have an existing reference (but one wonders how you got to that one without walking a million elements))
>>
>>52060505
stroustrup, pls go
>>
>>52060505
Or, it's possible you've misintrepted the results. Does the benchmark include searching for the element to delete? If so, of course it be slow because searching for an element in a linked lists is a slow process.
>>
hey retards, ignore the fucking bait ( >>52060097 )
seriously, /dpt/, always the same shit, what the hell?
sick, retarded fucks
>>
>>52060535
Traversing 1 million elements of a linked list to delete element 1,000,001 is much faster than reallocing the entire array to delete a single element.
>>
>>52060558
Why? The array is good on cache, and you're not reallocing, you're just shifting everything to the right of that element left. O(n) on a linked list will be far slower than O(n) on an array, in practice.
>>
>>52060544
How do you get an index or reference to an element to delete without traversing the list to find it?
>>
>>52060438
I don't think they exist in real life though... do they?
>>
>>52060544
What's the point of a list or array? To keep things in a block for easy traversal.

Look at the benchmarks: traversal time completely dominates.
>>
>>52060574
>shifting everything to the right
you might as well recreate the entire fucking array with every change you make, because it's literally going to eat up the same amount of time
>>
>>52060583
int *ptr = (int*) rand();


:^)
>>
so, struggling to figure out how to go about something i asked about in the previous thread and would like a bit more detailed help on how to acomplish this, please?
>>52059835
>>
>>52060558
>>52060574
Side point
if I've got [| 1, 2, 3, 4, 5 |] and I delete 3
after shifting [| 1 2 4 5 _ |]
can I not just say "only deallocate the last element" or "let me keep the first bit"
why would I need to reallocate the first half of memory?
>>
>>52060602
No, because if you recreate the array you're always having to go through the entire thing.

This is CS 101 shit, anon. Except the cache parts, but that's not difficult to comprehend.

>>52060610
You don't. You just decrement the length, which is independent from the size of the buffer. When you want to add another element, you then don't have to reallocate and extend the buffer.
>>
>>52060605
I lol'd
>>
>>52060583
I said "deleting an element while traversing" is fast for linked lists but ran dom access. You posted a benchmark that first randomly accessing an elemt then deletes it. Thats totally irrelevant because the random access is the bottleneck, not actually deleting the element.
>>
Benchmarks are shit.
>>
>>52060042
How the fuck can I get a list of running processes (Wangblows,) in D lang?
>>
does that guy with the closure memenchmark still post?
>>
File: 452.gif (705 KB, 500x500) Image search: [Google]
452.gif
705 KB, 500x500
Reminder that GPL is like communism.
>>
>>52060431

You can jerk off about big-O all day, but the profiler doesn't lie.
>>
>>52060042
Fucking faggot
>>
>>52060619
right, but if it's a lot of memory I might need to for practical purposes, are there functions to free only a slice of a memory region
>>
>>52060669
There's nothing wrong with communism, you idiot.
>>
>>52060678
realloc() with a smaller size is guaranteed to chop off the excess and leave the rest untouched. But you need to have allocated with malloc() in the first place, which is not an issue if you're encapsulating it in a vector class or something.
>>
>>52060672
....except the action that was benchmark ed was O(n) for linked lists. Finding an element in a linked list is slow, as we all know. Deleting said element is very fast. The benchmark was slow because it included searching.
>>
>>52060669
Your rights end where the rights of others begin.
That is the foundation of a free society.
Limitations must be put into place and enforced so that nobody can deprive you of your rights.
>>
>>52060687
communism killed more people than nazism
>>
>>52060634
1. I did not post the two pics/benchmarks

2. The random access is meant to model how these data structures are used in real life. You have a lot to learn.

3. Are you seriously saying that we should benchmark deletion rather than the algorithms and data structures themselves? Memory ops are going to be the same for both. I'm sorry, kiddo, but traversal is one of the reasons for having lists or vectors in the first place so it makes sense to include it in benchmarks.

4. I still can't get over how you're here arguing on the internet instead of arguing directly with Stroustrup or Sutter or writing your benchmark. It just proves that you only care about making yourself look smart-- which is retarded considering that you're posting on an anonymous message board.
>>
>>52060700
GPL is like cancer, it's un-American, it's like a virus, it's like communism. It taints everything it comes into contact with and assimilates it into the hive.
>>
>>52060669
notto disu shitto agen
>>
>>52060669
I like to think it's more post-capitalist really.
>>
>>52060745
Yes, when I write GPL software, I do so in order to contribute to free software.
You can reuse and incorporate my code into your product under the express condition that you give your users the same freedoms that I gave you.
If you can't do that, you're free to steal some other permissive software written by a BSD/MIT cuck.
I'm sure they'll even thank you if you send them a note.
>>
>>52060689
thanks

>>52060696
When wouldn't you need to transverse? (either searching for a value or a position, i.e. ordered data)
Advantage of a linked list is /supposed/ to be random insertion and removal, right?
>>
>>52060745
http://zedshaw.com/archive/why-i-algpl/
>>
i want to create program (or hire somebody to) that will continiously download the content from two sites and store them. i need them to keep updated for i fear losing these sites in the years im gonna be away soon .
>>
I honestly can't say with any certainty that I've ever had a reason to delete something from the middle of a list while preserving order of insertion (so swapping in an array-based implementation was still appropriate). I've never found linked lists more appropriate than array-based lists when I care about the performance.
>>
I was thinking of buying one of the 50 dollar kindle fire tablets for android development purposes. I've tried them out and they seem to be excellent for the price tag, but I was wondering if there's some reason why I shouldn't use it as my testing platform.
>>
>>52060304
They're related to continuation in the same way that an atom is related to the moon.
>>
File: 8u.jpg (50 KB, 640x360) Image search: [Google]
8u.jpg
50 KB, 640x360
>>52060766
Using a BSD/MIT license is a greater benefit to society, it's the people that use GPL licenses who are the cucks.

It is contrary to western values.

Bill Gates is a greater man than Stallman will ever be.
>>
>>52060776
Random example: you want to add 2 to every element in an array, but as you traverse, you delete every odd element. The individual deletes will be much less costly if you use a linked list over an array.
>>
Is anyone working on meme snake?

I'd really like to see it tbqh.
>>
fuck im dumb
accidentally posted in the old thread instead of this one so copypasta-ing that shit here:
https://github.com/nv-vn/unbox
shit's been renamed and it's now pretty much done from what I can tell
I covered all options I found on the OpenBox wiki (for version 3.6) and I just added some options to the C wrapper program. Am I missing anything other than good docs?
>>
>>52060529
Cache thrashing can't turn a constant-time algorithm into a square-time one.
>>
>>52060840
That's one (1) realloc for the array version.
>>
>>52060854
meme snake?
>>
>>52060840
The overhead of the structure clearly cancels that out.
>>
>>52060776
If you have a queue or a stack, you always have the head (or tail) pointer, for example. The same is true in structures where you have complex "sublists" that are allocated in one large linked list, and users of the code get handed a reference to the head of the sublist.
>>
>>52060833
you know there are lots of commies in the BSD community, right?
you are retarded, go back to >>>/a/
>>
>>52060872
Teach me senpai.
>>
>>52060869
Did you read the rest of my post or stop at the word "cache"?

>>52060880
That's grasping for straws.
>>
>>52060829
You still have a long way to satori
>>
>>52060893
When the wise man points to the moon, the fool looks at his finger.
>>
>>52060883
It even stands for Based Socialist Distribution.
>>52060887
>That's grasping for straws.
It's very obviously not when all empirical data shows linked list are simply not faster for random insertions in practice
>>
>>52060893
"Monad" is just a buzzword, it literally doesn't have a meaning. You could call it a "thing" or "stuff" or even a ``frob'' and it wouldn't be any more meaningful.
>>
For the odd thing (ignoring the adding because it really makes no difference) you just do a lot of left shifting. I see what you're trying to get at but I still think it could be optimised - definitely could for small arrays (where lots of elements can be loaded at once)

also, what about parallelism

>>52060881
Yes, and if you're doing operations on the head or tail there's absolutely no reason you should be using a linked list, is there?
>>
>>52060905
But it's not random insertion, it's random access + insertion. As expected of /dpt/ - dumb people thread, only retards post ITT.
>>
>>52060905
Oh, I agree with you, it's just irrelevant when purely comparing the performance of deletions.
>>
>>52060883
Yeah, but it doesn't hinder capitalism.

I can use BSD/MIT code in my proprietary software.
>>
>>52060907
m8 its not tho
>>
>>52060907
>talking out of your ass about things you dont understand
nic
>>
>>52060907
See >>52060252
>>
>>52060917
>random access + insertion
What the fuck is the point youre trying to prove here? There is no reasonable real world situation where you don't have to traverse the list.

>not storing the references to all your linked list nodes in an array for instant access
>>
>>52060907
The word "monad" itself, no. But the concept of a monad is concrete, and has nothing to do with continuations. It is literally a monoid in the category of endofunctors, that is the definition of a monad. But the meaning relating to programming is better expressed by "return + join/bind + laws".
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
How do I learn JS senpai?
>>
>>52060950
but that's wrong faggot
>>
>>52060886
uint8_t *array; // given
size_t len = 1024;

for (size_t i = 0; i<len/2; ++i) {
array[i] = array[i*2];
}

array = realloc(array, len/2);


Not tested but you get the idea. If you want to delete every second (odd/even) element anyway, just copy the remaining ones into the first half and throw away the second.
>>
File: VCPOmSW.jpg (884 KB, 2448x3264) Image search: [Google]
VCPOmSW.jpg
884 KB, 2448x3264
I pulled this image from reddit.
How does this make you feel?
>>
>>52060907
>>52060950
Though you will notice that the monad laws are extremely similar to the monoid laws. This isn't a coincidence.

>>52060970
How so, anon?
>>
>>52060926
commies are against the bad parts of capitalism, not against capitalism as a whole, m8
commies are not your retarded contrarian poltard... unlike most people here
>>
>>52060980
About 6 months old, since that's when everyone moved from reddit to voat
>>
>>52060980
euphoric
>>
>>52060907
assuming you think the same thing about monoids:

monoids have a closed, associative binary operation and an identity for it

e.g. the integers and addition

associative:
1 + (2 + 3) = (1 + 2) + 3
e.g., an application in parallelism:
1 + 2 + 3 + 4 = (1 + 2) + (3 + 4)

closed:
addition of integers is
integer -> integer -> integer
(two integers -> integer)
chaining operations is very simple type-wise

identity:
x + 0 = x

>>52060970
>>52060992

this guy is right btw, it's not exactly correct
http://stackoverflow.com/questions/3870088/a-monad-is-just-a-monoid-in-the-category-of-endofunctors-whats-the-problem
>>
>>52060977
Oh - I mean delete the element if it is odd. Ie [2,3,4,5,6,6,6,6] -> [3,5]. An extra complication for an array is you want to add the list [2,3,4] after any element equal to 4.
>>
File: IMG_20151225_234837681.jpg (3 MB, 2340x4160) Image search: [Google]
IMG_20151225_234837681.jpg
3 MB, 2340x4160
Parents got me these for Christmas
>>
>>52060983
Kek.

Commies literally want to abolish private property.

They don't just advocate small regulations in markets to prevent exploitation and monopolies, they're insane.
>>
Haskell weenies are one of the worst things that's ever happened to category theory
>>
>>52061012
>>52061034
How does a list benefit?


>>52061010
(monoids are just an example, i don't know enough about monads)
>>
>>52061062
actually I think a list does worse
1. still got that slow transversal
2. contiguous array elements = multiple loaded into one cache line
3. many opportunities for parallelism
>>
>>52061049
I wish I could properly learn category theory. I feel dirty that my only knowledge is based on stuff from functional programming, and therefore is probably not entirely correct.
>>
File: Laughing-Frog-Man.jpg (25 KB, 400x386) Image search: [Google]
Laughing-Frog-Man.jpg
25 KB, 400x386
>>52061019
>he fell for the SICP meme
>>
>>52061010
you're confusing algebraic monoids with monoid objects
>>
>>52061025
>Commies literally want to abolish private property.
exactly. it's the baddest part of capitalism, a huge restriction to human societies, based purely on an imaginary concept.
>>
File: trewatson.png (179 KB, 512x512) Image search: [Google]
trewatson.png
179 KB, 512x512
>>52061097
>>he fell for the "he fell for the SICP meme" meme
>>
>>52061107
they're the same m8
>>
>>52061141
>Haskell weenie knows all about CT
Not even once.
>>
>>52061148
I don't use haskell

Ok, so which was I talking about? CT or FP?
>>
What should I make
>>
>>52061148
Ohhh nvm, this is what confused me

I was talking about algebraic monoids and monoid objects

Not category theory monoids.
>>
>>52061012
Then you'd make a space-time tradeoff, get one puffer block (L1 size preferably) and make it not 100% inplace.
As you're continuously freeing parts of the source array you use that memory for the destination array, with the buffer as delay for the block you're currently working on.
>>
>>52061167
[b]A chrome extension that adds BBCode functionality to 4chan.[/b]

https://en.wikipedia.org/wiki/BBCode
>>
>>52061235
[spoiler]implying[/spoiler]
>>
>>52061247
>[spoiler]
>/g/
newfag
>>
>>52060042
learnin' C++

trying to hack
>>
>>52061252
>C++
>trying to hack
>>
>>52061235
[style color="red"]>newfags can't red text[/style]
>>
can someone explain this to me
when you have a monad with apply, what's the deal with the whole M<function> thing


>>52061251
>help me i don't understand how jokes work
>>
>>52061261
isn't apply just bind?
>>
>>52061261
What the fuck is "apply" and "M<function>" supposed to mean?
>>
>>52061273
>>52061280

oh is it just the mapped function?
>>
>>52061293
What are you talking about?
>>
>>52061293
What language are you using? What do the docs say?
>>
>>52061298
Reading a tutorial and it says
apply has signature: Result<('a -> 'b)> -> Result<'a> -> Result<'b>

(result is the name of an example monad)
>>
Anyone /react/ here?
>>
>>52061338
I'm too noble for that.
>>
File: 1451091057444.png (253 KB, 620x620) Image search: [Google]
1451091057444.png
253 KB, 620x620
What are union types used for?
>>
>>52061356
What kind of union? The C/C++ kind?
>>
File: 1444143348816.jpg (57 KB, 720x1280) Image search: [Google]
1444143348816.jpg
57 KB, 720x1280
>>52060801
Downloading photobucket nudes huh?
>>
>>52061361
yes
>>
>>52061363
nah, just trying to store content that could be dissapear in the time ill be away. in this case written works.
>>
>>52061361
homosexual unions
>>
What the fuck is Visual F#?
>>
>>52061385
MS cancer plus shitty language.
>>
>>52061390
Why do all ML derivatives have such a terrible type system?
>>
>>52061385
Have you ever considered applying mathematical principles to your codebases?
Then Functional Programming is for you.
>>
rate my hello world
#include <stdlib.h>
#include <string.h>
int main(void)
{
signed char *str = (signed char *) malloc(sizeof(signed char) * 12);
strcpy(str, "hello world");
auto unsigned int i;
for (i = 0; i < 11; i++)
{
putchar(*(str+i));
}
free(str);
return 0;
}
>>
>>52061424
>auto
>>
>>52061424
magic numbers/10
>>
>>52061372
All of the members share the same memory (it's as big as the biggest member).
That's all.

One usage: tagged unions
struct fruit
{
enum { t_apple, t_pair, t_banana } tag;
union
{
apple a;
pair p;
banana b;
//either an apple, a pair or a banana
} onion;
}

void print_fruit(fruit x)
{
switch (x.tag)
{
case fruit::t_apple: std::cout << onion.a; break;
case fruit::t_banana: std::cout << onion.b; break;
case fruit::t_pair: std::cout << onion.p; break;
default: break;
}
}

another usage:
union
{
float v[3];
struct { float x, y, z; }
} elem;
now you can do elem.v to get the data as an array, or do elem.x, elem.y, elem.z, etc

>>52061385
The
Best
Language
M8

No exceptions
other than ocaml
>>
>>52061424
>strcpy
>>
>>52061436
*x.onion.

also note that unions aren't type safe, you need to make sure you type safetly
>>
Why aren't for loops just:

for(100) {
//loop 100 times (0 to 99)
}


And the "this" variable could equal the current number it's at.

For example:

for(100) {
if(this % 2 == 0) {
print(this + ": is even.");
} else {
print(this + ": is odd.");
}
}
>>
>>52061317
Oh, now I understand what you've been confused about. That's not related to the monad exactly, it's the applicative functor part (because every monad is also an applicative functor).

Applicative functors are typically used when you want to map a curried function, often a constructor. Like in a parser (excuse the Haskell syntax, <$> = map, <*> = apply):
instance Functor Parser -- provides <$>
instance Applicative Parser -- provides pure (= return) and <*>
parseInt :: Parser Int
parseString :: Parser String

data Thing = T Int String
parseThing = T <$> parseInt <*> parseString
-- (T <$> parseInt) :: Parser (String -> Thing)
>>
>>52061436
>tagged unions
That sounds like an extremely roundabout way of implementing templates if we're talking C++.
I can see good usage in str8 C though.
>>
>>52061467

void some_class::count()
{ for (100) { std::cout << thi-
>>
>>52061467
most uses of the for loop are more complex than that
also you can just do
int i = 0;
while (i++ < 100)
>>
I have some productivity-related questions

>how many hours do you usually spend programming per week?

>do you practice programming out of discipline or only when you are in the mood?

>do you stick to a scheduled routine that has time allotted for programming? how many hours of programming do you aim for each day?

>generally, how many hours does it take for you to feel burnt out during a single programming session?
>>
>>52061471
It's runtime.
Dynamic dispatch without virtual function calls.
>>
>>52061467
Depending on what language you're talking about, `this` is usually reserved for other, more important things.

It isn't like for loops are all that complicated anyways...
>>
>>52061470
Oh, and
parseThing :: Parser Thing

of course.

>>52061471
Tagged unions are totally different from templates, though a poor programmer might use one when a template would suffice. Tagged unions are when a value could be of one of many types, with the type variable at run time.
>>
>>52061471
It was probably a poor example.

One thing you can do with this is you can query the tag, e.g. as was done in the switch, so you can check if it's an apple or a banana.

You can also change it from an apple to pair for instance.

e.g. fruit x = fruit(apple(params)); // fruit(apple) constructor will set the tag to t_apple and do onion.a = theapple

x = fruit(banana(params)); // still the same variable, "same type"
>>
File: rew.png (441 KB, 1048x587) Image search: [Google]
rew.png
441 KB, 1048x587
What books does /dpt/ recommend?
>>
>>52061534
SICP duh
>>
>>52061479
12-20 hours per week
only when i'm in the mood, but i've been super motivated the last few months so it's basically discipline at this point
one time I spent 12 hours writing computer code and it wasn't fun, it was actually hard to think of anything else afterwards
i went to sleep and dreamt i was still trying to program
>>
>>52061534
Just got this one today:

http://tddjs.com/
>>
>>52061561
I think he meant programming books, anon.
>>
>>52061467
Almost no one does that so often that it requires new language syntactic sugar to make something like that easier.

Let's take C# for example.
Haven't done this in half a year but I'm pretty sure this is right:
Enumerable.Range(0,100) //0 to 99
.ForEach(x => { });

They didn't implement any syntactic sugar just for the sake of incrementing from one arbitrary point to another--they extended on what they already had to produce the desired function

There's two problems with it though: The average codemonkey programmer probably doesn't know what lazy evaluation is and would assume that Enumerable.Range() is memory inefficient.
The second is that it doesn't look nearly as nice as a real for loop, so why would you ever use Enumerable.Range() this way?
>>
>>52061534
Stephen Kochan - Programming in C (4th Edition)
If you're looking to buy it, just get the 3rd edition, the newest one claims to have in-depth C11 coverage but the only thing that was changed was the font.
>>
>>52061565
Yeah, that's why I recommended it.
>>
File: 1406547749110.jpg (229 KB, 800x800) Image search: [Google]
1406547749110.jpg
229 KB, 800x800
>>52061565
sick burn
>>
File: 1447278982315.png (103 KB, 500x500) Image search: [Google]
1447278982315.png
103 KB, 500x500
How to run binary instructions from a file using C? As far as I know one has to spawn a new process and write its memory. How does one do it using standard C and Linux libraries? (I know how to do this on Windows.)
>>
>>52061467
Perl 6:
for 1..100 { say "$_ is " ~ ($_ % 2 ?? "odd" !! "even") }
>>
>>52061376
people already told you how... and you don't seem to care about it, so hire someone.
>>
>>52061534
Do you even need books these days?

You can just learn everything online.
>>
>>52061614
well i was more looking for handholding but honestly im already working on it.
ran into a problem though, some error message im trying to figure out.
>>
>>52061584
What the hell are you talking about?
Be more clear.
I don't know if you're referring to literally just compiling something in Linux, or if you're talking about building a virtualized CPU datapath and memory architecture.
>>
>>52061639
Yeah, every good programming book is available online for free.
>>
File: 1450763534148.png (398 KB, 508x685) Image search: [Google]
1450763534148.png
398 KB, 508x685
>>52061584
I would have told you how, but you posted a frog, so I don't want to.
>>
>>52061731
I remember that reaction image, you communist shitposter.

Get out.
>>
>>52060801
I'll do it email me at [email protected]
>>
>>52061758
subscribed to gay furry porn newsletters
>>
>>52061641
you can do that shit with wget
or, how about you ask the owners of the site?
>>
>>52061663
I want to run hexadecimal machine language instructions which are stored in a binary file, using C.

>>52061731
Fuck off.
>>
>>52061780
well first and foremost i wouldnt even know how o begin that conversation. second the asnswers i had gottem were either python or the wget. i was attempting it via python and already hit a wall.
>>
What's the best language to write a web crawler with? The goal is to crawl the web for specific keywords, and communicate the webpages which contain them.
>>
>>52061811
drop them an email to the address listed in the whois?
>hey, I like your website. for X, Y and Z reasons, I want to make backups. would you let me do this?
>>
>>52061811
man wget
>>
>>52060801
>>52061758
No wait I lied. its [email protected]
>>52061778
N I C E
>>52061776
Its a throwaway so I don't really care
>>
>>52061829
in all honesty im not all that interested in making a backup sites. more accurately i want to download all the things that have been posted there and that will if that makes sense
>>
>>52061865
^and that will be posted
>>
>>52061865
why don't you just say that you want to clone a website? you know, you don't need to lie in 4chan...
>>
>>52061942
i mean believe what you want but its more like i want access to the things on the sites even if the site just dissapears one day.
>>
>>52061828
Perl https://metacpan.org/pod/HTML::Robot::Scrapper
>>
>>52061801
So what?
If you know how to do it in C on Windows, then just do it in C on Linux.
All you're doing is emulating the CPU datapath and registers in a highly inefficient manner.
>>
File: 1438441304668.png (181 KB, 256x733) Image search: [Google]
1438441304668.png
181 KB, 256x733
How do I learn to program?
>>
>>52061956
use https://archive.org , then, or http://archive.is/ , or something similar...

>>52061978
take a programming book, follow the instructions. finish it. congrats, you are a programmer
>>
>>52061978
Who the fuck is the guy in your pic? This is the second time I've seen him.
>>
>>52062001
while that is intersting i want access to the content in question while offline
>>
File: wqs.jpg (798 KB, 1600x1067) Image search: [Google]
wqs.jpg
798 KB, 1600x1067
>>52062007
>>
>>52062007
That's what a forced meme looks like, anon
>>
>>52060042
on a more serious note what moon comic is that from
>>
Literally how to practice programming?
Do you people just write random shit for no purpose?
>>
>>52061967
I used WinAPI to do that in Windows. I just spawned a process, suspended it, and wrote headers + instructions, then ran it.

I have no idea how to do that on Linux.
>>
open System
open System.Windows.Forms

[<STAThread>] do
let f = new Form( TopMost = true, Visible = true, Height = 800, Width = 600 )
let wb = new WebBrowser(Dock = DockStyle.Fill)
let tb = new TextBox(Dock = DockStyle.Top)
let b = new Button(Dock = DockStyle.Right)
f.Controls.AddRange [|wb; tb; b|]
b.Click.Add (fun _ -> wb.Navigate tb.Text)
Application.Run f;


hey guys i wrote my own web browser
all me
>>
>>52062007
>>52062055
>He doesn't know about lisicki
>>
>>52062086
it works with youtube and everything that's just how good i am
>>
>>52062077
You mean to say that you used WinAPI to remote execute a Win32 application, or that you used WinAPI to execute raw binary instructions? I'm pretty sure that the latter is impossible.
>>
File: thatsoundslikeachallenge.jpg (137 KB, 1280x720) Image search: [Google]
thatsoundslikeachallenge.jpg
137 KB, 1280x720
>>52062132
>impossible
>>
File: wew.png (9 KB, 327x615) Image search: [Google]
wew.png
9 KB, 327x615
Post your meme star and meme triangle code, /dpt/.

String.prototype.reverse = function() {
var val = "";

for(var i = 1; i <= this.length; i++) {
val += this[this.length - i];
}

return val;
};

var star = function(str) {
var val = "\n"

for(var i = 0; i < str.length - 1; i++){
val += (" ".repeat(i) + ( str[i] + " ".repeat(str.length - (2 + i)) ).repeat(2) + str[i] + "\n");
}

val += str + str.substring(0, str.length - 1).reverse() + "\n";

for(var i = 2; i <= str.length; i++){
val += (" ".repeat(str.length - i) + ( str[str.length - i] + " ".repeat(i - 2)).repeat(2) + str[str.length - i] + "\n");
}

return val;
}

var triangle = function(n) {
var val = "\n";

for(var i = 1; i <= n; i++){
val += " ".repeat(n-i) + "*".repeat(i * 2 - 1) + "\n";
}

return val;
}
>>
>>52062132
I used the VirtualAlloc routine to allocate memory, then unpacked Portable Executable headers and instructions from the file there, and then redirected execution to the process I created.

I want to do something similar in Linux, but I don't know how to.
>>
I downloaded this a while a go to get started on natively programming for OSX/iOS but even though I'm, shall we say, proficient at C++ I really can't fully understand it. It does an excellent job at explaining the technical side of stuff.

Can anyone recommend me something else to learn Objective-C?
>>
>>52062132
>>52062169
Also, I basically transformed raw binary instructions into the Windows Portable Executable format loaded in memory. I want to do something similar, but in Linux. I want to take in raw instructions, and process them somehow so that they would run as an executable in Linux.
>>
>>52062180
Swift. I don't even like Swift but Objective-C is literally coding hell.
>>
>>52062099
>lisicki
googled a bit, some tripfag (a janitor?) from /sp/ that got doxxed?
>>
>>52062169
Oh.
Then I assume you're familiar with the ELF header format.

I have no idea why you would want to go through so much work when it would be simpler to write a cross platform application and automated compilation suite. You have guarantee of running anything but the simplest of programs due to reliance on external libraries.
>>
>>52062234
*no guarantee
>>
>>52062162
meme triangle hard modo:
given the word "meme" and the size 5
make your output look like this
    m
mem
memem
mememem
memememem
>>
>>52061019
Nice! Are you into a bit of osdev??
>>
show me what you look like (simple stupid websocket app)
https://pasticode.com/#1668439272
>>
File: gdfv.png (97 KB, 710x761) Image search: [Google]
gdfv.png
97 KB, 710x761
>>52062247
>>
File: best.png (5 KB, 565x551) Image search: [Google]
best.png
5 KB, 565x551
>>52062247
>>
>>52062169

I have no idea, but can I ask why you would want to do that
>>
>meme star
>meme triangle
>meme tornado
>meme buzz
don't you people write anything useful
>>
>>52062299
no
>>
File: 1444782012373.png (427 KB, 514x662) Image search: [Google]
1444782012373.png
427 KB, 514x662
whats a good casual filter?
>>
>>52062247
>>52062277
Any other ideas to improve my meme triangle, anon?
>>
>>52062299
you forgot meme spiral
>>
>>52062299
I want to see meme snake.

Somebody better be working on it.
>>
>>52062305
I thought the meme spiral was the meme tornado
>>
meme square
>>
>>52062330
i'm pretty sure you can make a meme tornado by cutting out the exact center of a meme triangle

really, the proper term is string rotation
>>
>>52062336
don't really follow

you got an example?
>>
>>52062346
meme tornado would be something like
MEME TORNADO
OMEME TORNAD
DOMEME TORNA
ADOMEME TORN
NADOMEME TOR
RNADOMEME TO
ORNADOMEME T
...
>>
import std.stdio;
import std.conv;

//tornado.d ~ rudy

void main(string[] args){
writeln(args);
tornado("latematt sucks ", 100);
}

/// tornados the input text
void tornado(string text, immutable int rows){
int n;
string shifted = text ~= " ";
do{
writef("%s\n", shifted);
shifted = shift(shifted);
} while (++n < rows);
}
/// shifts a string once to the right
string shift(immutable string str){
immutable int len = str.length;
string nstr = to!(string)(str[0..len - 1]);
string ret = to!(string)(str[len - 1]);
ret ~= nstr;
return ret;
}
>>
>>52062386
ah, got it
>>
>>52062247
#include <stdio.h>
#include <stdlib.h>

main(argc, argv)
int argc;
char *argv[];
{
int n = atoi(argv[1]);
char *s = "MEME TRIANGLE HARDMODE";
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++)
putchar(' ');
for (int j = 0; j < 2*i - 1; j++)
putchar(s[j%22]);
putchar('\n');
}
}
>>
>>52062162
sub meme_star {
my $str = shift;
my $len = length $str;
my @a = split //, $str;

for(my $n = 0; $n < $#a; $n++) {
my $c = $a[$n];
my $s = ' ' x ($len - $n - 2);
$a[$n] = ' ' x $n . "$c$s$c$s$c";
}

splice @a, -1;
return join("\n", @a), "\n", $str, (scalar reverse $str), "\n", join("\n", reverse @a);
}
>>
File: sds.png (210 KB, 640x360) Image search: [Google]
sds.png
210 KB, 640x360
Awfully quite in here.
>>
>>52062614
post meme star

here's meme star in C
https://paste.installgentoo.com/view/raw/995a844c
>>
File: meh.png (35 KB, 896x816) Image search: [Google]
meh.png
35 KB, 896x816
bit shit but whatever
>>
>>52062635
Is all the code really necessary for meme star in C?
>>
File: holyshit.png (4 KB, 274x240) Image search: [Google]
holyshit.png
4 KB, 274x240
>>52062636
>3d for free
>>
File: ter.png (1 MB, 1087x731) Image search: [Google]
ter.png
1 MB, 1087x731
It's all fun and games until you end up taking memes too far.

Be careful, /dpt/.
>>
Calm down, it's not like memes can bring down an aeroplane
>>
>>52062662
strrev probably isn't necessary
the 3 functions probably aren't necessary either, but i was just being lazy
a well-written algorithm involving X and Y coordinates could be placed within a 2 layer nested for loop.
>>
>>52062767

>nested for loop
>any for loop
>>
>>52062794
what's wrong with nested loops?
>>
>>52062800
Unfortunately I don't have a folder full of smug anime reaction faces like everyone else, but rest assured I would be uploading one right now if I did.
Imagine a particularly smug anime face.
>>
File: 2015-12-26_06-22-07.jpg (18 KB, 310x263) Image search: [Google]
2015-12-26_06-22-07.jpg
18 KB, 310x263
>>52062162

Public Class Form1
Dim pon As New Pen(Color.Black, 3)
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(200, 100)
Dim point3 As New PointF(150, 200)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
CreateGraphics.DrawLine(pon, point1, point2)
CreateGraphics.DrawLine(pon, point3, point1)
CreateGraphics.DrawLine(pon, point2, point3)
End Sub
End Class
>>
>>52062807
>mindlessly spouting other people's opinions
>mindlessly posting other people's smug anime faces
your entire existence is a meme
Thread replies: 255
Thread images: 42

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.