/dpt/ - Daily programming thread
Continuing the type system flame war from the previous thread ( ). Please be refined.
/dpt/ - Daily programming thread
Continuing the type system flame war from the previous thread ( ). Please be refined.
Linear types will save systems programming
>Linear types will save systems programming
tell me how
Also, this was the first image that popped up when I googled "type wars".
Reminder
Ahem.
golang.org
so how many of you are trannies
What did he mean by this
Apparently rust programmers are sewage workers , and go programmers are gay pornstars doing xena parodies.
Rust users use sensible means of protection to avoid getting hurt. Go users have a perverse fetish for restricting themselves in extreme ways.
How does this shit work? Why the fuck we make a recursion, then take tail, then zip? What the hell?
Generates n-th row of Pascal's triangle.
wandbox.org
>What are you working on, Sup Forums?
Exploring the deepest, darkest corners of Racket. Advent of Code 2017 (Day 11)
>there are retards on /dpt/ who think that only static types exist
each element is the sum of the two above it (or above and left in the case where it's displayed to the left)
Is there any Haskell textbook with good problem sets?
>Haskell
>good problem sets
Better off doing advent of code
theres these
wiki.haskell.org
i know nothing bout x86 assembly, where do i start?
>x86 assembly
>where do i start?
Back in the 1980s.
How can Phong shading be implemented in OpenGL using vertex and fragment shaders?
has anyone made any interesting web scraper or crawlers they use daily?
Why can't I decide on a fucking programming language and fucking learn it? I'll start on one make decent progress then get distracted because some other one seems better.
Also, should I continue with Common Lisp, or go for C++? Or Swift, but I don't want to get locked into Apple ecosystem since faggot in chief is wrecking everything.
Device_one_L = 100
Device_one_W = 150
Device_one_H = 75
Device_two_L = 125
Device_two_W = 350
Device_two_H = 50
I don't know how to simplify this in Python3
>should I continue with Common Lisp, or go for C++
Go try C++. It'll really help you appreciate CL.
>pyton
why even bother
Ok, well can you do it in C?
>can you do it in C?
typedef struct {
int L, W, H;
}Device;
Device device1 = (Device){100, 150, 75};
Device device2 = (Device){125, 350, 50};
ok pajeet
Ok, well then how would I address it?
he's unintentionally right though.
The great thing about ASM is that it's largely timeless. So you can pick any decent book.
>then how would I address it?
Not sure what you mean by "addressing it", but you can access the fields like device1.L etc. There's probably something analogous in Python, though.
That's what I meant. Will that also work in C++?
>The great thing about ASM is that it's largely timeless
Tell that to 6800 assembly programmers, if you can find any in your local geriatric department.
Dubs don't lie, C++ it is I guess lol. I like Lisp already but I have my doubts, besides numerical simulations and graphics are what most interest me, aside from meme learning and such. And even though the community for CL seems to be fairly active and whatnot, it's nonetheless minuscule.
>Will that also work in C++?
Yes.
i'm sure he meant x86 assembly
>i'm sure he meant x86 assembly
My response is still relevant no matter what he meant.
class Device
def __init__(self,l,w,h):
self.l,self.w,self.h = l,w,h
device_one = Device(100,150,75)
device_two = Device(125,350,750)
how to use keyword (string) to search a string in text file in C ?
any crypto nerds on need help?
Liquid types are the height of refinement.
Cool, should I start in C or C++?
int summary(){
system("cls");
FILE *fptr;
fptr = fopen(".txt", "r");
fprintf(fptr, "Month: %02d Year: %04d \n", month, year);
for (int i=0; i
>"\nText"
christ...
not helping.
Sorry I need help, not offering it
Please, explain what is going on there to a C brainlet.
Looking for project ideas Sup Forums, should I make a cryptocurrency cpu miner in C, or is the idea unfeasible?
Hacked on inferred, refined types.
Basically the equivalent to putting auto everywhere in sepples.
And he just keeps posting the same .gifs from the LH site so he's not actually doing anything of worth himself.
whats a linear type?
>cryptocurrency mining
>on the cpu
disposable variables.
one I'm having fun with is a tool to crack hand ciphers and attack hashes using wordlists
I want to mine shitcoins for FUN
Well okay but why write your own for one, and also use the GPU to mine crypto because it's much better at concurrent and repetitive calculations that are needed to efficiently mine them.
If you are wanting just to write a basic blockchain algorithm and test designing your own cryptocurrency then go for it but I still recommend learning GPU programming (and maybe ditch C at the very least for C++ to speed up productivity.)
But if it's all just for fun why don't you just give it a go and you'll learn all this on your own my faggot friend
This question is kinda throwing me a loop.
glm::vec4 pos2 = scale * vertex;
Vertex isn't defined anywhere. Is vertex a standard identity matrix or something?
The question is: what is the value of pos2?
Ban JavaScript, Python, Ruby, and Go.
+ Lisp & Java
c++ is the greatest language of all time
Sad but true.
the vertex shader should take as input (at minimum) a position and a normal vector. transform the position by the world/view/projection matrix/matrices, and transform the normal vector by just the world matrix (you want normals to be in world space for the fragment shader, not clip space). you'll also want an additional output representing the view/eye vector - the difference between the world space vertex position and world space camera position. propagate other vertex attributes like texture coordinates or vertex color if applicable
the fragment shader should have uniforms for ambient color (or color and intensity/scale value), with similar values for diffuse and specular color (and an additional scalar for specular "power"), for each light you want the shader to support, along with a direction vector for directional lights or a position vector and attenuation/distance values for point lights. if i remember correctly, phong shading is achieved by more or less:
AmbientColor
+
DiffuseColor * dot(NormalVector, -LightDirection)
+
SpecularColor * pow(dot(reflect(normalize(ViewVector), NormalVector), -LightDirection), SpecularPower)
this can be adapted for multiple lights by summing this process over different light directions and colors. you can also use the half-angle vector instead of reflection for a less accurate but generally acceptable and cheaper approximation. specular power affects how sharp specular highlights appear and how rapidly they attenuate; higher values will simulate surfaces that appear glossier, and lower values will appear rougher/more diffuse. in some cases you may need to clamp the dot product in the specular calculation to between 0 and 1, otherwise the exponentiation could negate negative values
Got it, C++ and GPU programming will do thank you faggo. Muah.
Assembly Language
Write a function called findLargest that receives two parameters: an unsigned doubleword array and the length of the array. The function must return the value of the largest array member in eax. Preserve all registers (except eax) that are modified by the function. Write a test program in main that calls findLargest three times, each call using a different array with different lengths.
Write a function called named countHits that takes as parameters two arrays of unsigned doublewords, and a third parameter that indicates the length of the two arrays (they are the same length). For each element in the first array, x(i), if the corresponding element in the second array, y(i) is equal, increment a count. After comparing the arrays, return a count of the number of matching array elements in registers eax. Write a test program in main that calls your function and passes the memory addresses of the arrays and the length of the arrays. Be sure to save and restore any registers, other than eax, that are changed by your procedure.
Write this program in NASM
If you can solve this I'll give you $50 in litecoin.
or you know, you could just figure it out yourself and put that college loan to use instead of scraping by.
>Write this program in NASM
ugggghhh
Do your homework you pleb.
why tf you in comp eng if you cant do your work
I try man, but I just suck at assembly with nasm the compiler on Unix sucks. Considering I use the gdb debugger.
Do what I do when I come across unfamilliar material, or the professor just plain sucks at teaching. Learn the specific architecture he's teaching you from 2-3 different sources. Exposure to different methods of teaching solidify information easier than just one source.
Why can't I decide on a fucking anime character and fap to it? I'll fapping to one make decent progress then get distracted because some other loli seems better
>finish BSc in compsci
>upload all my assignments and projects to Github
>end up with this breakdown
Is this normal? It seems fairly accurate but add like 10% to Java. It seemed like every fucking course had Java, and the only way out of this abysmal language were "choose your own language" assignments which came once or twice a year.
>css as a programming language
>less than 5% C
glad i never fell for """""""""""""""""""higher""""""""""""""""" learning
else if ((clock = 0000))
{
rate = dist*0.20;
}
What does it mean by this?
error: Error 1 error C2041: illegal digit '9' for base '8'.
post the line clock was defined on
//prototype
float Toll_Rate_3(int clock, float dist);
//....
float Toll_Rate_3(int clock, float dist)
{
...
}
If you prefix a number with 0 it means octal, 0x means hexadecimal.
Either say 559 instead of 0599 or explain what you want to do.
to calculate rate based on different time of the day.
But why prefix 559 with a zero?
I guess you are right. 559 instead of 0559.
>my first impression was 0559 => 05:59 AM.
I am silly
don't represent a wall clock time as an integer. at the very least, split it in to hours and minutes:
typedef struct {
unsigned int hour;
unsigned int minute;
} clock;
>can't use -> to access operators in C++
Every day I discover something I hate about this language.
Using code extracts or pseudo code, describe a recursive L-system
algorithm that implements an L-system with input parameters specifying the
L-system string and the recursion level.
How the fuck do I do this? I know the basis of L-Systems. Like F - One unit forward, +, -, [, ], etc. How do I answer this question though?
hmm. this is new.
If anyone interested looking at the question. This is not a request of doing it.
(a) Problem Statements
Write a C program to develop a Toll Collection System that mainly calculates the daily collection of a tolled highway in City A. You are free to design input, interface or any related components that you think are necessary to be included in your system.
(b) Project Requirements
Your system needs to calculate and print out payment receipts for every customer’s vehicle and a summary of monthly report. The toll rates are charged as follows:
>pic related
Create a program to perform the following tasks:
i. Use your creativity to design the user interface for the System menu (Eg: Pay Toll, Delete
Payment Receipt, View Receipts, Monthly Summary Report and quit);
ii. Calculate the payment for daily and monthly collections;
iii. View a receipt for particular vehicle number (Display on screen);
iv. All collections must be saved (append) in a text file (tollcollect.txt) by dates.
v. Your program must be able to calculate and print the summary of monthly collections report
based on vehicle types.
(just satisfy the minimum requirements, no fancy things)
is it supposed to be generic? does the string input describe the L system or do you pick an L system and just use that as the seed?
Generic.
That's the entirety of the question. It's 7 marks. Doing a past paper for an exam I've got coming up.
It doesn't seem like it's generic.
It could be, and if it is you'd say something like
>extract the production rules into a list using bla bla
>extract the initial state param ...
>set the initial state param ...
>for i = 1 to recursion level
>for each char in string
>if it's in production rules, replace it with its substitution
>1. Extract the production rules into a list using
Using what? Heck.
why would you? just use the operator
what do you mean using what, just like having
A -> ABCD;
so
split at ;
pseudo-regex "[a-Z] -> [a-Z]+"
>can't use -> to access operators in C++
1) you literally can: ptr->operator+=(foo)
2) you can also just dereference the pointer(s): *ptr += foo
Ah, gotcha. I figured it was a technique I didn't know or something. Thank you!
are you sure it's supposed to receive the rules as a string?
There's honestly no information that says otherwise. The Koch Curve example includes it as a string for example.
>ptr->operator+=(foo)
>the absolute state of sepples
Anyway, what I wanted to do was ptr->[key] but I might as well just do (*ptr)[key] since ptr->operator[](key) is even more disgusting.
I found this paper that describes how many lines of code it took to formally check various real-world libraries with liquid Haskell:
goto.ucsd.edu
Apparently, the average was roughly two lines of specs/annotations per ten lines of code. Some bugs in the libraries were found and corrected.
So Brigade 2 was open source at one point. Then they sold to OTOY and it's officially gone now.
But since it's out there I'm wondering if anyone has it and is willing to share?
For educational purposes of course.
Open up the Intel x86 developer's guide if you want a full lesson.
Otherwise try disassembling code to see how it works.