[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 111 KB, 600x800, 1502554078961.png [View same] [iqdb] [saucenao] [google] [report]
61875133 No.61875133 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous thread: >>61868339

>> No.61875159

Anyone built something with Haskell, if so what was it?

>> No.61875169

I think Idris was made in Haskell

>> No.61875185

Nothing practical has ever been nade in Haskell. Only academic circlejerk projects.

>> No.61875195
File: 44 KB, 636x616, 1474325315193.jpg [View same] [iqdb] [saucenao] [google] [report]

Employed Haskell programmer reporting in

>> No.61875210

So, how are you finding the latest JS framework?

>> No.61875270

stop using that image
you're scaring the children

>> No.61875286
File: 139 KB, 470x545, dlang_chan.jpg [View same] [iqdb] [saucenao] [google] [report]

Germany loves dlang-chan!

>> No.61875287

splitvalue = *(&(&tp->v0 + tv)->x + axis);

Is this acceptable to you?

>> No.61875293

Variety is the spice of life, OP. You, on the other hand, are Miracle Whip spread on Wonder Bread.

>> No.61875316


>> No.61875419

What do you do?

>> No.61875520
File: 358 KB, 2238x1168, Screen Shot 2017-08-12 at 6.28.22 PM.png [View same] [iqdb] [saucenao] [google] [report]

Trying to wrap my head around how C handles headers.

Pic related is my setup for an implementation of linked lists. However, when I try printing the value of "p->Next", I get the following error (gcc)
Test_Poly.c:12:41: error: incomplete definition of type 'struct Node'
printf("Address of p->next: %d\n", p->Next);
./Polynomial_List.h:3:8: note: forward declaration of 'struct Node'
struct Node;

Why is this happening? Don't I include the header file, which specifies how Node should be built?
Using the following gcc command to compile:
gcc Polynomial_List.c Test_Poly.c

>> No.61875596

either say
export struct node;
in the header
or just define it in header fully

i think that would work

>> No.61875619

Can you please show the filenames of all the files you included

The top right header file just declares the existance of the struct Node, but doesn't declare what fields it has. The bottom right header file declares what fields it has.
In order to use fields such as ->Next, you need to include the bottom right file, and in order to use those functions you need to include the top right file.

>> No.61875656

nigga the file on the left includes the header
and he compiles both of the .cpp files
use your eyes

>> No.61875675

Okay so the bottom right file is a .c file but that's wrong, it needs to be a header file that the left file includes.

The key takeaway here is that compiling multiple C files at once is the same as compiling them seperately. So if you were to just say
gcc Test_Poly.c -c
then it has no way of knowing what ->Next is. So you need to tell it that information by declaring it in a header

>> No.61875728
File: 552 KB, 2612x1420, Screen Shot 2017-08-12 at 6.44.41 PM.png [View same] [iqdb] [saucenao] [google] [report]

Yeah sorry.

Left file is "Test_Poly.c"
Top right is the header file Polynomial_List.h
Bottom right is the implementation file Polynomial_List.c

I'm thinking of ways I can include both the implementation and header files, but I'm worried that might lead to duplicate symbols and leading to compiler errors

Not sure if this helps, but when I
#include "Polynomial_List.c"

int the left file, I get linker errors (duplicate symbols errors for the functions defined)

>> No.61875756

>it needs to be a header file that the left file includes.
but that's wrong
you're getting duplicate symbol errors because the poly-lists header should have a
#define Polynomial_List_H
right after the #ifndef
right now that #ifndef never does anything

>> No.61875773

pretty sure you want to do something like this:


either define functions to return the inner values required or expose the struct definition in the header file

>> No.61875778

Don't include the header. There's no reason to have a header file anon. This isn't sepples. You only need header files when you are thinking about an interface and then you'll link against the .o file not the .c file.

>> No.61875799

Functions get compiled into assembly code, and if the same function gets compiled twice (which is what happens when you #include the .c file) then you get a linker error.

However, struct declarations are not compiled into anything. As long as each c file sees the same definition of a struct, you're good to go.

// a.c
void foo() {}

// b.c
void foo() { printf("yikes"); }


// a.c
struct thing {
int x;

void foo(struct thing) { printf("x = %d\n", thing.x); }

// b.c
struct thing {
int x;

void foo(struct thing); // note: this is a DECLARATION not an IMPLEMENTATION

void bar() {
struct thing;
thing.x = 4;

result: x = 4 (GOOD)

// a.c
struct thing {
int x;

// b.c
struct thing {
double y;

result: this compiles, but is undefined behavior since a.c and b.c see different versions of struct thing. never do this.

>> No.61875843
File: 786 KB, 2954x1522, Screen Shot 2017-08-12 at 6.53.25 PM.png [View same] [iqdb] [saucenao] [google] [report]

Alright... I should have seen that coming, but unfortunately I don't think that did anything (see pic related)

I want to include header files because it makes it easier to organize imo.

>As long as each c file sees the same definition of a struct, you're good to go
But don't I do this? I have a declaration of a struct, and define it in an implementation file.

>> No.61875866

Each C file needs to see the definition of a struct. The only way it can "see" it is by having it be inserted into the file.

// a.c
struct thing { int x; }

// b.c
// note: does not #include anything
void foo() {
struct thing t.
printf("%d\n", t.x);

$ gcc a.c b.c
ERROR: b.c doesn't "see" the definition of the struct, so it doesn't know that the field .x exists

>> No.61875869

xmonad was built in haskell
it was heavily used in the corporate world as a fast, safe language before java and C++ came into the picture.

>> No.61875876

>But don't I do this?
i think the test-poly still sees the undefined struct, might be wrong

you should really be defining structs in the header, not in the .c file

>> No.61875893


>> No.61875917

Not the same anon but you just need to put the struct definition in the header, basically instead of this:

struct Node;

Put this:

struct Node
int Coefficient;
int Exponent;
struct Node* Next;

And then get rid of the definition in the .c

>> No.61875926

The header defines a function the name of which should point somewhere. That somewhere would be a library file linked to your program.

Basically the header file does nothing but to announce the existence of the function, alone it's worthless. The library/binary file the function is in (if it's not called from the file itself) defines what the function is.

So for example #include <stdio.h> will bring in symbols from stdio, therefore tell (promise to) your program that the function printf (and every other in stdio) exists. Doing -lc when compiling (often done by default by your compiler) will have the program call the libc library in which it will find the actual printf function.

>> No.61875929

Netbeans-Cpp IDE is pretty comfy.

>> No.61875952

>Pure and innocent window manager written in 1.2 kLOC.
>Built on top of the heaping garbage fire known as X11.
It hurts.

>> No.61875953
File: 709 KB, 2788x1498, Screen Shot 2017-08-12 at 7.05.11 PM.png [View same] [iqdb] [saucenao] [google] [report]

I moved the definition of Node to the header file... Never thought I'd be so happy to get a seg fault!

Many thanks to everyone!

>> No.61875980

any day lad

>> No.61875984

what in the world are you editing text with? This looks like software from the 90's that was ported to cocoa, and it looks even worse than acme.

>> No.61876012

Emacs... So exactly what what you described.

On an unrelated note, anyone know why the value of p-> Next changes between a function call?

void Initialize(Polynomial p)
p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);


int main()
Polynomial p;

printf("Address of p: %d\n", p);
printf("Address of p->Next: %d\n", p->Next);

And output is below:
Printing P->NEXT: 0 /* In function Initialize(p) */

/* In main */
Address of p: 136380470
Address of p->Next: -1991765899

>> No.61876013

looks like some type of vim application

>> No.61876043

functions only change the inputted values locally
if you want to change p's value use a pointer
pass the function &p and use it in the function as p*

>> No.61876049

Rate my 7th C++ program
#include <iostream>
#include <string>
using namespace std;

enum class monster_t {

struct monster_detail {
string name;
int health;

struct monster {
monster_t type;
monster_detail detail;

string get_type_string(monster_t m)
switch (m) {
case monster_t::dragon: return "dragon";
case monster_t::giant_spider: return "Giant spider";
case monster_t::ogre: return "ogre";
case monster_t::orc: return "orc";
case monster_t::slime: return "slime";

void print_monster(monster m)
cout << "This "
<< get_type_string(m.type)
<< " is named "
<< m.detail.name
<< " and has health value: "
<< m.detail.health << endl;

int main()
monster T{
{"Torg", 120}};
return 0;

>> No.61876055

nice to hear

>> No.61876076

are you going through a game development book?

>> No.61876079

You have no taste anon. Code like that is the only reason I still bother with this crap.

>> No.61876087

Nope, it's http://www.learncpp.com/
Pretty nice resource if you ask me

>> No.61876088

Oh duh...

I guess I just forgot about this because I was working with pointers and assumed I could change values will-nilly

My only concern is that it's not very prone to being expandable (what if you had 100 monster types? A gargantuan switch/case statement isn't exactly something you would want to type out)

I recommend having an array of structs and a file for monster names... But not really into game development (yet) so take my concern with a grain of salt

>> No.61876090

all pretty silly
it would be smarter to have a map that maps strings of monster names -> structs of monster stats

>> No.61876139

>not creating a pure Linux opengl es context by using generic buffer manager and kernel mode setting
>not creating your own hardware accelerated graphics
>not grabbing input directly from evdev

>> No.61876142

i'm not a game dev but to me it seems like it'd be better organized if you make a class for every monster than inherits from the monster class. also, if you're not trying to do OOP stuff don't try to learn cpp

>> No.61876172

This kind of shit is why I'm not productive in Linux. I end up fucking with the env endlessly instead of working.

>> No.61876177

We need a pastebin.

>> No.61876181

found an old fizzbuzz i wrote a few years ago. what was i thinking

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define Oo 100ULL
#define __(oo,oO)\
for (o=(Oo*(oo)>>(oO));o<=Oo;o+=(Oo*(oo)>>(oO)))OO ++[O]

int _o(const void *o, const void *O) { return
((*(uint64_t*)o) >> 48) > (uint64_t)(*((char*)O + 6)) ;}

int main(void)
uint64_t oo, oO, o, O [Oo * 0x1bbbbbbbd4 >> 36], OO = 0;

__(0x3e0f83e1ull, 35) = (o << 060) | 2054842694;
__(0xcccccccdull, 36) = 0x7a7a7542 | (o << 48);
__(0xa57eb503ull, 38) = (uint64_t)0xff << 36 | (o << 0x30)
| ((o + 0x30 - 10 * (o * 205 >> 11)) << 010)
| (((0x1999999a * o >> 32) + 0x30)); qsort(

O, OO, sizeof(0[O]), _o);
for (o =0;o <OO;o ++) {
oO= o[O] >> 060; oo =o;
while (!(oO^ (o [O]>>48)) && (o [O]&16711680))
printf("%s", (char*)&o ++[O]);
printf(!(o ^oo) ? "%s\n" : "\n", (char*)&o [O]);
} return


>> No.61876217

What should be on it?

>> No.61876224

But that's the purpose of Linux, of programming. Making programs for other people is for idiots. Do it for yourself

>> No.61876258
File: 1.82 MB, 1920x1080, terrain.png [View same] [iqdb] [saucenao] [google] [report]



>> No.61876352

If you're dispatching on type (in your case the big switch statement) you should consider a polymorphic approach instead.

>> No.61876354

Nigga I'm lazy. I have work to do unrelated to my environment, and I generally would like to get that work done. The problem with Linux is sharpening that particular axe is alluringly straightforward, so if I don't check myself I end up grinding metal for hours instead of just chopping the fucking tree down. As weird as it sounds, knowing nothing about how the dev tools I'm using work under the hood leads to far greater productivity for me.

>Making programs for other people is for idiots.
That's pretentious as fuck. I write code for people who can't, but will pay me for my efforts. In turn I pay contractors, attourneys, doctors, etc. for services I need but don't have the time to become an expert on. Eventually you'll need to pay for someone to do something you can't. That doesn't make then superior to you, and you knowing how a computer works doesn't make you superior to others.

>> No.61876365

If you don't want to define Node in the header, you could also have used a function (inside the header) that took a struct Node pointer and returned the next of it. That's why the error existed. The struct definition was hidden inside the implementation, so the compiler doesn't know how to dereference it in main.

>> No.61876375


>> No.61876380
File: 479 KB, 800x600, terrain.png [View same] [iqdb] [saucenao] [google] [report]

Innovation! This new version allows the dividing planes to not be positioned perfectly at the center of the sphere. This means that elevation changes won't be forced into symmetry at antipodes.

>> No.61876395
File: 1.19 MB, 1127x1600, trap-programming.png [View same] [iqdb] [saucenao] [google] [report]

Next time you're having problems, try wearing some thigh-highs and girl clothes. They always help me solves any issues in my programs.

>> No.61876465

RTFM and Google for Retards

>> No.61876472


>> No.61876489
File: 999 KB, 1920x1080, terrain.png [View same] [iqdb] [saucenao] [google] [report]

1920x1080, fewer slices

Magenta: Z < -2
Blue: -2 < Z < -1
Cyan: -1 < Z < 0
Green: 0 < Z < 1
Yellow: 1 < Z < 2
Red: 2 < Z

>> No.61876504
File: 971 KB, 1920x1080, elevation.png [View same] [iqdb] [saucenao] [google] [report]

Where Z = (pixel's elevation minus mean elevation of all pixels) / standard deviation of all pixels' elevations, of course.

>> No.61876508

These are correct responses

This is not

this guy is just being edgy

There are good arguments to me made against OOP but "lol inheritance" is not one of them.

>> No.61876541

EVERYTHING in C is PASS-BY-VALUE. Which is why you pass pointers to stuff to save your results outside a function. You pass-by-value a pointer so that when you dereference it the memory pointed at is the same.

Polynomial Initialize()
Polynomial p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);
return p;

void Initialize(Polynomial *x)
Polynomial p = (struct Node*) malloc( sizeof(struct Node));
p->Next = NULL;
printf("Printing P->NEXT: %d \n", p->Next);
*x = p;

>> No.61876548

Isn't multiple inheritance the feature that's looked upon with disdain? And if I recall correctly, C++ is the only major OOP player that supports it.

>> No.61876568

Inheritance in general is viewed in a far more negative light than it used to be.

Extending functionality in a way that doesn't require dynamic dispatch is done with mixins or composition.

Dynamic dispatch is the only reason to model with inheritance, and it's not a very good one with today's languages.

>> No.61876628
File: 36 KB, 1116x244, Screen Shot 2017-08-12 at 8.08.06 PM.png [View same] [iqdb] [saucenao] [google] [report]

Thanks!! I kind of completely forgot about pass by value (because I'm kind of used to pass-by-reference in sepples)

Everything works now! I even made an addition function!

>> No.61876667

is there like a cheatsheet for common/useful methods/imports (in java)?

ive done c++/c# for a few years now as its the standard at my school and while learning java im having trouble thinking of the useful methods i could use instead of doing everything manually.

stuff like string.replace() is super basic but i was doing that shit manually with loops for too long before realizing it was a thing.

>> No.61876670
File: 3.23 MB, 3840x2160, terrain indexed.png [View same] [iqdb] [saucenao] [google] [report]

Simple worldbuilding...
>Magenta/blue/cyan: Ocean
>Green: Continental shelf
>Yellow: Habitable land
>Red: Uninhabitable mountains/plateaus

In this 4k image, we have one big continent, composed of a big landmass, a small landmass, and a bunch of smaller islands. The continent technically extends underneath the northern ice cap, and there are a few undiscovered islands (yellow dots in the upper-left area of this picture), since the people living on the bigger landmasses haven't yet invented ocean travel.

>> No.61876682

A lot of people criticize multiple inheritance, whether or not that's fair is up for debate. Python also supports multiple inheritance. Java classes may implement multiple interfaces which is sorta like multiple inheritance.

But what we're talking about here is _not_ multiple inheritance. Multiple inheritance is when one class can have multiple parent classes. In this situation we're talking about one parent having many subclasses, which is considered perfectly fine among people who are into OOP.

There's a growing but still certainly minority opinion that inheritance in general is "bad". This is a position that's come out of seeing people abuse inheritance and a few vocal high-profile language designers advocate "composition over inheritance" which is not a blanket dismissal of inheritance but a statement that inheritance is not the solution to every situation where you want to reuse code.

>> No.61876698

Usually when I'm using a language I'm not sure familiar with, I scoure the documentation for something I want and if I don't find it very quickly I'll write it myself.

>> No.61876739

The java documentation is absolutely fucking garbage because you have to go to the parents of the parent of the grandparents to see wherever the fuck a method exists and its signature. Just google shit and you more likely than not find a solution with an example on stack overflow from people tired of the same garbage.

>> No.61876752

This is one reason why I love Racket, it has absolutely excellent documentation that makes it very easy to find out how something is supposed to be used and find related functions for the same kind of data.

>> No.61876762

multiple inheritance is if you had "Slime" inherit from "Monter" and also from "DungeonCritter". what i described isn't multiple inheritance

>> No.61876771

If I had to devote my energy to learning a language that will get me employed between clojure and Haskell, what do you recommend?

>> No.61876776

redpill me on rust /g/

>> No.61876783

Clojure will get you employed. As a Haskell lover who doesn't really have any interest in Clojure I still acknowledge that it has more applications in webdev jobs and the such

>> No.61876789

if you only know clojure and haskell it seems you're oriented towards app development, so java

>> No.61876799

Yes, I know. Jesus christ. The implication of my question was to clarify whether or not the anon who laughed at inheritance was referring to single or multiple variety. Please read more carefully before replying.

>> No.61876818

Rust is a meme. Improve yourself at C. Unless you want to waste time fighting the borrow and the lifetime checker and putting "unsafe" before writing C.

>> No.61876846

I've been using rust for a few days now and I only ever fought the borrow checker once; it seems more than obvious how it works, does it not?

>> No.61876863

Not for C weenies

>> No.61876894

I should also mention that it's very difficult to write C that does lots of buffer manipulation, whereas writing Rust that does so is trivial. So much so that it's easier to write Rust that does the heavy lifting and export unsafe C bindings.

>> No.61876897

It is. That's how you write C that doesn't segfault. No training wheels required.

>> No.61876910

Rust is fine for its purposes. I still use C heavily but that is mainly when doing embedded and other no-allocation based stuff.

I've written >10K+ lines of rust and haven't needed to use unsafe once at all. The borrow checker and all that isn't too big a deal I don't think, and I'd just advise people to make unnecessary clones when they start of to ease in to it.

The big boon to productivity for me is that it prioritizes performance in a way which I won't be stuck at some point in the future at some wall where I may otherwise be with something like python. That and the fact that libraries and the like are so much easier to use which makes it much easier for less low-level things like api-servers and the like.

There are some things I don't really like using it for but in general, it makes you feel confident in the small details and lets you focus on the actual program logic.

>> No.61876912

If Rust was just C with a borrow checker, I wouldn't use it.
If Rust was C++ with a borrow checker, I still wouldn't use it.

>> No.61876915

C# is such an incredible language with an incredible IDE Loving it so far.

>> No.61876955

I've found it most comfortable to use a hybrid approach: Rust staticlib for high level code, compiled together with C to start and do certain syscalls

>> No.61876957

>The java documentation is absolutely fucking garbage because you have to go to the parents of the parent of the grandparents to see wherever the fuck a method exists and its signature
Inherited methods are listed on every doc page, is clicking one link really that hard for you?

>> No.61876972

How the fuck does

> Isn't multiple inheritance the feature that's looked upon with disdain? And if I recall correctly, C++ is the only major OOP player that supports it.


> clarify whether or not the anon who laughed at inheritance was referring to single or multiple variety

you illiterate shit?

>> No.61876987

he probably just learned what multiple inheritance is recently and wanted to use it in conversation. be easy on him

>> No.61877077

Because it's written according to the rules of the English language, and if you knew English you'd be able to correctly comprehend its meaning. As such, calling me an "illiterate shit" shows me the dire severity of your ignorance. Are you an ESL pleb?

>> No.61877208

Wrong, here's a list of the things >>61876548 implies:
- You're unsure of how multiple inheritance is viewed
- As far as you know C++ is "only major OOP player that supports it" (which is wrong)
- You're asking for clarification on how multiple inheritance is viewed

Nothing in that post implies it was a question directed at >>61876375 , nor is there any mention of single inheritance.

Points though, for calling me an ESL pleb when you can't figure out what your own post means

>> No.61877278

how do I make my own proglang

>> No.61877376

assuming proglang is short for programming language
write a parser + compiler/interpreter

that's it
implementing a basic scheme implementation for example is easy as fuck
all you really need are:

and a few other things I'm forgetting
most of the other scheme functions can be defined in terms of the above
+ is just repeated inc
* is just repeated +
let is just a lambda

>> No.61877413

how do I write a Lisp sexp parser?

>> No.61877435
File: 145 KB, 800x533, t3_6diw4m.png [View same] [iqdb] [saucenao] [google] [report]

working on banging ur mom lol

>> No.61877468

I've just learned that I can put a static array inside a struct, so I can copy the entire array with only one assignment.
Pretty cool trick!

>> No.61877470

I'm not going to spoonfeed you
go see how others do it
go look into parsing in general
google it for fucks sake

you'll learn nothing if I tell you everything

>> No.61877490

It is nice that whoever made this image thinks "backend" and "web development" are two different categories and that "backend" belongs with "scripting".

>> No.61877501

in what case would this be helpful?
if you're passing to a function you're already copying, that's just how functions work
if you're not passing to a function and you're just working with it, why copy it
what use cases does this help exactly?

>> No.61877506

Wrote dependency resolution algorithm using preorders. The time complexity is probably terrible but it works well (and in this case n is usually small)
It's fairly elegant

;; evaluate a preorder using reflexivity + transitivity
(define (dep<=? p1 p2) (dep>=? p2 p1))
(define (dep>=? p1 p2)
(or (equal? p1 p2)
(ormap (λ (p1-) (dep>=? p1- p2))
(hash-ref preorders p1 null))))

;; sort paths by preorder and return corresponding asts
(map cdr (sort asts dep<=? #:key car))

>> No.61877519

the entire thing was made ~4 threads back for the sole purpose of pissing people off

the guy that made it used it as the OP image for the last 3 threads

>> No.61877544


The only reason people have deviated from the old yuki image was pissing people off. I still remember the dpt image wars

>> No.61877598

arrays aren't copied when passed to functions

>> No.61877603

Literally the easiest parser there is. Start with an empty list and read each symbol.

Open paren -> create new list, append to parent, this is now the current list
Close paren -> append the current list to the parent list. Parent list is now the current list
any other symbol -> append it to the current list

Fun fact: for reasons of tradition lisp parsers are generally called "readers"

>> No.61877637

Seems wierd unless you knew what the largest such array could ever be or every such array had the same number of elements.

>> No.61877646

Should I proceed with CS degree or math degree if I want to work in crypto?

>> No.61877654

do you know of a lisp reader example written in C?

I've created s-exp readers in dynamic languages before but it's much, much easier there due to the ease of string manipulation

>> No.61877671

Do both. You'd probably have enough paper overlap that there is not much extra work at all. Are the departments separate where you are studying?

>> No.61877686

then why does this work?
#include <iostream>
using namespace std;

void prtarr (int v[10]) {
for (int i = 0; i < 10; i++) {
cout << v[i];

int main () {
int b[10];
for (int i = 0; i < 10; i++) {
b[i] = i;
prtarr (b);
return 0;

>> No.61877723

That declaration is deceptive and v decays to an int pointer.


If you want to enforce the size of the input array you can do something like this (in C99), but it still decays to a pointer to something like `sizeof(v)` will be the size of an int pointer so be wary.

void prtarr (int v[static 10]) {
for (int i = 0; i < 10; i++) {
cout << v[i];

This will give an error if an array which cannot be determined at compile-time to contain 10 elements is passed. More elements is still fine so its not exact.

>> No.61877735

didn't notice you were using C++. Look at http://en.cppreference.com/w/cpp/container/array

>> No.61877746

Yes. Math crypto course is 3rd year and CS security is also 3rd year, both with long prerequisites.

>> No.61877767

ah, I see. the compiler does shit to try to help you, but in your use case it just gets in the way. yeah?

>> No.61877778

There are plenty of examples, I know the steel Bank CL interpreter is written in C but it's full featured, there's a lot of code there, you'll have to do some digging (which is not a bad thing, great way to learn, just work).

Are there any issues with string manipulation you're having in particular? It's definitely a lot more ceremony to mess around with strings in C but it's not fundamentally different.

>> No.61877781

Clojure is amazing!

>> No.61877808
File: 20 KB, 332x304, 5819995642.jpg [View same] [iqdb] [saucenao] [google] [report]

Do you fags write actual useful programs or just meme sample code to show off here?

>> No.61877818
File: 316 KB, 500x556, 1497484828388.png [View same] [iqdb] [saucenao] [google] [report]

quick, post a fizzbuzz using 5 stars and a cyclic linked lists written in ANSI C

>> No.61877838

>Fixed-length arrays must have their size determined at compile time.

so why I can do this?

#include <stdlib.h>
#include <stdio.h>

int main(){
int size;
scanf("%d", &size);
int array[size];

for(int i = 0; i < size; i++){
array[i] = i;
for(int i = 0; i < size; i++){
printf("%d\n", array[i]);

return 0;

>> No.61877839

in a dynamic language, my usual parsing routine would consist of reading a big string from file, splitting it on space, using a regular language to classify the tokens, and then running a parsing algorithm on the token list, either a custom recursive descent parser, a generated one or an Earley with a custom grammar fed to it

It's been so long since I used C I don't even know how to load data from files anymore, so I just hardcoded a simple Lisp program in the source code. I don't know how to split this shit either, I don't have regular language support either... I'm basically fucked

>> No.61877849

>scanf("%d", &size);
> int array[size];

>> No.61877861


>> No.61877862

yes, why can I do it

>> No.61877871

I mostly keep busy with my CS assignments and programming book exercises
once i git gud at C, scheme, and the SDL library I'll start work towards my first personal project tho

>> No.61877873

Do you know what the user will type in during compile time?

>> No.61877879

I can't find a single C file in SBCL's repository

>> No.61877881

Clojure us amazing!

>> No.61877882

I generally just write programs to fulfil my needs as I go. The last programs I wrote recently were one to search a list of directories for duplicate files and offer an option to delete either of them in a way that's fully scriptable and isn't slow as hell, and one to delete files/directories without regard for NTFS file permissions/attributes because I don't like being told I'm not allowed to delete files on my own computer.

>> No.61877887
File: 75 KB, 844x1440, su___garnet_by_shyrstyne-d8rye7e.png [View same] [iqdb] [saucenao] [google] [report]

ruby vs python vs perl

which should i learn to replace bash shell scripting for more power?

>> No.61877923

Ruby is great for Unix scripting, it's essentially a better perl. Has less libraries though.

Python has a shit ton of useful libraries of greatly varying quality from 10/10 to utter crap.

Perl is write-only programming language and is essentially Unix duct tape. A lot of libraries as well, but it's losing momentum compared to Python and even systems like Node.

>> No.61877950

What did you use to find the duplicates, MD5?
I remember trying to do that years ago, but it was slow a fuck.

>> No.61877960

I've never heard people talking about that before. I guess it is because it is not an ansi c thing

>> No.61877964

That's still pretty much the process. You know each step, you can look up how to do them.

Splitting strings means walking through the string, keep an index at where you start, advance until you find the next token you want to split on, copy between the current location and the previous index into the output list, and advance both indices to the same place. It's annoying if you're used to more robust string operations being part of the language but it's nothing to get intimidated by.

For token classification you can use a regex library or it's simple enough that you can do it yourself, you only need to recognize quotes, numerics, and parens to get something off the ground.

It'll be a lot of wrestling with C but it's the best way to learn.

>> No.61877981


>> No.61878000

its part of C99 and optional in C11

it's not really used since unbounded stack storage isn't usually a great idea

>> No.61878103

do you happen to know if C Programming: A Modern Approach talk about this kind of thing? I was looking for a book to get to know more about how C works and I feel like I'll be missing some features if I get C Programming Language

>> No.61878104

I use them quite often. They shouldn't be used for unbounded and untrustworthy input, though.
There are many situations where you can reason about the max length of the array and safely use them, giving you much more performant code.

>> No.61878152

Yeah, it seems fast enough. I can search 280MiB across 1,958 files and 264 directories in ~1.5s. The hashing itself is about 300-400MiB/s. I experimented with some other hashing functions but couldn't get a significant speed increase and MD5 is simple enough for me to write my own implementation for, which probably helps with any licensing issues if I were to ever release the program as well as just the fact that it feels nice to write everything yourself.

>> No.61878246
File: 6 KB, 240x184, lol.png [View same] [iqdb] [saucenao] [google] [report]


Use CRC32. If it detects duplicates, use SHA1 or MD5 on the duplicates to re-confirm.

Ya dig?

>> No.61878292

I don't know how I managed to fuck up a simple program like that. It was taking 500 ms to compare two relativity small files.
Maybe I will give it a try again when I've got some time.

>> No.61878342


In C how do I get the program to read one character from standard input and discard any others that are entered? I'm trying to do a simple y/n loop to continue without it sperging out if you enter more than one incorrect entry at a time.

>> No.61878400

With modern CPUs (anything from the last 10 years) I imagine you're probably being bottlenecked by how fast you can read the data rather than the speed of the hash calculation, even on an SSD.

>> No.61878430

with a while loop

>> No.61878432

Read a whole line, ignore the rest of it and use the first character.

You have to consume the extra characters in order for them not to get fed into your next std input usage.

>> No.61878442

Or validate based on the whole line, your choice. But the point is you have to consume the other characters.

>> No.61878446


Aite I got it so getchar() then (ch=getchar()) != '\n'?

>> No.61878496

Yep, or you can use fgets to do it automatically. Keep in mind fgets puts the newline into your read string.

>> No.61878532
File: 52 KB, 280x438, 884142.gif [View same] [iqdb] [saucenao] [google] [report]


>> No.61878536
File: 1.10 MB, 1120x642, 000090-Essentials_ Brian Kernighan on Associative Arrays - Computerphile - YouTube.png [View same] [iqdb] [saucenao] [google] [report]

>brian kernighan is left handed

>> No.61878537

what are the most mystical, ethereal programming languages? scheme? haskell?

also, why does /dpt/ hate rust? it was the most loved language on stackoverflow


>> No.61878621

>because I'm kind of used to pass-by-reference in sepples
Sepples is no different, retard.

>> No.61878633

The best way to get better at C is to learn another language and then come back to C.

>> No.61878677

The average /wdg/ poster gets more stuff done than /dpt/ combined!

>> No.61878706


>> No.61878719

What's your solution?

>> No.61878722

why are programming books so expensive?

>> No.61878741


College textbooks.

>> No.61878750
File: 40 KB, 303x566, 478895.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.61878816

Stupid frogposter

>> No.61878835

There is literally nothing wrong with programming in Python and anyone who disagrees is a pseudo-intellectual.

>> No.61878879

>tfw right-handed brainlet

>> No.61878942

>abysmal performance in general
>no TCO
>can't use assignment inside expressions
>conditionals can't be used as lvalues
>no native ropes
>no native support for O(1) array slicing

>> No.61878952

>conditionals can't be used as lvalues
That's a good thing. Doing so results in poor, unclear code.

>> No.61878956

also, __dict__

>> No.61878961

I just learned that in C the assignment operetion returns a value so I can do

>> No.61878966

trying to learn c.

Can someone tell me what wrong with this, other than possible shit coding practices?
#include <stdio.h>
const int CONVERSION = 60;
const float DEC = .01;
int main(){
int begin_min, hour, ans_min, mod_min, temp;
char user_min[3];

printf("Enter mins: ");
fgets(user_min, sizeof(user_min), stdin);
sscanf(user_min, "%d", &begin_min);

hour = begin_min/CONVERSION;
mod_min = begin_min%CONVERSION;
temp = mod_min*.01;
ans_min = temp * CONVERSION;

printf(" Answer is %d hour and %d mins", hour, ans_min);

>> No.61878971

I would like a Big Mac, Pepsi and fries.

>> No.61879012

way to not respond to everything else I said. everyone who uses python does the exact same logic except uglier, setting the assigned expression outside an if and then using if statements for each one. because they have to, thanks to guido's enlightenment.

other problems include not knowing statically if basic property accesses have side effects, an issue shared with several other languages.

>> No.61879029


Increased your buffer size because its not like you are strapped for memory.
Your conversion also is wrong and you only need to take the mod_min as your seconds. I think the following is what you want.
Also, you want to specify main as taking a single void parameter. Not specifying any parameters in C actually means something different (okay in C++ though).

#include <stdio.h>

const int CONVERSION = 60;

int main(void) {
int begin_min, hour, mod_min;
char user_min[32];

printf("Enter mins: ");
fgets(user_min, sizeof(user_min), stdin);
sscanf(user_min, "%d", &begin_min);

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

hour = begin_min / CONVERSION;
mod_min = begin_min % CONVERSION;

printf(" Answer is %d hour and %d mins\n", hour, mod_min);
return 0;

>> No.61879053

that seems counter-intuitive

>> No.61879128

who the hell thought Hy was a good idea?

>> No.61879172

So was my issue (besides the incorrect conversion) was that the array was too small?

>> No.61879200

wowowow im retarded, i essentially tried to do what the modulas does already

>> No.61879211

I write a different FizzBuzz solution every week in Scheme.

>> No.61879234

nvm im triple retarded i haven't done remainders since elementary.

>> No.61879303

Continuing my quest through all the models in our simulation. Currently making sure our atmosphere model isn't retarded.

>> No.61879312

you too!?

>> No.61879315
File: 89 KB, 164x265, 000021-Twitch.png [View same] [iqdb] [saucenao] [google] [report]

(spoiler: it does)

>> No.61879375

Yes, wrote one using macros today.

>> No.61879554


>> No.61879571

i hate it when my model does retarded too

>> No.61879573


>> No.61879606

no hablo englando

>> No.61879689

Whatcha simulating?

>> No.61879767

Guided bombs. Most of the sim was developed by a bunch of GNC monkeys so we're having to go through and fix all the fuckery.

>> No.61879824
File: 61 KB, 535x577, sad_wojak.jpg [View same] [iqdb] [saucenao] [google] [report]

>ywn be left handed
Why is being left handed the master race?

>> No.61879827

what are classes used for in c++?

>> No.61879849

to encapsulate state and state change of a particular type of object

>> No.61879860

is this your first time programming?

>> No.61879874

job security

>> No.61879877


is writing classes as projects something great to do in order to learn programming? seems like a good first stop.

>> No.61879887

do basic procedural programming before you even think about OOP

>> No.61879921

This. Eventually you'll start writing things complex enough that classes and such become the natural next step. They're not really a good starting point.

>> No.61879938

Okay. Gonna write something and post it when I'm done to get a rating.

>> No.61879953

OOP in the modern context is a pretty tried-and-failed concept for the most part. It's only useful in huge companies where swaths of low-credential employees that don't collaborate efficiently need to be protected from one another.
Learn basic procedural programming first, maybe something like C or Python. Then some basic functional after that.

>> No.61879965

I have to make an algorithm that takes a dictionary.txt file with a list of words separated by new lines and find the anagram that occurs the most.

It has to be O(M N) complexity, so using radix sort with counting sort I can achieve this.

Could anyone help me with how they'd do it? I'm struggling to get a grasp on the logic behind it as a sorted list will put all anagrams next to each other but they won't have been counted...

>> No.61879970

oop being a data abstraction technique, it shouldn't come first

>> No.61879978
File: 40 KB, 400x400, fedora.jpg [View same] [iqdb] [saucenao] [google] [report]

Do you wear a fedora too?

>> No.61880028

#include <iostream>

using namespace std;

int addition(int a, int b);

int main()
int a, b, product;
cout << "Enter 2 integers" << endl;
cin >> a >> b;

product = addition(a, b);

cout << "product: " << product << endl;

return 0;

int addition(int a, int b) {
return a * b;

Am I ready yet or should I just continue with increasing complexity?

>> No.61880051

>int addition(int a, int b)
Also keep doing more, this is basic shit.

>> No.61880064

oops did it too fast i guess. and okay. what should I do?

>> No.61880093


Rough pseudo code for the idea. Use a dictionary with a default value of 0 (i.e. a defaultdict in python).

m = defaultdict()
max_entry = 0
max_word = ""

for word in words:
w = sorted(word)
m[w] += 1
if m[w] >= max_entry:
max_word = w

>> No.61880108

need to set max_entry along with max_word but i think you get the idea

>> No.61880110

Make a game of tic-tac-toe.

>> No.61880123

Can't use dictionary because it's worst-case retrieve and input is O(n) when every value is indexed at the same hash :(

>> No.61880125

/g/uys its raining im excited

>> No.61880136

>Trying to wrap my head around how C handles headers.
C handles headers (and all includes, the extension does not matter) by simple text concatenation. It simply adds the stuff from the included file right on the line it's included at. For instance, let's say we have two files, a.h and a.c:

/* a.h */

return 0;

/* a.c */

#include "a.h"

int main(int argc, char **argv)
return do_something();

If we compile an object file with "a.c" as the source, it will actually look like this after the preprocessing:

return 0;

int main(int argc, char **argv)
return do_something();

There's no magic there, just code being added to where ever you asked the compiler to add it.

>> No.61880155

This is the simple part, it becomes a headache when you start worrying about linkage.

>> No.61880163

What does ERROR_H *actually* define in a header file, like below?
#ifndef ERROR_H
#define ERROR_H
/* eprintf.h: error wrapper functions */
void eprintf(char *, ...);
char *estrdup(char *);
void *emalloc(size_t);
void * erealloc(void *, size_t);
void setprogname(char *);
char * progname(void);

>> No.61880177

how would i go about doing that?

>> No.61880181

It defines the symbol for the preprocessor with no value. Any substitution later will be empty but the only important thing for a header guard is that the symbol is defined.

>> No.61880186

That's an include guard. The value of the define doesn't matter, all that matters is that it is actually defined. If it is, then the ifndef directive will skip over the body of the header file and avoid duplicate-definition errors in case the header is included a second time.
It's a common pattern, sometimes the #pragma once directive is used instead though.

>> No.61880215

That's for you to find out. You know how to read text, you know how to print text and you should know some looping and conditional constructs. That's enough to implement the rules of a simple game like tic-tac-toe.

>> No.61880218

Only if you make it unnecessarily complicated by declaring everything in different files. Just remember that since its all simple string concatenation, you can include a file anywhere, not just at the top of the file (for example, after having defined your data structures).

Generally I think people have a tendency to keep their source files unnecessarily small and that leads to those headaches you're referring to, not to mention actual performance issues of not being able to inline some functions for instance, simply due to bad project structure.

>> No.61880234

a hashmap is amortized O(1), this doesn't matter and i don't think you should care about it, you can't do any better

>> No.61880303

/g/uys there is lightning now i dont know what to do

>> No.61880327

it's pretty dull sunny weather here, trade?

>> No.61880407

How come when I try to do an empty define in a function it prints an error?
#include <stdio.h>

#define HELLO

int main(int argc, char *argv[])
printf("%d\n", HELLO);
return 0;

>> No.61880420

After preprocessing, the file will look like this.
// other definitions from stdio.h.

int main(int argc, char *argv[])
printf("%d\n", );
return 0;

You can't have an empty argument like that.

>> No.61880424

I see. I agree that I'd like more of that. Perhaps not for a beginner book but it's certainly a very important step in learning software.
Find some open source Java project and look into it. Start with something small and gradually work up to enterprise Java.

>> No.61880442

no sorry i live in a desert this water needs to last us until winter its just very overwhelming sometimes

>> No.61880670

I'm trying to submit some java code to an online thing as homework, but the thing doesn't accept the format I give it, saying
***Runtime error***
Error: Could not find or load main class XXX

regardless of what I name the main class "XXX". Since I'm just entering the code from the .java file, I guess it doesn't know what the main class should be called. If I try just entering the code within the class then it tells me I've got invalid syntax, so I know I'm nearly there, it's just getting hung up on the class name. In this case, is there some simple workaround or default name for the main class I could try? I'm not expecting a thorough tutorial or anything, just for someone to clue me into something stupid that I've probably missed.

>> No.61880774

alright Cfags


how the FUCK is this macro counting the number of arguments and selecting the right syscallN function to call?

this is pure wizardry

>> No.61880778

So how do we fix some of the type declaration syntax in C?
Here are some changes I think would be good.
int[] arr; //instead of int arr[]
int[5] arr; //instead of int arr[5];
int* a, b, c; //a, b and c are of type int* instead of *a being of type int.
int a, b, *c //is a compile error now

int*()(int, void*)* fp; //Not really sure about this syntax

The only thing I don't really know a nice syntax for is function pointers without introducing a new keyword

>> No.61880791

>#define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
#define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0)
#define __syscall_cp2(n,a,b) (__syscall_cp)(n,__scc(a),__scc(b),0,0,0,0)
#define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),0,0,0)
#define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),0,0)
#define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),0)
#define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))

Ah yes, C is action.

>> No.61880793
File: 174 KB, 562x389, fragzeichen2.png [View same] [iqdb] [saucenao] [google] [report]

Is there a super-minimal, modular version of TeX that can be easily embedded with one's preferred packages?

I've made what I think is a really useful program for normies, but it's handicapped by the fact that it depends on an extant LaTeX installation. It'd be really nice if I could just distribute a standalone binary.

>> No.61880818

>Is there a super-minimal, modular version of TeX that can be easily embedded with one's preferred packages?
Yes. Read the pdf made by Donald. He explain everything.

>> No.61880821


I mean this:

#define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
#define __syscall_cp1(n,a) (__syscall_cp)(n,(long)(a),0,0,0,0,0)
#define __syscall_cp2(n,a,b) (__syscall_cp)(n,(long)(a),(long)(b),0,0,0,0)
#define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),0,0,0)
#define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),0,0)
#define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e),0)
#define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,(long)(a),(long)(b),(long)(c),(long)(d),(long)(e),(long)(f))

#define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
#define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))

how the hell does it count arguments

>> No.61880828

>So how do we fix some of the type declaration syntax in C?
C needs no fixing.

>> No.61880876

#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
#define __SYSCALL_CONCAT_X(a,b) a##b

It's a clever trick I have to admit.

>> No.61880889

I say we leave it as it is considering it makes complete sense.

>> No.61880926

This is wrong because int[3][6] foo; is indexed as foo[5][2];

Returning a function pointer is a nightmarish clusterfuck.

>> No.61880927

can you explain how it works

>> No.61880960

You didn't really offer any improvement for function pointers. In fact, I think you made it more ambiguous for more difficult function pointers.

Here's how I see it:
#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)

__SYSCALL_NARGS("hello") becomes __SYSCALL_NARGS_X("hello",7,6,5,4,3,2,1,0,)
and with named arguments: __SYSCALL_NARGS_X(a="hello",b=7,c=6,d=5,e=4,f=3,g=2,h=1,n=0,), so the result of this macro is 0 since n=0

__SYSCALL_NARGS("hello","world") becomes __SYSCALL_NARGS_X("hello","world",7,6,5,4,3,2,1,0,)
and with named arguments: __SYSCALL_NARGS_X(a="hello",b="world",c=7,d=6,e=5,f=4,g=3,h=2,n=1,...), so the result of this macro is 1 since n=1

That about sums it up.

>> No.61880984

At a guess I'd choose a style like int(int, int) fptr; to declare a function pointer but I'm not sure if that's any better. I haven't thought it through.

>> No.61881010

I think that with something like this you'll run into clearly ambiguous syntax with pointer to function that returns pointer to function that returns pointer to function.

>> No.61881072


int i;
char c;
short s;
double(int)(char)(short) fptr = getFptr();
double(char)(short) fptr2 = fptr(i);
double(short) fptr3 = fptr2(c);
double d = fptr3(s);

>> No.61881085

Now you're asking for way more than just a new syntax for function declaration.

>> No.61881103

And in addition to that, you haven't even demonstrated a function that returns a pointer to function. All your functions return double and you just used your new feature you came up with that creates a function that returns double from another function that returns double.

>> No.61881137

You misunderstand what I'm trying to express here.
a value of type double(int)(char)(short) is a function pointer that takes an int and returns a function pointer which takes a char and returns a function pointer which takes a short and returns a double. In other words:
int i;
char c;
short s;
double(int)(char)(short) fptr = getFptr();
double d = fptr(i)(c)(s);

This is all speculative shit I don't really know what I'm doing. I'm not the original person who complained about C declarator-style syntax.

>> No.61881146

>>61881085 >>61881103
not >>61881072
but like I said in >>61880778 function pointers are just hard to think up a new fitting syntax for.

>> No.61881174

Yeah, and my point is suggested "improvements" to C are not actually improvements at all, since what we have now makes no less sense than your suggestions.

>> No.61881195

>>61881137 is directed towards >>61881085 >>61881103

I dunno, it makes sense to me.

>> No.61881231

I know perfectly well what you're doing. You're suggesting the way Haskell handles function arguments. Calling a func(a,b) with just one argument creates a new function, func(b). There are plenty of reasons why this has no place in C, but that's not even the point. A function that returns pointer to the function is not what you are suggesting. A function that accepts 2 arguments can as a result of its execution return a pointer to a function that accepts 10 arguments.

>> No.61881300

I don't know Haskell and have only a vague idea of functional programming concepts. For me this is just a novice with a thought experiment.
>Calling a func(a,b) with just one argument creates a new function, func(b)
No, there isn't currying or partial application. A function call would be complete just like in C, void(int)(int) requires two distinct calls and void(int, int) requires one. Nothing changes but the syntax for types.

>> No.61881338

Came back from work a few moments ago. Rate my 9th C++ program.
#include <iostream>
#include <cstdlib>
using namespace std;

int generate_random_value()
return (rand() % 100) + 1;

int get_int()
int result;
cin >> result;
return result;

* Returns 1 if y, else 0
int get_yn()
char input;
cin >> input;
if (input == 'y' || input == 'Y') return 1;
else return 0;

void check_loop(const int determined_val)
cout << "Cheat: it's " << determined_val << endl;
cout << "Enter your guess [1-100]: " << endl;
while (true) {
int response = get_int();

if (response > determined_val) {
cout << "Too big!" << endl;
} else if (response < determined_val) {
cout << "Too small!" << endl;
} else if (response == determined_val) {
cout << "Correct!" << endl;
} else {
cout << "Error detected, exiting..." << endl;

int main()
cout << "Welcome to the number guessing game. " << endl;
while (true) {
int random_value = generate_random_value();
cout << "Do you wish to continue? [y/N] :";
if (get_yn() == 0) {
return 0;

>> No.61881363

All right, I did misunderstand then.

void(int,int,int,int,int,int,int,int,int,int)(int,int) func
would be a function that accepts 2 arguments and returns a pointer to a function that accepts 10 arguments (returning void). I'll think about it.

>> No.61881393

What is your current occupation?

>> No.61881401

employed haskell programmer

>> No.61881409

It's the other way around, actually. It accepts 10 arguments and returns a fptr that accepts 2 arguments.
int i;
void(int,int)(int) fptr;
fptr(i, i)(i);

I still think that specifying the types based on how you use them is a good idea. It talked about how it gets confusing with arrays here >>61880926 if you do it in a "dumb" way by just popping off the right hand side rather than making the declaration match the usage like in C.
You'd declare a pointer to int as *int ptr; to int* ptr; too.

>> No.61881421

I work as a bartender

>> No.61881462

be more consistent with bracketing

>> No.61881474

I thought I was following the K&R style...

>> No.61881512

you are. don't listen to that anon

>> No.61881532

not >>61881137 but I assume it works like:

double first(short, int) {
return 1.0;

double(short, int) second(char, int) {
return &first;

double(short, int)(char, int) third(short, char, int) {
return &second;

int main(int argc, char *argv[]) {
int i1, i2, i3;
char c1, c2;
short s1. s2;
double(short, int)(char, int)(short, char, int) fptr1 = &third;
double(short, int)(char, int) fptr2 = fptr1(s1, c1, i1);
double(short, int) fptr3 = fptr2(c2, i2);
double value = fptr3(s2, i3);
double value2 = fptr1(s1, c1, i1)(c2, i2)(s2, i3);

Your way makes zero sense.

>> No.61881559

I don't think you declare a function pointer like that.
A pointer to first would look like
double (*fptr)(short, int);

>> No.61881565

it's speculating about an alternative.

>> No.61881570

My bad.

>> No.61881574

Right. That way you declare the function and use it with same order, func(10 args)(2 args).

>> No.61881585

>still adamantly refusing to use decent syntax because it's from type theory and you hate academics

double -> (short, int)

(char, int) -> (double -> (short,int))

>> No.61881606


(short, int) -> double
i got confused because C function type syntax is backwards

>> No.61881625
File: 827 KB, 858x1200, 1502126194359.png [View same] [iqdb] [saucenao] [google] [report]

Here is my first line of code. What do you guys think?
#define female female(male)/* traps are not gay */

>> No.61881627

You got confused because you are generally just a confused person. My suggestion for you is to get your shit together.

>> No.61881637

No, I got confused because no sane person would want output(input)

>> No.61881643


That definitely looks like someone's first line of code.


>> No.61881654
File: 143 KB, 833x696, 1479883677181.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.61881657

At some point you have to stop being confused. You may think you have all the time in the world, but that's not actually the case.

>> No.61881696

What are you even talking about?

>> No.61881697

#lang racket/scribble

>> No.61881700

Take your time.

>> No.61881707

You have a really roundabout way of trying to pretend C has good syntax for function types

>> No.61881741

Those are levels of confusion that even I did not predict.

>anons are talking about a new syntax for C function pointer type declaration
>this means they must really think C has good syntax for function types

>> No.61881751

I know, and your proposed syntax is just as bad.

>> No.61881771

1. It's not mine.
2. You're still a very confused person, even more so after >>61881707.

>> No.61881779

You are just posting dribble.
It's you who's confused.

>> No.61881789

A perfect example of dribble is >>61881707.

>> No.61881899

I've only learned how to ""program"" recently. I made my own version of Conway's game of life yesterday.

>> No.61881900
File: 144 KB, 600x678, 1488475745114.jpg [View same] [iqdb] [saucenao] [google] [report]

Is there a way to get instant volume change notifications? I was thinking of setting inotify to watch whatever amixer writes to but it doesn't seem like it writes to a file. I'm probably going to end up writing to a file when I press the volume change keys and watching that instead but I would like a less hacky way if it's possible.

>> No.61881934
File: 26 KB, 842x647, cwgol.png [View same] [iqdb] [saucenao] [google] [report]

pic related

>> No.61881948

Looks like HTML+CSS+Javascript.

>> No.61881972
File: 5 KB, 429x410, 1275349948732.png [View same] [iqdb] [saucenao] [google] [report]

Ya got me. Hence the quotation marks.

>> No.61881990

Well, I got nothing against JS. Apart from few very silly quirks, it's a fine language, and HTML+CSS is a great tool for making UI.

>> No.61881996

undefined is not a fine language.

>> No.61882000

I haven't done C++ in a while but, for starters, you might want to replace that switch with an array of strings.
string get_type_string(monster_t m){
string[] name = {
"Giant spider",

return name[m];

Even then, you might want to take that list out of the function and have it be global or in its own header or something.

>> No.61882005

Are you ok?

>> No.61882046

Starting off my journey on Scala.

>> No.61882050

>one sperg's opinions
>"/dpt/ recommended"

Scheme is cool, but irdis and shen are fucking useless, and learning both is even more useless. Irdis is slow with a shitty syntax. Shen isn't all too bad, but it's not necessary when you can just use Scheme in it's place.

>> No.61882057

I implore you to watch this before making a big mistake.

>> No.61882112
File: 47 KB, 850x655, sudk.png [View same] [iqdb] [saucenao] [google] [report]

Also this, in similar fashion.

>> No.61882182
File: 17 KB, 486x899, comfy_merge.png [View same] [iqdb] [saucenao] [google] [report]

Is my merge sort implementation comfy?

>> No.61882199

It's not done yet btw, I still want to add function pointer and remove the initial value.

>> No.61882205

> software engineering, theory and practice, and will include some programming exercises.

How do I prepare for an interview containing questions about "software engineering theory and practice"?

Do they mean OOP?

>> No.61882206

please stop using pure colors, especially black on white.
Your eyes fatigue faster.

>> No.61882213

that's yellow

>> No.61882244

needs to be a little darker though.

>> No.61882245

Is this acme?

>> No.61882305


Dark themes are stupid.

>> No.61882352

It is sam.

>> No.61882424

bright themes are stupid.

>> No.61882470

No they aren't. The human system likes nature and nature is full of pale colors, so something you’re going to look at all day is best served if it were also in relaxing shades.

>> No.61882522
File: 399 KB, 762x990, bearsuit lain.png [View same] [iqdb] [saucenao] [google] [report]


>> No.61882544

This, but I resort to dark themes otherwise I cannot read yellow/red text.

>> No.61882565

lain is cute
i love lain

>> No.61882568

>nature is full of pale colors
Nature is also full of dark and saturated colors, as well as J-Pop bright and bold colors.
Whats your point?

>> No.61882577
File: 312 KB, 480x360, suicide.gif [View same] [iqdb] [saucenao] [google] [report]

>ynw have lain as a gf

>> No.61882588

>wanting a spaced & depressed gf
no you dont lad, trust me.

>> No.61882594

How many of you are actual pajeets?

>> No.61882595

w-what is she doing to that gun

>> No.61882599

text colors are harder to distinguish with a bright color scheme than with a dark one, making working with it more straining. furthermore, small characters or marks like dots are more difficult to perceive when blurred (through e.g. poor eyesight) on a bright background compared to a dark one.

>> No.61882609


>> No.61883020

>I'm a big boy who doesn't need syntax highlighting

>> No.61883047

>I'm a big boy who refuses to take off his training wheels

>> No.61883058

>making shitty analogies

>> No.61883059

>I'm a big boy because I refuse to use anything useful that helps me

>> No.61883066

I have no hands. Can I still be a programmer?

>> No.61883082

2 foot pedals are enough for machine code

>> No.61883083

Doesn't constitute arguments. Stay triggered kids

>> No.61883100

>My posts contain arguments but yours don't because I'm a big boy and you're not

>> No.61883121

Ask your mom to put a diaper on your head, shit-for-brains.

>> No.61883140

Nice argument, big boi

>> No.61883155

Are these my future co-workers?

>> No.61883169

better fucking start praying

>> No.61883174

I worked at 3 places so far, and none had people acting like that. There were some assholes but even those were polite.

>> No.61883257
File: 8 KB, 520x236, キャプチャ.png [View same] [iqdb] [saucenao] [google] [report]

What did you mean by this?

>> No.61883277

He meant he would really dislike for you to be his coworker, a sentiment I happen to share with him.

>> No.61883296

Don't worry. If you're anything like the average deepeeteér, you probably won't work with me, or anywhere for that matter.

>> No.61883300

Guys I wanna learn c++ more thoroughly, aside from code academy and solo learn what other books should I read?

>> No.61883388

More "thoroughly"? C++ Primer (not the one by Prata) is pretty thorough.

>> No.61883416

I know. I'm the person who wrote >>61883174.

>> No.61884350

disgusting stateful programming

>> No.61884476

>Not capitalising the "L"
Damn it. For a second, I was doubting whether her name was Lain for Iain.
I know a few Iains.

>> No.61884501
File: 295 KB, 700x704, 1474074445126.gif [View same] [iqdb] [saucenao] [google] [report]

there is only one lain whom we all love

>> No.61884632

Does C++ execute all code in a file? Tried to initialize some static members for a class and it forced me to do it outside of the class, worked fine just below it.

>> No.61884761

I don't know what you mean.

>> No.61884780

Static members are like namespaced globals.

>> No.61884793

>Does C++ execute all code in a file
They say that there are no stupid questions, but there are, and this definitely is one of them.

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.