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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 23

File: an-older-worker-in-his-office.jpg (737KB, 1348x1134px) Image search: [Google]
an-older-worker-in-his-office.jpg
737KB, 1348x1134px
Previous thread: >>55996728

What are you working on, /g/?
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
>muh lambdas
>>
Studying fucking dynamic programming for fucking interviews fuck
>>
I'm redoing some school assignments in c++ to get more familiar with the language, and last project I worked was just an array list class. I was going to add a copy constructor, but wanted to run it, and make sure it still worked as is so far.
I think I just had some problems with
>using namespace std
This is just some of the error
/tmp/ccI9fUGv.o: In function `main':
ArrayListdriver.cpp:(.text+0x42): undefined reference to `std::cout'
ArrayListdriver.cpp:(.text+0x47): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
ArrayListdriver.cpp:(.text+0x51): undefined reference to `std::ostream::operator<<(bool)'


I removed using namespace std, and the error went away, but went wrong? Why shouldn't I be using namespace std? I find it particularly strange, because last time I worked on this 3 months ago, I didn't have this problem.
>>
>>56003496
>dynamic programming
define

Dynamically-typed?
>>
>>56003514
If you think that using namespace is the root of your problem, you simply don't understand C++ or its syntax.

Try writing all of your applications without namespace.

Then once you get used to it, i.e. after you understand operator overloading and everything involved in it, try using namespace again.

Logically speaking, it's simply the removal of redundant namespace calls. The only time using namespace should EVER cause a problem, is if a library or header you're using has a name collision with another library or header.
In which case you start specifying scope by sticking std or whatever everywhere.

tl;dr the problem is not using namespace.
>>
>>56003514
Hmmm, never mind. It's going back to all this undefined stuff even with and without using namespace std.
I'll have to mess around more.
>>
http://www.strawpoll.me/10939705

>>56003468
Inline, anonymous function declarations are pretty obvious, why did it take so long for them to be added to mainstream languages?
>>
>>56003533
It's a type of algorithm. Djikstra's algorithm is considered a dynamic programming algorithm.
>>
>>56003468
>I enjoy passing function pointers to other functions while writing the relevant code somewhere it totally doesn't belong
>>
>>56003598
>passing function pointers
nigger wtf are you doing
>>
>>56003606
Have you ever written a hash table?
>>
>>56003614
>>>/g/wdg
>>
>>56003624
>>>/trash/
>>
>>56003598
>dependency injection is wrong
>>
>>56003606
He's dynamically picking a function.
>>
Good resource for a beginner to learn .net CORE?
>>
>>56003443
What do they teach in college? I want to start learning it myself before enrolling in tafe or uni
>>
>>56003674
>what is object polymorphism
>>
>>56003702
How do you think virtuals work?
They (indirectly) carry a function
>>
>>56003702
A meme.
>>
Is this poor form when inserting data into a database?
I'm not sure if this is how you compose SQL statements.
sqlite3_stmt *stmt2; /* insert some stuff into database */
char *random = random_text(45);
char insert[1000];
sprintf(insert, "INSERT INTO sample(field) VALUES(\"%s\");", random);
free(random);
sqlite3_prepare_v2(db, insert, -1, &stmt2, NULL);
sqlite3_step(stmt2);
sqlite3_finalize(stmt2);
>>
>>56003714
so pass objects or function pointers instead of memey one-liner lambdas, what's the problem
>>
File: suckit.png (168KB, 1600x835px) Image search: [Google]
suckit.png
168KB, 1600x835px
I made a script to dived a image up into blocks.
from PIL import Image
im = Image.open("arrow.jpeg") #build the image object.
pix = im.load() #build the image object this has all the pixels

#Get the width and hight of the image for iterating over and make sure it's devisable by 10.
image_croped_x = (im.size[0] - (im.size[0]%10))
image_croped_y = (im.size[1] - (im.size[1]%10))

#setting some vars.

red = 255
green = 0

image_done = False
line_done = False
block_done = False
y_point = 0
y_count = 0
x_start = 0
x_end = 10
x_point = 0
while image_done == False:

if line_done == True:
if x_point >= image_croped_x - 5:
print "image is done"
image_done == True
break
else:
x_start += 10
x_end += 10
line_done = False
y_point = 0
print "starting new line"


else:
print "Image is not done - State: %r" % image_done

while line_done == False:

if block_done == True:
if y_point > image_croped_y:
print "line is Done"
line_done = True
break
else:
if red == 255:
red = 0
green = 255
else:
red = 255
green = 0
y_count = 0
block_done = False
print "line is not done - State: %r" % line_done
print "block Is starting - State: %r" % block_done

while block_done == False:
if y_count == 9:
block_done = True
break
for x_point in range(x_start ,x_end):
print "%d %d %d %d " % (y_count, y_point, x_point, image_croped_x)
pix[x_point,y_point] = (red, green , 0)
if block_done == False:
y_point += 1
y_count += 1


im.show()
>>
File: feels_good_pepe.jpg (20KB, 329x357px) Image search: [Google]
feels_good_pepe.jpg
20KB, 329x357px
Finally seeing some applications of polymorphism and Dijkstra's and so on with this transportation game I'm making. I class everything as extended from a node and use Dijkstra's to find the shortest routes between them and so on. Pretty fun stuff :)
>>
>>56003702
Something that doesn't exist in C.
>>
>>56003758
Holy shit you're dumb

You know what, why do you use objects?
Why don't you use some other fucking retarded concept that uses objects under the hood but adds another fucking 10 books of UML and stupid constraints, syntax and imcomposable inventions of idiots that don't know what they're doing?

For instance, why not have a virtual object factory that returns the object you want to pass in?

Oh, but that's totally not a meme.
Using X disguised as Y isn't a meme, using X is.

>function pointers
Can't be portably or conveniently generated at runtime.
>>
>>56003817
you could emulate it, or just use plain function pointers and structs
>>
>>56003758
lambdas are good for one liners.
That's really all.
Why write a function that performs one line of code, and then pass the pointer of that function?

Where would you even place this function? It only does one thing, and it's out of place in comparison to the rest of your functions.
>>
>>56003826
nice strawman argument

>generated at runtime
yet lambdas can? what shitty meme lang are you using?
>>
>>56003836
>why use X when you can use X to emulate Y
>>
>>56003758
A lambda is just a function value, like how 3 is a number value. What did you think the function pointer was pointing to?
>>
>>56003700
Java?
>>
>>56003850
Yes, because

Lambdas aren't function pointers, they're objects of anonymous classes with overloaded operator()s. Those are member functions that could have associated state.

The point is you can't generate function pointers at runtime but you can generate objects of lambda classes are runtime.

>strawman
It's perfectly true.


Do you know why C# and Java and F# have inline object expressions?
Do you realise that they were trying to achieve the same functionality?
An object that inherits is like an extensible map or record of functions
>>
>>56003850
>yet lambdas can? what shitty meme lang are you using?
Python, C#. C++. Scheme, Common Lisp...
>>
>>56003700
java and C++
>>
>>56003900
>>56003904
please, show us how to dynamically generate a lambda expression at runtime in C++, show us how it's done
>>
File: sure_is_summer1.jpg (61KB, 1280x720px) Image search: [Google]
sure_is_summer1.jpg
61KB, 1280x720px
>>56003939
Eat a dick.
http://en.cppreference.com/w/cpp/language/lambda
>>
>>56003799
what are the image dimensions?
>>
>>56003939
Either you didn't read what I said or you didn't understand.

Expressions don't get generated at runtime, but lambdas are bound to values that can be.
Lambda objects can be generated at runtime because lambdas are just anonymous classes with a function call operator.
>>
>>56003443
freecodecamp

i feel like i failed myself somewhere
>>
>>56003961
>>56003974
you're thick as a fucking brick

and how is overloading an lambda object less meme than using normal objects
>>
>>56003699

To learn anything .NET, MSDN is the answer.
>>
>>56003986
>overloading a lambda object
What are you talking about?
>>
>>56003997
>Lambda objects can be generated at runtime because lambdas are just anonymous classes with a function call operator.
what are YOU talking about? post code, in C++
>>
>>56003997
you're thick as a fucking brick

how is overloading an lambda object less meme than using normal objects
>>
>>56003986
>overloading an lambda object
You don't even know what the words you use mean.
>>
>>56004012
What is "overloading a lambda object"?
Please explain
>>
>>56004022
>overloading an lambda object
You don't even know what the words you use mean.
>>
>>56004020
>Lambda objects can be generated at runtime
You don't even know what the words you use mean.

KILL YOURSELF
>>
>>56004030
I'm not the one who used them
I want anon to explain what overloading a lambda object is

>>56004010

auto printer(int x) {
return [x](){ std::cout << "Hello! I am number " << x << ".\n"; };
}

this is equivalent to

class ___my_anonymous_lambda_class_328925 {
auto operator() {
std::cout << "Hello! I am number " << x << ".\n";
}
int x;
}
// ...
___my_anonymous_lambda_class_328925 printer(int xParam) {
return ___my_anonymous_lambda_class_328925(xParam);
}




>>56004037 see ^
>>
>>56003496
I don't think they expect you to invent dynamic programming solutions on the spot.

That's kind of hard.
Imagine inventing the solution to 0-1 knapsack off the back of your head. Who the fuck does that?
>>
>>56004058
you're fucking retarded
>>
>>56004058
So, for example, comparisons

With OOP you're forced to use some kind of ICompatator object, which contains a single virtual function, which you must define elsewhere (I will be assuming you acknowledge object expressions are the lambdas of OOP)
This ICompatator object literally contains a function (generally by pointer/reference) but a few people don't recognise this as it's hidden behind the OOP concepts of members and polymorphism.

The alternative is you pass in a function explicitly, and use a lambda, which means you don't have to define something elsewhere. You can define your one-use function inline.


>>56004090
The example is dumb but it demonstrates the point.
Instances of ___my_anonymous_lambda_class_328925 are generated at runtime, with different bound variables.
This is the primary difference to function pointers.
>>
>>56004082
>Who the fuck does that?
Me. I often ask candidates for a solution to the multiply constrained knapsack problem, or, multidimensional knapsack problem.

Those who can't answer are not fit for the role.

The position usually is about optimization in low-level hardware CPU-architectures
>>
>>56003905
Cheers
>>
Posted in the other thread, but that one is kill

>>56002882

I guess 2 is optimal over 1. Though the only optimization there is taking (2 - 1) out of the equation when you call factorial(2).

That was an oversight by me, but I've only been writing python/code in general for just under two weeks. I think it's fair.

Regardless, thanks
>>
>>56004037
Lambda objects are generated at runtime, like most objects.
import random

def create_a_new_lambda():
value = random.random()
return lambda : value

create_a_new_lambda()()
create_a_new_lambda()()
create_a_new_lambda()()
create_a_new_lambda()()

By the way, an object doesn't have to be something created by calling a constructor.
>>
>>56004120
you define your one-use function inline at COMPILE TIME, not runtime.
>>
>>56004134
you're welcome
>>
>>56004058
Maybe he's talking about closures? I'm not 100% sure on how C++ implements them. If captured variables are statically allocated, or if after the function returns the variables are moved out of the function similarly to how Lua implements upvalues. If they are allocated on the stack and moved out after function exit, then the binding happens at runtime, so "Lambda objects have to be generated at runtime". But really only the binding occurs at runtime. I think he doesn't quite understand what he's talking about.
>>
>>56004140
i'm talking about C++ (not python) since >>56003904 brought it up
>>
>>56004159
>>56004167
Yes, closures. The binding occurs at runtime, which is the generation of a lambda object. A lambda in C++ is an anonymous class with a function call operator.

>>56004159
Look at my example here >>56004058
auto printer(int x) { return [x](){ std::cout << "Hello! I am number " << x << ".\n"; }; }


I call this, with a number only available at RUNTIME, e.g.
int x = 0;
std::cin >> x;
myPrinter = printer(0);
Now I can use this function object, which is bound to that value:
myPrinter();
>>
>>56004167
see >>56004159

>>function pointers
>Can't be portably or conveniently generated at runtime.
he's implying that lambdas can be generated at runtime, but in C++ (at least) you can't generate a different function from what you wrote in the source code (portably without using hacks), the distinction between normal functions and lambdas is more or less just syntax
>>
>>56004171
>Oh no, he's right! Maybe if I pretend he's only right for Python and lambdas have wildly different semantics in C++ I'll be okay!
>>
>>56004195
you can call a function pointer with a runtime number too you complete moron
>>
>>56004124
Sounds like you'd use linear programming to solve that.
Not that I'm knowledgeable on the subject.
Everywhere I've read about linear programming absolutely refuses to dive deep into the subject of actually solving the linear program in favor of just setting it up and letting it roll through MATLAB.
>>
>>56004195
>A lambda in C++ is an anonymous class with a function call operator.
Yes, but the code itself cannot be generated at runtime. Each application would require an embedded JIT. Only the data is binded during runtime, just like virtual functions. The compiler already knows exactly what variables are captured during compilation. you can't "move" a lambda generation into another function and have it work.
>>
>>56004212

Lambda objects can be.
When you use the term 'lambda' in C++ you refer to one of three things that are all part of the same system, or the system all together

1. The expression / syntax
2. The anonymous classes generated by 1
3. The objects / instances of 2

Objects can be made at runtime

>>56004226
Look at what it's doing
myPrinter is one of the lambda objects generated by printer
printer takes parameters and returns a lambda
the lambda it returns TAKES NO PARAMETERS
>>
>>56004225
see >>56004212

we're talking about different things, you can generate different function logic at runtime
>>
>>56004226
The lambda isn't being called with a number.
>>
Hey /g/, I have a working pathfinding implementation based on A*. It works but I have an issue, it runs quite slowly for what I want it to do. What I want it to do is check A* of around 2000 elements against 2000 elements quickly, and It isn't going too quick (It has been going about 3 minutes and it is about 1/3 of the way through). Is there any tips you would have to optimise it?
>>
>>56004231
i was actually kidding, but it amazes me people still replied to my comment
kek
>>
>>56004245
*can't
>>
>>56004249
Are you absolutely sure that you have actually implemented A*?
What happens if you create a maze with no walls or movement penalties?

Are you aware of what a heap is?
I get a lot of people trying to write A* without knowing what a heap is.
>>
>>56004256
>i was actually kidding

Thank the lord. There are interviewers who have those expectations, though.
>>
>>56003636
>muh design patterns
>>>/loo/
>>
>>56004318
>muh using words to describe things
>>>/specialed/
>>
File: smeg on the big screen.png (1MB, 998x728px) Image search: [Google]
smeg on the big screen.png
1MB, 998x728px
Problem: you have two kinds of geometrical objects, points and lines. Write a function to reflect one object around another.

Statically typed solution:
Point reflect(Point obj, Point pivot);
Point reflect(Point obj, Line pivot);
Line reflect(Line obj, Point pivot);
Line reflect(Line obj, Line pivot);


Dynamically typed solution:
def reflect(obj, pivot):
fun = None
if isinstance(obj, Point):
if isinstance(pivot, Point):
fun = reflectPointAroundPoint
elif isinstance(pivot, Line):
fun = reflectPointAroundLine
elif isinstance(pivot, Line):
if isinstance(pivot, Point):
fun = reflectLineAroundPoint
elif isinstance(pivot, Line):
fun = reflectLineAroundLine
if fun:
return fun(obj, pivot)
return None

def reflectPointAroundPoint:
pass

def reflectPointAroundLine:
pass

def reflectLineAroundPoint:
pass

def reflectLineAroundLine:
pass
>>
>>56004318
>>>/poo/in/loo
>>
>>56004287
Yeah, as in the heap you malloc to?

It is close to A*, and while it doesn't have walls as such, there are differently weighted tiles (So I suppose you could make a wall by having a huge addition to fscore). I wouldn't say it was a 100% pure implementation, but it works.
>>
>>56004350
No, as in the min/max heap data structure.
It's not absolutely necessary to use a heap to implement A*, but you do need it if you want it to run fast in an amortized fashion.
>>
>>56004242
Yes, the code isn't generated, but lambda objects ARE.

In the first part of >>56004244
The objects are generated at runtime
This is generating functors (C++ usage) at runtime
Functors (C++) are function objects

There is a direct relation to virtual classes
Here's the example I gave earlier, OOP style:

base classes / utility
template <typename A, typename B>
class Function { virtual B operator() (A) const = 0; };

template <typename R>
class Function<void, R> {
virtual R operator() () const = 0;
// C++ would error without this specialisation
};

#define comma ,
#define to comma


code on the usage side
#include <iostream>
class customFunction : Function<void to std::string> {
public:
customFunction(int parameter) : x(parameter) {}
std::string operator() () const {
return std::string("hello ") + std::to_string(x);
}
private:
int x;
};

int main() {
customFunction functor(5);
cout << functor(); // hello 5
customFunction functor2(98);
cout << functor2(); // hello 98
return 0;
}



(also when I said = delete earlier I misused it, I meant = 0)
>>
>>56004350
https://en.wikipedia.org/wiki/Heap_(data_structure)
>>
>>56004350
He probably meant a heap as in the data structure. It's used to implement priority queues, which can be used in heuristic search algorithms like A*.
>>
>>56004331
>muh programming buzzwords
>>>/DESIGNATED/
>>
>>56004398
>muh memes
kys
>>
File: curious octopus.jpg (30KB, 480x326px) Image search: [Google]
curious octopus.jpg
30KB, 480x326px
>>56004373
>#define comma ,
>#define to comma
>>
>>56004245
>>56004267
Except you can generate functions with different logic using high order functions. Saying functions can't be dynamically created because the code that generates it is static is like saying objects can't be dynamically instantiated because their classes are static.
>>
>>56004433
Function<int to std::string>
>>
>>56004398
>>muh programming buzzwords
yeah like lambdas
>>
>>56004410
Design patterns ARE memes.
>>
>>56004345
I hope you know that to reflect something, you need more than just a single point as a point of reference.
>>
>>56004371
>>56004374
Alright, I will check it out. Thanks, it also sometimes will hang on positions which is a bit odd, but I am sure I can weed out why.
>>
>>56004436
>Except you can generate functions with different logic using high order functions.
in that case you can "generate" functions with function pointers as well.
>>
>>56004471
He's using functions to refer to functors or function objects
These can have bound state
Function pointers can't, they would need an additional parameter
>>
>>56004453
hello neet, how was your day?
>>
>>56004433
>>56004440
Oh and if you mean the redundancy of comma, that's a mistake
I used to do it because you can pass a macro "comma" to another macro, but you can't pass a , to a macro
>>
File: don't be a retard, anon.png (76KB, 1000x1000px) Image search: [Google]
don't be a retard, anon.png
76KB, 1000x1000px
>>56004459
You sure?
>>
>>56004436
>you can generate functions with different logic using high order functions
You could do that in C... Functions are structs, function creation with higher-order functions is really just creating new structs with different bindings set at runtime. The structs are used by the code generated to utilize them by calling the function pointer in the struct with the struct as the first argument.

You're right, C++ is nice in that the structure creation and binding is done for you, but it doesn't mean functions are generated at runtime. The language knows exactly the structure of the objects at compile time. It couldn't reason without that ability. Look and I think you'll find that lambdas and varargs don't mix, guess why...
>>
>>56004542
Familia, where are you getting that line from?
You cannot assume that you can just generate a line using the line from Point A to Point B as perpendicular to the reflection line.
>>
File: sad_mess1.jpg (100KB, 800x680px) Image search: [Google]
sad_mess1.jpg
100KB, 800x680px
>>56004471
I hope you're trolling.
>>
>>56004558
The function objects are functions themselves
Not primitive functions, but they are functions
>>
>>56003966
626x626 I think i see what your getting at i tested a larger image and ended up going past the pixel count and braking it
>>
>>56004558
Here we are with the "If it can be done in a language implemented in lang X, it can be done in lang X" meme
>>
>>56004562
Of course you can.
http://www.mathopenref.com/constperpextpoint.html
>>
How can I calculate the average of two ints in C?
>>
>>56004600

Simply not possible.
>>
>>56004558
>>56004574
Oh and in C++ you shouldn't use varargs, you should use variadic functions.
You CAN mix C++ variadics with lambdas.


auto bind(auto f, auto ... params) {
return [&f, params...](auto ... extraparams) { return f(params..., extraparams...); }
}

auto add(auto a, auto b) { return a + b; }

auto add5 = bind(add, 5);
auto x = add5(3);
>>
>>56004606
Maybe I can get away with using a lookup table?
>>
>>56004599
nigga that simulation shows a line that already exists

you've got a single point.
Not a vector, but a point.
If you had a vector, I'd see your point, but alas, you only have a point.
>>
>>56004504
Fine Pajeet, how was yours? How many design patterns did you have to use to solve a problem that is a piece of cake in my language?
http://www.norvig.com/design-patterns/design-patterns.pdf
>>
>>56004558
You're confusing the semantics with the implementation. Yes, you can create structs with function pointers in C, but they still won't be lambdas. They'll be structs with function pointers inside. Lambdas are lambdas because of how they can be used not how they are implemented.
>>
>>56004558
this

lambdas are basically syntactic sugar, you're not actually generating function logic at runtime and lambdas don't have special powers like someone implied
>>
>>56003533
Divide and conquer + memoization
>>
File: 1468866470632.png (342KB, 1000x1012px) Image search: [Google]
1468866470632.png
342KB, 1000x1012px
Prolly I'm going to start interviewing for a C# + WPF position in the next coming months (1-3). I'm going to review some knowed algorithms since I haven't implemented one in like 1 or two years when I was using C.
Any other advice?
>>
>>56004651
Lambdas aren't just function pointers, they can have bound state
>>
>>56004651
What about closures?
>>
>>56004651
Just because something could be implemented as syntactic sugar for something else, doesn't mean that it's not a separate language feature.
>>
>>56004637
What the fuck do you mean? It shows the *construction* of a line perpendicular to the reflection line that passes through the point. The reflection of the point is also, serendipitously, constructed along the way.
>>
>>56004669
Write a WPF application that visualizes pathfinding.
You'll probably wrap everything up in one go that way.
>>
>>56004673
Closures are a function pointer + extra data to fill in free variables. The free variables may change, but the generated code that actually gets run is still the same. But that's not "just a function pointer": the important thing is you don't have to manually deal with the structure of closure, and can use them like a function.
>>
>>56004669
>knowed
Here's some advice, learn English first.
>>
>>56004687
Nigga when you're trying to reflect a point around another point, you don't have a reflection line.

You can't just invent one because you don't have that information.

Unless you make a rule out of thin air that "Using the line perpendicular to the line created by two points as a reflection line is allowed", you do not have enough information to reflect one point around another point.
>>
>>56004651
Lambdas aren't syntactic sugar anymore than classes, functions, conditionals, loops, numbers, or any other thing that has to be implemented. If everything that has to be implemented is syntactic sugar than the label "syntactic sugar'"doesn't mean anything.
>>
>>56004637
draw a vector from the point smartass
>>
>>56004637
>>56004716


the reflection line is the reflection point + the direction
the direction is the tangent to the line from the reflected to the reflecting point
i.e.

a b

a->b

|
a-b
|
b
a b
b
>>
>>56004675
>>56004719
the point is that you're not actually generating function logic at runtime and lambdas don't have special powers like someone implied
>>
>>56004692
Going to try that, ty.
>>56004705
Yep, sometimes my english is fucked up. But I don't think it really matters that much since I'm capable of reading programming/tech books while understanding the 99% of the content, also I'm not apllying in a country that uses english as first language.
>>
>>56004744
not him
>you are not actually generating function logic at runtime

You ARE generating logic at runtime, you aren't generating function pointers at runtime, you aren't generating C/C++ "primitive" functions at runtime, you aren't generating code at runtime, you ARE generating functions at runtime, the "special powers" you keep saying are just me saying there's bound state in a functor<a to b> but not in a function pointer b(*)(a)

This is all I've been saying
>>
>>56004574
Yes. But when you say 'generate' you are implying something is happening which is not. Certainly, in a JIT'd interpreted language new functions are in fact generated (if performance enhancing), but not so in AoT compilation.

>>56004643
How is that important? I could add lambda semantics to C with a little (lot of) m4 action. Implementation is the only thing that matters, because as this fag
>>56004585
pointed out, if it can be done in language implemented in lang X, it can be done in lang X. You are escaping the reality that languages are just nice ways to generate assembly code. Usually, they have static analyzers in them to make sure what you described makes sense.

Certainly, I'll never try writing that m4 closure pre-processor, but the fact that I can trivializes the existence of "proper semantics", because they do the same thing.
>>
>>56004722
What fucking vector?
You have a two dimensional point. You do not have directional information.

>>56004740
And since when did you declare that you could use that line?

Did you just magick it up in your head, "Yeah, that makes sense", without considering that you literally invented a line out of nothingness and excuses?
>>
>>56004777
swapping in a variable is hardly "generating logic" in programming terms
>>
>>56004792
you have TWO points, or a point and a line, or two lines
>>
File: here you go retard.png (31KB, 559x561px) Image search: [Google]
here you go retard.png
31KB, 559x561px
>>56004716
Hell, that's even easier than the case with the point around the line. You simply draw the line connecting the point and the pivot, draw a circle around the pivot that goes through the point, and when you intersect the circle with the line you get the reflection.
>>
>>56004777
>you aren't generating code at runtime
by this I mean machine code or C++ expressions, you are generating abstract code and abstract expressions at runtime, i.e.

f(x, y) = x < y
g(x) = x < 5

>>56004789
>when you say 'generate' you are implying something is happening which is not
No I'm not implying that or trying to imply it

>>56004792
a is the reflected
b is the reflecting
you can take the vector a to b from information you already have
then you get the tangent of a to b
then you centre that tangent on b
now you have a reflection line

>>56004814
i would say that two points is slightly more than a point and a line

>>56004802
do some FP and you'll change your mind
>>
>>56004814
But you're forgetting that you invented those two lines.

You could say "Reflect across the perpendicular line created by the two points", but you could not say "Reflect one point across another" without inventing information.
>>
>>56004836
>do some FP and you'll change your mind
*tips*

it's perfectly equivalent to using a "primitive" function with a variable
>>
>>56004838
Yes you can. >>56004818
Unless you think you can't connect two points to form a line, or draw a circle around a given center that goes through a point. Those are literally all the compass and straightedge constructions do.
>>
>>56004789
>How is that important?
Just because it can be done in a language implemented in X does not mean it can be done in X. If all you care about is Turing equivalence, go write in assembly. According to you, assembly totally has lambdas, classes, functions, conditionals, and loops, because it can implement them.
>>
>>56004862
Maybe if you're using it for very simple examples, but I'd say a cryptographer would think
encrypt(value, key) and encrypt(value) have very different implications


>>56004838
>>56004866
Actually now I've thought about it, this doesn't really work well for a shape
It makes sense to reflect a point with a point, but with a shape and a point it's not at all obvious which point on the shape to use
I suppose you could take the mean
>>
>>56004744
>the point is that you're not actually generating function logic at runtime and lambdas don't have special powers like someone implied
What is generating logic at runtime? An eval function?
>>
>>56004866
In the first place, what I'm trying to get across is that reflecting a point around another point by inventing a reflection line is meaningless.

It's the fact that the reflection you created is meaningless is the problem.
It's like someone telling you to answer the question "Why does the universe exist?" It's purely philosophical, and inventing information to answer a meaningless question is key to finding that answer.

You can't provide a solution to a question if you do not have the prerequisite information. As such, you would have to explicitly define what the reflection around two points looks like, otherwise you have a meaningless transformation.
>>
>>56003606

You're fucking retarded
>>
>>56004900
>I'd say a cryptographer would think
>encrypt(value, key) and encrypt(value) have very different implications
as i said in >>56004802 i'm talking in terms of programming
>>
>>56003836

you're stupid and you don't realize it
>>
>>56004927
What is "generating logic" then?
>>
An xml editor written in ksh93. Because I hate my job and it keeps it looking like im busy all day.
>>
>>56004910
I'm not "inventing a reflection line". You can try taking another look at the picture at >>56004818. There's no line that I'm reflecting the point against, only the line that connects the two points, the line that the reflection line would be perpendicular to.
>>
>>56004862
>>56004900

incidentally the majority of logic in FP programs IS done by composing functions

>>56004927
What is the difference between logic and programming logic?
As >>56004909 says, do you just mean eval?
In your mind is "generating logic" generating language expressions?

>>56004910
You can reflect a point around a point and have one geometrically meaningful and intuitive solution

The line isn't invented, it's the tangent of the line from the point being reflected to the point of reflection

If you've got a shape it doesn't necessarily make sense which point on the shape to pick to create the line, but if you've got a single point it does
>>
>>56004651
>lambdas are basically syntactic sugar,
Wasn't this the start of the entire argument, someone said that lambdas are memes since function pointers exist then another person said that function pointers require the one-time-use function to be defined somewhere else rather than where it would be used. It's literally the root of the argument.
>>
>>56004910
https://en.wikipedia.org/wiki/Point_reflection
>>
What's the best resource to learn how to write a lexical analyzer?
>>
>>56004941
How they don't notice you aren't doing shit?
>>
>>56004935
basically if your program could reprogram itself at runtime, because simply binding a variable doesn't count as generating logic in terms of programming (not talking artsy fartsy computer science), because you could achieve the same thing with a normal function with a parameter/variable
>>
>>56004893
>According to you, assembly totally has lambdas, classes, functions, conditionals, and loops, because it can implement them.
Yep. Assembly with a massive macro library and processor. Engineering tools for productivity. And yes, semantics are important, abstractions are important, but don't pretend that they are more than templated implementation.
>>
>>56004979
No idea. Im going to see how long I can make it before they catch on. We use AIX alot so it usually looks like I may actually be doing something when Im just typing away in the shell.
>>
>>56005020
In that case every high-level language is "Assembly with a massive macro library and processor. Engineering tools for productivity."
>>
>>56004976
Google "Finite State Machine"
>>
>>56004973
and then this asshole came and derailed the thread with his shitty meme argument against OOP and his ridiculous claim about generating functions at runtime >>56003826
>>
>>56004082
>knapsack problem
i haven't solved this problem before, and i just wrote a dynamic programming solution in about 5 minutes
>>
>>56005019
That's called reflection. No, lambdas don't provide reflection.
>>
File: 1470631297468.png (441KB, 640x958px) Image search: [Google]
1470631297468.png
441KB, 640x958px
>>56005049
good job figuring out the amortized runtime, familia.
>>
>>56004838
>but you could not say "Reflect one point across another" without inventing information.
yes, you reflect in the direction from the reflectee to the reflector
>>
>>56005035
Yeah, how isn't it? Is Haskell actually magic and doesn't even use the assembler of the machine to execute?
>>
File: pizza2.jpg (42KB, 600x450px) Image search: [Google]
pizza2.jpg
42KB, 600x450px
>>56005020
You misunderstood. I'm telling you that you're wrong. Being able to implement something is not the same as already having it. You're like the fat jogger on the couch guzzling cola and potato chips. "I can get in shape whenever I want, so I'm already in shape!"
>>
>>56005019
>simply binding a variable doesn't count as generating logic in terms of programming

"Simply binding variables" is the fundamental principle of lambda calculus and the foundation of computing

Do these functions have different logic?
l = a list of boolean variables

> if all the elements in l are true, do X

> if at least one of the elements in l is true, do X

> if none of the elements in l are true, do X
>>
>>56005062
i didn't figure out the complexity, just wrote a simple solution
>>
>>56005089
>> if all the elements in l are true, do X
>> if at least one of the elements in l is true, do X
>> if none of the elements in l are true, do X
you are hardcoding this into the source code, you're not generating it at runtime
>>
>>56005100
But then there's no point because it's an NP-complete problem

You could say "I brute forced the shit out of that", and it'd still be a solution
>>
>>56005019
> because simply binding a variable doesn't count as generating logic in terms of programming

all possible logic can be synthesized from variable binding and substitution
>>
also
>>56005089
>"Simply binding variables" is the fundamental principle of lambda calculus and the foundation of computing
>>56005019
>in terms of programming (not talking artsy fartsy computer science)

fucking sperg
>>
>>56005107

Haskell:

f = foldl (&&) True
g = foldl (||) False
h = foldl (\x y -> (not x) && (not y)) False
>>
>somebody in AGDG is trying to defend OOP by saying that it's not really about orienting your code around objects
>>
I say we listen to what Ruby and OSGTP have to say.
>>
>>56005149
whoops h might be a mistake
this should work
h = not . g
>>
File: mycalc.png (3KB, 640x300px) Image search: [Google]
mycalc.png
3KB, 640x300px
Working on a command line calculator. Started it months ago but now that I'm a better c programmer I rewrote most of it.
>>
>>56005112
well i mean, it should be the same complexity as the standard dynamic programming solution unless there's a bug
>>
>>56005164
Ruby is winning the worst tripfag poll somehow by 3:2:2, so we should listen to him
>>
File: 1410126560229.jpg (22KB, 348x343px) Image search: [Google]
1410126560229.jpg
22KB, 348x343px
>mfw the only language I know is MATLAB
>too impatient to learn another
>>
>>56005182
Remember:

Ruby = daddy
OSGTP = mummy
nv = doggo
>>
>>56005200
Learn C. It's a very compact language.
>>
>>56005200
That's not a language.
>>
>>56005036
i'll check it out, thanks
>>
>>56005212
I'll look into it, thanks friend-anon :^)
>>
>>56005227
Alternatively you might try Lua, it's higher level than C but not bloated like Python/Ruby.
>>
>>56005175
Then you're missing the point of an interviewer asking the question in the first place
>>
>>56005245
hue
>>
>>56005201
Invoke*
also, I was wondering. If OSGTP likes nigros, then Ruby would be one?
>>
>>56005263
Lua's source is 300KB.

Python's source is 20MB.
Ruby's source is 17MB
>>
>>56005245
Ruby is cute tho.
Both the lang and the tripfriend.
>>
>>56005263
Lua is tinier than your dick.
>>
>>56005255
depends on whether you ask for the best solution possible, or just want to know if a truly good solution is possible
>>
File: simple.png (88KB, 890x670px) Image search: [Google]
simple.png
88KB, 890x670px
I'm working on a program to measure the time it takes for recursive merge sort and iterative in c++. But I'm getting really caught up on how to measure the time in milliseconds.

I've gone through alot of stackoverflow and google'd answers but most of them either dont work for my unix g++ compiler or measure in microseconds / seconds.

Im gonna keep googling rn but if anyone has any recommendations I'd love some help.
>>
>>56005372
Man I wish there was a way to convert microseconds to milliseconds.
>>
>>56005389
Wait

micro = 1/1 000 000
milli = 1 / 1000

maybe we ca?

nope, can't think of anything
>>
when I use System#arraycopy in java on an object array and it has null pointers in it does it "copy" those too? what I mean is does it keep the order 1:1?
>>
>>56005407
I don't do java, but seach about "shallow" or "deep" copy.
>>
>>56005421
well arraycopy is function in native code (as in c). so I have no clue.
>>
>>56005436
Check the documentation m8.
>>
>>56005400
>>56005389
Why would the time elapsed still be 0? I'm trying to divide to get ms


clock_t start = clock ();
#define CLOCKS_PER_MS (CLOCKS_PER_SEC / 1000)

mergesort(nums, temp, 0, count);

clock_t time = clock() - start;
unsigned msElapsed = time / CLOCKS_PER_MS;

cout<<"Time Elapsed: "<<msElapsed<<endl;
>>
>>56005541
try converting it to a float first?

if you want to go from seconds to milliseconds then you should be timing multiple operations
>>
I have a chunk system of 512 bytes and I need to set up a read( offset , size ) function that is capable of handling between-block situations Such that Size can span the width of multiple blocks and stop in the middle of one.

If I have a loop that goes through each block id with the index variable "i" how do I intersect the domain between [CurBlock,CurBlock+512] and [Offset,Offset+Size] so I know how many bytes from CurBlock should be read?
>>
cout<<"input the numbers until the array is complete"<<endl;
do
{
cin>>myarray[n];
c++;
}while (c < 10);
sorted = false;
do
{
sorted = true; // once the for loop is completed the boolean will be true
for(i = 0; i < 9; i++)
{
if (myarray[n] > myarray[n+1]);
{
Temp = myarray[n];
myarray[n] = myarray[n+1];
myarray[n+1] = Temp; // the swap
sorted = false;
}
}
}while(sorted = false);

for (j = 0; j < 10; j++)
{
cout<<myarray[n]<<endl; //printing sorted array integers
}
cout<<"the number have been sorted"<<endl;
}


i'm new to c++ and i'm trying to create a bubble sort
don't know whats wrong with it
>>
>>56003572
Because they are disorganized and hard to read in real world environments, which 90% of the time are spaghetti code.
>>
>>56005616
They aren't disorganised or hard to read at all
>>
>>56004345
Python please die
>>
>>56005586
>myarry[n]
>c++;
>>
>>56005643
i've only ever done array input in pascal
how do i fix anon
>>
>>56004610
auto should be forcibly removed from the C++ standard and all the slimy Microsoft nazis who sneaked it in as well
>>
>>56005658
>>>>>>>>n
>>>>>>>>>>>>c++
>>
>>56005669
you're right, you shouldn't need to use the word auto at all, it should just infer unused variables
>>
>>56005182
does anyone care to explain why? he tends to stay on topic, and he's fairly knowledgeable about programming. nv is an FP tard, maybe that's why these neckbeard memers aren't voting for him?
>>
>>56005629
I'm not sure if you're a college-level or professional. They are definitely hard to read when mixed into 13,000 lines of spaghetti code. Complicates things..just a little. But maybe you're a genius. So by all means.
>>
>>56005719
I don't know why, but he is

Maybe it's because he's not an FP fag?
>>
>>56005733
OSGTP should be at the top
he uses C#, wangblows, WinForms, likes niggers, has a rifle or two, etc
>>
how to i input a value into an array index is c++
>>
>>56005752
please kindly do the needful
>>
>>56005740
nv is worse, he unironically likes haskell or some langs like that and memes against imperative langs
>>
>>56005815
he's a kid though so it's fine
OCaml is his favorite i think
>>
>>56005815
I like Haskell
>>
>>56005676
am i just a moron
i don't see whats wrong with this
i only program for a hobby
>>
>>56005827
start over
not with your program, with programming
>>
>>56005815
who wouldn't like haskell
>>
>>56005827
I think he means this

 do
{
cin>>myarray[n];
c++;
}while (c < 10);


What's n?


myarray[c]
>>
>>56005164
>>56005182
What I have to say is this: eat more red meat, drink less alcohol (except for maybe some red wines), and most importantly, learn C.

Anyways, I've got myself a Raspberry Pi 3 sitting in my living room running an ssh server and a shitty http server that just shits out a hello world. I'm debating on some projects to run on this bitch.
>>
>>56005848
thanks man
>>
>>56005586
>n

>myarray[n] > myarray[n+1]
what do you think the n is for, but you're not looping with n, you have c, i, j
>>
>>56005873
>ruby hasn't got past Hello World
>>
>>56005873
Woo, the other thing that you needed to do the thing came in, then? I don't remember whatever the heck it was.
I'm considering getting myself the same meme if I can come up with a cool idea.
>>
>>56005884
It's a placeholder http server to test that I've got all of my networking bullshit set up while I figure out what I want to do. I've written plenty of things more complicated than Hello World. Most of them are ugly as sin though, because they're school projects, and my university.

>>56005887
My HDMI/VGA adapter did not come in the mail. Amazon sent me a refund and I went out to buy one. It's funny, because I didn't really need the adapter except for one day. Right now, the Pi is just sitting around headless after I set a couple of things up.
>>
>>56005873
Daddy, why does mummy suck so much at programming? Doggo is better than her at it.
>>
>>56005980

Woops, forgot to finish that sentence in the first response...

Meant to say that my university runs on a quarterly system, so classes are only like... 10..11 weeks. We cram a lot of information into a short amount of time, but unfortunately, this also means we don't get much time to perfect our programs.

>>56005982

I really am having a hard time imagining OSGTP as anything motherly. I imagine him as sort of a rugged masculine dude, although with less of a literal neckbeard than myself.
>>
>>56006034
But you'd be the girl in the relationship, right?
>>
Learning OpenGL.

Finally have the ability to create an arbitrary number of polygons with arbitrary numbers of sides, and reshape/resize/reposition and re-color them and also render text at the same time.

There were far too many steps in getting to this point.
>>
File: happy family.png (4MB, 3900x2600px) Image search: [Google]
happy family.png
4MB, 3900x2600px
What's the best language and why is it Haskell?
>>
>>56006034
>him
Shitlord, you should respect your own wife's identify and use her pronouns.
>>
>>56006034
>I imagine him as sort of a rugged masculine dude, although with less of a literal neckbeard than myself.

Despite partaking in activities that most people here think are for slovenly rednecks, I don't really look the part. In fact, I probably look like you do.

I try to shave, though. Going out in public with a literal neckbeard is embarrassing.
>>
>>56006080
Mummy, will you teach me Racket, please?
>>
can i become celebrity too
>>
>>56006112
https://www.youtube.com/watch?v=YgHNtzxO0y8
>>
>>56006112
>ozuxJSfx
No, fuck off webshit.
>>
why do if statements within a while loop just get stuck there and never exit? wtf
>>
>>56006130
post your code
you're probably doing something wrong
>>
>>56006129
you missed the UX as well ;)

>>56006130
post code, you're missing somethiing
>>
>>56006130
you fucked up
>>
>>56006130
Have you considered that your logic is dictating that it does exactly what it says it does?
>>
>>56006080

>Going out in public with a literal neckbeard is embarrassing.
I honestly haven't been giving much attention to my appearance. I walk around with a black trenchcoat in almost all weather except this goddamn summer heat because I find the deep pockets convenient. I don't shave my beard or mustache because it's just going to grow back very quickly, and I don't have much time during the school year for much socializing, so I don't really benefit much from looking decent in most people's eyes. After I get my master's degree, I'm probably going to shave, and definitely going to be moving.

>>56006112

If you're not going to get a tripcode that matches some sort of actual word, use a secure tripcode. Also, anyone can become an e-celeb, but you do have to deal with the fact that all e-celebs without exception are total faggots.
>>
>>56006148
>deep pockets
Is that why mummy is with you?
>>
>>56006148
just know me as UXjs, it'll work
also you're not helping us forget that you're a brony
>>
>>56006138
>>56006143
            int loop = 1;
float i = 1;

cout << image->h;

while(loop == 1) {
if (SDL_PollEvent(&event)) {
/* an event was found */
switch (event.type) {
/* close button clicked */
case SDL_QUIT:
loop = 0;
break;
}
}
SDL_BlitSurface(background, NULL, screen, NULL);
SDL_BlitSurface(image, NULL, screen, &imgDest);

if(imgDest.y = screenHeight) {
}
if(imgDest.y = 0) {
}

if((imgDest.y <= screenHeight - image->h)) {
imgDest.y += i;
} else if((imgDest.y >= 0 + image->h)) {
imgDest.y -= i;
}

SDL_UpdateWindowSurface(window);
}

//Sleep(3000); // Pause execution for 3000 milliseconds, for example
SDL_FreeSurface(background);
SDL_FreeSurface(image);
closeWindow(window);
}

Not the entire file, but most of it.
these two blank if statements stop the other code from executing.
I'm trying to make an image move from the top of the screen to the bottom, over and over.
>>
haskell is cool
Main> [(*23), (+13), (/30)] <*> [101]
[2323.0,114.0,3.3666666666666667]
>>
>>56006164
replace = with ==
stop using SDL, use SDL2
don't learn a library before you know how to program
>>
>>56006182
Why are you choosing to become a tripfag?
>>
>>56006182
Even with == to compare it still stops the other code from executing.

and I thought I was using sdl2?
I swear I looked up SDL2 tuts
>>
>>56006164
>while (loop == 1) {
> if (SDL_PollEvent(&event)) {
> ...
>}
> }
The code is going to pause until you click the close button
If there are no events it's not going to close

Change it to this:

while ((loop == 1) && SDL_PollEvent(&event)) {
...
}

This way you exit the loop once there are no more events
>>
>>56006201
edit

misread your code, do this instead
while (loop == 1) {
while (SDL_PollEvent(&event)) {
...
}
...
}
>>
>>56006200
surfaces are a thing of SDL1, of course supported in SDL2 for legacy reasons

use SDL_Texture instead.

Also, if you're following tuts, avoid LazyFoo
>>
>>56006182
Ruby = daddy
OSGTP = mummy
nv = doggo
UXjs = ?
>>
>>56006242
passerby
>>
>>56006249
No, you're part of the family now. You can be the bidet.
>>
>>56006242
UXjs is Ruby's mistress
>>
>>56006148
>I walk around with a black trenchcoat

Yeah, I put in a bit more effort than that.
>>
haskell is cool
j = \x y z t -> putStrLn $ x $ y map z t
f = (!! 20593)
m = \x y -> y x $ m x y
s = \x y z -> [] : (y z >>= (\t -> x (:t) z))
u = map toEnum [74..85] :: String

main = j f m s u
>>
>>56006313

I've had the damn thing for ages, so it's sort of iconic for me. People who know me recognize me by the coat. I don't wear a fedora though. The only fedora I've ever owned was given to me by my ex-girlfriend, and I lost it when moving. In retrospect, I'm glad it's gone.
>>
>>56006432
But are you glad it's dead?
>>
>>56006112
just shitpost and piss people off a lot and you'll appear in quite a few people's filters
>>56006148
please tell me you shower, at least
>>
>>56006439

Chances are I lost the damn thing on a bus somewhere, so it might be floating around on some idiot's head right now. It's not dead.

>>56006473

Yes. I am also partial to nice warm baths.

>>56006473

I honestly want to read your tripcode as "Invoke Wizards of the Coast"
>>
>>56003443
Working on a simulation program that that simulates bacterial/viral growth given specific parameters (climate, region, oxygen levels, pH, water activity, etc.)

It's for this gay internship at my uni, but it pays $14/hr so I said fuck it
>>
>>56006513
dream job dude, nice
better than 16 an hour for integration testing
>>
>>56003799
my brother please help me
I am running the program but it returns error
I require the conclusion to the code email [email protected]
please do the needful
>>
>>56005200
>R
>know that feel

>>56005212
I've been considering it. I tried learning Python on codecademy but got bored with the slow drip of info. However the fact that C can be used for Arduino stuff and has readily available compilers to make .exe's is really enticing, so I might go for that. What's the difficulty level of going from a dynamically typed language to C?
>>
>>56006530
Yeah, I will say it's pretty easy, and I've been able to work with some nasty shit up close like Dengue and Rabies which was cool
>>
>>56006422
>j m f s u
0/10

>j = lambda
don't do this

>map toEnum
All bounded enums can be range constructed

>map
use fmap or <$>
>>
>>56006617
even worse is this

j = \x y z t ->
j x y z t =
and this
j x y = \z t -> ... ... ... z t
>>
>>56006597
C is the easiest language to learn, static typing is no hurdle
>>
>>56006626
>j x y = \z t -> ... ... ... z t
You can't simplify that, it contains two instances of $ and operators are applied after functions
>>
>>56006645
at the very least you can do
j x y z = putStrLn . x . y map z
>>
>>56006597
none because C's type system is a joke
>>
>>56006716
>a joke
>literally the best
ha
>>
>>56006617
>>56006626
>>56006645
>>56006674
>spergs can't see it was purposely obfuscated
s m h = putStrLn $ m map h !! 228
m h s = s h $ m h s
h s m = [] : (m >>= (\t -> s (:t) ['H'..'S']))
main = s m h
>>
>>56006736
>still using map
>>
File: smug pence.png (66KB, 206x369px) Image search: [Google]
smug pence.png
66KB, 206x369px
>>56006628
>C
>static typing
pick one
>>
>>56006742
>why do you use [function1] instead of using [function2] which is defined to be the same as [function1] in the only case you're using [function1]
>>
File: 0383f5dcc9.png (79KB, 1366x768px) Image search: [Google]
0383f5dcc9.png
79KB, 1366x768px
I was discussing with a friend about recursion, and he said mine wasn't because it used "self contained variables". And I don't know if my function is recursive, first and last time I used recursion was 2 years ago while using C.
tl;dr: My function is recursive?
>>
>>56006984
Yes, it's recursive
>>
>>56006507
ooh that's good, you can call me that if you want
>>
morse decoder

go go go
>>
>>56007055
does the morse input include spaces?
if so, this becomes a trivial strcmp loop between 36 different patterns.
>>
>>56006984
It's recursive. Your friend is wrong.
>>
still writing my OPL3 tracker

all of the hardware access code is easy, write some shit to an IO port (other than the register layout being all over the fucking place, using the OPL3 is really easy), occasionally read some shit from an IO port (mostly waiting for vblank), there's enough implemented so far to let the user press some keys and get music to come out

writing user interface code is an absolute slog and I don't want to do that shit though
like, 90% of the remaining work is UI shit (there's also the song player, but that's literally just feeding data from the table into the note play function every 5-6 vblanks)
it's a fullscreen text-mode program, but that still doesn't really make it much easier
>>
File: 1470377563304.jpg (285KB, 800x1200px) Image search: [Google]
1470377563304.jpg
285KB, 800x1200px
>>56006994
>>56007104
Thanks then, have a patche.
>>
>>56006984

Your function is tail recursive. This means that the last action taken is a return, and the entire function can be optimized to a jump, rather than pushing an entire stack frame (note: can and will are not the same thing here. I am not sure what the CLR and the C# compiler will necessarily do here). That there are local variables in the function is irrelevant, because they would normally go out of scope at the end of the function anyways, and so the space used to store them can just get overwritten.

There are other forms of recursion that do not get this sort of optimization. Where control of the function continues after a recursive call is called backtracking, and this necessarily implies pushing new stack frames to store previous states of the function. This can be very useful in a number of algorithms, but it may be wiser to use an explicit stack data structure and just do things iteratively, so as to avoid the possibility of a stack overflow.
>>
>>56007096
strcmp? It's audio you doofus.
>>
>>56007164
CLR/.NET supports tail recursion optimisation fine
>>
>>56007186
ideally, you'd convert your morse audio to plain text patterns
>>
>>56007201

I have read some mixed documentation on this. One suggested that it works perfectly in F#, suggesting that the CLR can do it. Another suggested that Microsoft's C# compiler won't do it for whatever reason. I think there's supposed to be some sort of bytecode instruction to tell the CLR that this is a tail recursive function, and the C# compilers aren't emitting it or something along those lines.
>>
>>56007243
Yea I wouldn't know about C#
>>
>>56003443
Writing a OSRS bot, and updater
I wrote one a few years ago, so not a massive challenge.
These ones are different to the stock standard updater + bot as:
Bot uses the Observer Pattern instead of injecting getters and setters then spamming them
Updater is written in the TypeScript (which i am fucking loving) and targeted to run on AWS Lambda for that whole #MemeLanguage #MemeInfrastrure #LookMomNoServers circle jerk
>>
>>56007266
As soon as Docker runs native on windows (no hyper-v) I will open my arms to our lord and savior Microsoft
>>
>>56007266
> Observer Pattern

OOP patterns are cancer.
FP is dat future.
>>
>>56007164
irrelevant in Haskell where the stack is allocated on the heap :^)
>>
>>56007331

But relevant in languages actually used in the real world.
>>
Can someone explain to me why you would ever need an anonymous function?
>>
>>56007441
Can someone explain to me why you would ever need inline blocks?
>>
>>56007455
Can someone explain to me why you would ever need loops?
>>
>>56007481
Can someone explain why would ever write code?

You can just pay a pajeet a flat fee to write your business logic and be up and running.
>>
>>56007490
>up and running

I hope you're joking
>>
NEW THREAD!

>>56007502
>>
>>56007506
dumbass
>>
>>56007441
>need
>>
File: woods_compr.png (1MB, 640x2496px) Image search: [Google]
woods_compr.png
1MB, 640x2496px
A pretty useless image compression algorithm that in a way tries to exploit self-similarity in an image in a stupid way. It's probably been done before.
>>
>>56007481
>why you would ever need loops?
you don't:
http://www.nsl.com/
>>
>>56006577
What the fuck?
>>
>>56007490
>You can just pay a pajeet a flat fee to write your business logic and be up and running.
good luck with that
Thread posts: 315
Thread images: 23


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.