[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 30
File: lambda-star-red-flag.png (23 KB, 1920x1080) Image search: [Google]
lambda-star-red-flag.png
23 KB, 1920x1080
Daily Programming Thread (Functional Master-Race Edition)

Old thread: >>51430708

What are you working on, /g/?
>>
>>51436784
Is that optimized?
>>
Ain't nothin civil bout war
Ain't nothin functional bout programming
>>
My webserver.

Only posting because it has functional elements to it (I'm the FAP.net dev), I really want to see someone use it with F# and make something really trippy... Unfortunately they'll probably never release their code.

Now I'll fuck off to /wdg/
>>
File: 1448031305986.png (17 KB, 1920x1080) Image search: [Google]
1448031305986.png
17 KB, 1920x1080
>>51436792
This... is optimized.
>>
I am finishing up a LISP interpreter for my compilers course

I have a few weeks to implement my ``own" language with javacc

also need to create another android application for this course with an optimal neural network player for a specific game my adviser is interested in

porting and maitinaing packages so they can be built with pkgsrc on OS X 10.11

missing the REAL !WiNdowsNME
>>
6th for functional programming is literally useless garbage
>>
So how exactly do they build libraries like OpenGL?
>>
D!
>>
>>51437011
It's not a library
>>
>>51437031
Whoops, I meant API
>>
>>51437008
only pure functional is garbage. Functional programming is an important aspect of almost every decent language these days.
>>
>>51437043
>>51437011
opengl is a standard

look at the source code for an implementation of it if you want to learn
>>
>>51436828
what's fap.net?
>>
>>51432993
>that pic
Programming!

>>51432994
have you ever had an illness that could have killed you? I have. let me tell you, I always think about suicide... but I didn't kill myself just because I was sick.

>If I were severely injured, or I ended up disabled in some way, I'd probably kill myself, too.
and you will end up thinking the same thing: "why would I kill myself? I don't need to"
>>
>>51437056
>>51437008
implementing BFS/BSTs in scheme was pure agony for this course
>>
>>51437011
like what? Do you mean a dynamically linkable library like libGL?
>>
>>51436784
Thank you from refraining from using an animation garbage image op. This is a quality post.
>>
I find it amusing the success rate for FizzBuzz on CodeEval is only 37%. I mean, I think I get why. People sign up, try the first problem, realize they fuckin' suck as programmers, then leave and never sign on again. Still.. 37%.

Let's see your best bogosort implementations, /dpt/.
>>
>>51437169
>bogosort in 2015
it's all about memesort now
>>
>>51437072
What illness anon? Dealing with some serious shit myself at the moment.

>>51432994
Do you not have friends and family that would be devastated? This is the main reason I wouldn't kill myself, but there's probably others i guess. Do you plan on killing yourself when you're too old to work then?
>>
>>51437169
I think it's because they don't know about the modulus operator.
>>
how can i do this in java/scala
 public class Person {
private String name;
private int age;
private Set<Group> groups;

public Person() {
}

public setName(String name) {
this.name = name;
}

public setAge(int age) {
this.age = age;
}

public setGroups(ArrayList<Group> groups) {
this.groups = groups;
}
}

public class Group {
private List<Person> persons = new ArrayList<>();

public Group() {
}

public setPersons(List<Person> persons){
this.persons = persons;
}

}

public Shit {
Person p1 = new Person();
p1.setAge(20);
p1.setName("FAG");
Person p2 = new Person();
p2.setAge(20);
p2.setName("FAGGOT");

Group friends = new Group();

// cycling references

}
this i want to expand it to something like a star-graph with cycling references
>>
>>51437169
>tfw it never gives me a perfect score no matter how good I think the program is
>>
>>51437169
import random

def bogosort(array):
while not is_sorted(array):
random.shuffle(array)
return array

def is_sorted(array):
return all(array[i] <= array[i+1] for i in xrange(len(array)-1))
>>
>>51437011
magic
>>
>>51437209
I don't believe a perfect score is possible.
Best I've gotten is x.998. A perfect score most likely implies 0 mem usage at 0ms runtime
>>
>>51436784
Working on CS homework. Using command line arguments, FILE things and such in C. Pretty neat stuff, too bad I can't figure out how to make my functions work.

Any suggestions on programs to create for fun/experience? I don't have a lot of experience with C, just about a semester's worth, but I'm having a lot of fun with it.
>>
>>51437071
My http implementation

Minimal api and currently benchmarking faster than node.js, a simple http listener in c# and likely most other c# web libraries. In case you're not a web dev, it can be used to send information to and from a server (like login stuff).

var page = new Page("api"); // Create a page accessible through 127.0.0.1:1024/api? 
page.get = (a,b) => "Hello"; // Return "Hello" upon successfully connecting to the page
var server = new Server(); // Create a new instance of the server
server.AddPage(page); // Load your page onto the server
Thread.Sleep(-1);


Anyway, what I really want is someone to write something in F# with it. I'm thinking a webserver with dynamically changing paths.
>>
>>51437280
rwasa is the only worthwhile modern webserver imo

recently ported the most recent version of fasm just so I could run it on OS X
>>
>>51437229
Boring. Jazz that bogosort up a bit.
How about this?

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

#define ARRMAX 9

int check (int array[ARRMAX]) {
for (int i=0; i<ARRMAX-1; i++)
if (array[i] < array[i+1]) return 0;
return 1;
}

void printarray (int array[ARRMAX]) {
for (int i=0; i<ARRMAX; i++) {
int color_chance = rand() % 5;
char color_string[5];
switch (color_chance) {
case 0:
strcpy(color_string, "\033[32m"); break;
case 1:
strcpy(color_string, "\033[31m"); break;
default:
strcpy(color_string, "\033[0m");
}
printf("%s%02X%s ", color_string, array[i], "\033[0m");
}
putchar(10);
}

int main (void) {
int sorted = 0;
int unsorted[ARRMAX];

srand(time(NULL));

for (int i=0; i<ARRMAX; i++) {
unsorted[i] = rand() % 100;
}

while (!sorted) {
for (int i=0; i<ARRMAX; i++) {
int choice = rand() % ARRMAX;
int temp = unsorted[choice];
unsorted[choice] = unsorted[i];
unsorted[i] = temp;
}
printarray(unsorted);
sorted = check(unsorted);
}
puts("SORTED!");
printarray(unsorted);
return 0;
}

Merry Christmas /dpt/
>>
Does anyone know some good books for someone looking to improve at c#?
>>
File: GwY6HZk.png (88 KB, 890x670) Image search: [Google]
GwY6HZk.png
88 KB, 890x670
>>51437200
>>
>>51437313
>
int check (int array[ARRMAX])

[angry Linus noises in the distance]
>>
>>51437337
s'wrong with that?
>>
File: lain.png (987 KB, 814x637) Image search: [Google]
lain.png
987 KB, 814x637
Got side images working! Everything's coming together!
>>
>>51437337
oh I could have done array[] I guess. or even *array.
>>
>>51436976
>LISP

Me too.

Well. It was a Lisp originally. But now I'm deviating and i seems likely I will be incorporating influence from Forth and Smalltalk, including a first-class object system.

The parser is implemented in YaCC and generates S-expressions which can be transformed by macros. Like in Lisp the first component of the Sexpr is considered to be a function to be called.
>>
>>51437291
FAP was written and tested in mono, it absolutely works on osx too. I chose C# for a reason, for my luck Java would only end up working on Linux and C or C++ would require me owning a Mac to support Mac, same with assembly (which is what rwasa is written in).

I'd love to write a server in assembly or (more likely) C one day, just to see how fast I can get it. A 20 nanosecond response time would totally be worth the pain of directly touching whatever files/streams Linux (and later Windows) os use.
>>
>>51437280
Why write it in C# and not F# in the first place?
>>
File: 1397339340537.jpg (2 MB, 2000x2610) Image search: [Google]
1397339340537.jpg
2 MB, 2000x2610
>>51436784
please delete your image, functional programmers don't want anything to do with that disease called communism. We let that to C fags who like to live under an ideology that is dangerous to mankind and to use a language that is also harmful (for most cases)
>>
>>51437169
to be fair, it does have more than just fizzbuzz it asks for. it requires you to parse some file first IIRC.
>>
>>51437280
looks kinda neat. Have you seen suave.io? It's a lot of fun
>>
>>51437516
CodeEval provides you with a template for whatever language you choose to open the file and read it line by line, that's no excuse senpaitachi.
>>
>>51437497
C# is easier and I'm not good at F#.

Also, F# devs can use C# libraries. The whole point of using C# was so I could design a very minimalist, very straightforward library, I doubt that's an easy task with F#. I also wanted to reach as many people as possible, C# allows multiple languages, multiple operating system platforms and since my library has no dependencies it can be pretty much used anywhere.

>>51437533
Interesting, looking into it now. Maybe functional programming is the future...
>>
File: normiesunwanted.jpg (464 KB, 1131x1600) Image search: [Google]
normiesunwanted.jpg
464 KB, 1131x1600
Where were you when the functional programming revolution happened, anon ?
>>
>>51437596
>I doubt that's an easy task with F#
It is. You can write the exact same stuff you'd write in C# in F#. It's just going to be more concise.

>Maybe functional programming is the future...
It's certainly a part of it
>>
are lisp/Haskell/meme functional languages good for gayme dev?
>>
>>51437684
They're good for nothing other than wearing out your paren keys and stroking your dick while shitposting on /dpt/.
>>
>>51437684
No. Sadly.
>>
>>51437684
No, but F# is great for game dev.
>>
>>51437684
they're not really good for anything but to keep SJW neckbeards away from the big boy languages
>>
>>51436784
Can anyone explain why I should benefit from learning functional over procedural or OOP?
>>
>>51437684
tim sweeney, one of the most famous game programmers, once said "purely Functional is the right default"
>>
>>51437727
you should learn how to use all of them
>>
>>51437737
Sure, so you do everything purely functional you can;y find a reason not to. In game dev you always find a reason not to.
>>
>>51437737
>default
meaning you should not use a purely functional language, you should use a proper multi-paradigm language like C++ and use "pure" functions when they make sense
>>
>>51436784
Working on this one
https://open.kattis.com/problems/3sideddice
in python. I just don't know how to solve it without using any external libraries(numpy, scipy).
>>
how do I get into functional programming?
I started reading SICP recently and I'm failing to solve half of the exercises
>>
What should I read to learn C++?
>>
>>51437822
everything
>>
>>51437784
>c++
hell, no. you better should multi-paradigm language like haskell where pure functional is the default. pure fp is not default in c++.
>>
>>51437829
>gaymes
>haskell
*tips*

>pure fp is not default in c++
just write self-contained functions dipshit
>>
>>51437849
contrary to haskell, you have no way to enforce separation of functions from procedures. function programming in c++ gives you its constraints but not the benefits.
>>
File: 1425429412322.gif (141 KB, 287x344) Image search: [Google]
1425429412322.gif
141 KB, 287x344
>>51437882
>>
what if there was a language where there are no booleans, only ternary-truth-values!
>>
File: 1318186319989.jpg (607 KB, 1210x837) Image search: [Google]
1318186319989.jpg
607 KB, 1210x837
>>51436784
>What are you working on, /g/?
Gotta implement a sorting algorithm that sorts a list of points by the polar angle between it and the the first point in said list.
I'm shit at algorithms and programming in general, so this is gonna take a while.
>>
File: lain.png (396 KB, 819x643) Image search: [Google]
lain.png
396 KB, 819x643
There's a main menu now!
IT'S HAPPENING

Any advice /g/?
>>
>>51438070
When and where can I play this?
>>
>>51437971
https://en.wikipedia.org/wiki/Atan2
>>
I'm working on Android app for saving notes.

I have a question.

I have abstract class with abstract method that is called when user's session expired.

How to check inside other class if that method was called, and use that as an argument to redirect user to login screen?

This is abstract method:
public abstract class BaseActivity extends Activity {

@Override
public void onResume() {

if (ParseUser.getCurrentUser() == null) {

sessionExpired();

}
super.onResume();

}

protected abstract void sessionExpired();

}
>>
>>51438122
yes, I know, I have cartesian to polar conversion, it's the sorting with respect to point[0] I need to implement
>>
What are your views on Islam, the religion of peace, /dpt/?
>>
>>51437337
>>51437352

https://lkml.org/lkml/2015/9/3/428
>>
>>51437811
How far into it are you?
>>
>>51438070
There be a Sussman route, right?
>>
>>51437198
>What illness anon?
I had hodgkin's lymphoma. I was in therapy for a year. granted, HL isn't "too bad" w.r.t. other types of cancer, but it's still shit.

>Dealing with some serious shit myself at the moment.
may I know what?
I guess this could help: once I knew I had HL, I read a lot: forums, medical stuff, etc., trying to understand what I had to do, what to expect, and so on. other people probably went through the same thing you are living, so read their experiences.
>>
>>51438250
Wouldn't be a terrible idea. I might think about it.
>>
>>51437684
Ask Carmack.
>>
>>51438229
I watched two lectures and read up to that point
>>
>>51437516
> what is standard input?
>>
>>51438266
basically chronic fatigue. Not been able to work since march. As far as i know it's caused from my guy flora being very unbalanced, which tests have confirmed. Recovery seems tricky. Reacting badly to a lot of the supplements I'm being given.
>>
File: C.png (136 KB, 2000x2126) Image search: [Google]
C.png
136 KB, 2000x2126
>>
>>51436784
>What are you working on, /g/?

A simple A* implementation in C to show my friend who's not so fluent in C how it can be done.

https://github.com/enfiskutensykkel/a-star/
>>
>>51437849
>just write self-contained functions dipshit
>just
lel
>>
>>51437569
>>51438347
oh I might be thinking of a different challenge then
>>
>>51438415
int iadd(const int a, const int b) {
return a + b;
}


oh man oh man
>>
>want to start programming
>start to read book about C#
>guy says I need ".NET documentation"
>I have a vague understanding of what the .NET framework is and that documentation is exactly that, a file that documents features about a thing
>google .NET documentation
>bombarded by a wave of bullshit I don't understand
>look man, I just need fucking ".NET documentation" so I can learn C#

jesus christ this shit is already frustrating, literally can't even find the documentation to begin with, I don't know if I even want to bother with this now. I've learned complex subjects like music before but it seems like programmers are pretty much universally shit tier teachers and make ridiculous assumptions of knowledge. cue everyone calling me a dumbass because I didn't grow up with computers since age 8
>>
>>51437684
Lisp is multi-paradigm, not just functional, you cocksmoking dumbass.
>>
>>51438500
Look at MSDN.
>>
>>51437169
What is their "success rate" based on? Actual successful attempts vs failed attempts, or is no attempt also a failed attempt? I know I made a throwaway account on their to see the challenges, realised how shit their site actually was, and just did any interesting challenges since I couldn't submit them.
>>
>>51438500
What book is that, it sounds like shit or too high level for you
Try this one:
C# Yellow Book

Or search for
"C# Fundamentals: Development for Absolute Beginners Channel9" in google
>>
>>51436784
No anime girl? Fuck this thread.
>>
>>51438250
>wanting to romance jews like RMS and Sussman

John McCarthy is where it's at.
>>
what's a good lisp book for starters?
started reading land of lisp but it's shit
>>
>>51438523
It's not what he's using in the book from the screenshots

>>51438535
alright thanks
>>
>>51438550
define starter

are you literally new to programming? the little/seasoned schemer
do you know already know programming? SICP and HtDP
>>
>>51437684
They can be found okay if you use them right. For example, I made a small game engine in OCaml that had an embedded DSL you could use for scripting the game itself. The main engine was functional but the embedded language was using reactive programming mainly.
>>
>>51438676
>HtDP
HtDP2e
>>
>>51438676
already know programming, new to lisp programming.

>the little/seasoned schemer
is it intended for people new to programing or new to lisp specifically?
and any reason why scheme and not common lisp?
>>
Holy fuck, Visual Studio 2015 does not install the C/C++ tools by default. Unlike the previous versions. I just had the most wonderful time trying to find all the fucking binaries and shit to build something with the VS tools. Why does Microsoft arbitrarily change this shit every version?
>>
>>51438840
little Xer are ``cute'' marginally poetic books to get into lispy thinking by talking about code. HtDP is an introductory book about designing programs, uses Racket (scheme descendant). SICP is an introductory book about computer science, uses MIT Scheme (lisp descendant). If you're self-taught, both of these books will be good for you.

>why use scheme
It has the better books. It's a smaller language than common lisp, which is good for teaching about other topics since you spend little time learning stupid fucking syntax and more time spent learning practices.

Scheme is more toward the functional side than lisp but not by much. Both languages have mutations and they aren't discouraged in any particular way. Finally, lisp has two namespaces (one for function names and one for value names) and scheme has just one.
>>
>>51438953
>using visual studio for anything buy C#
>>
File: download.png (5 KB, 204x247) Image search: [Google]
download.png
5 KB, 204x247
Is this an easy language to learn?
>>
>>51438980
I'm using a free compiler, but need the Microsoft linker.
>>
>>51438953
Microsoft is actively hostile to programmers and you deserve everything you get for programming in Windows.
>>
What is the pattern called when I return "this" from function calls and those function calls change some internal state about the object.

Like right now I have an object that builds an url string for a rest API using chained function calls.
>>
>>51439053
Builder pattern?
>>
>>51436753

No, you're right to feel disgusted.
3rd party libraries aren't written to your exacting specifications and anything that goes wrong in those libraries is out of your control.
>>
>>51439053
It's just called chaining.
>>
>>51438345
That's about the first chapter, right? There's a few hard questions there but most should be doable. Have you tried looking at online solutions and seeing how they do them?
>>
>>51436784
I'm looking into writing a program to interpolate video frames better than the shit that is SVP. No actual code yet, and it probably won't work in realtime, but hey, it's worth a shot.
>>
>>51439084
this

at most i copy-paste individual parts of a library and then refactor the code. for example i needed cubic spline interpolation so i copied some code but it used immutable polynomials (= extreme object creation and garbage collection) and it was kinda messy with 3 different classes just to do the one thing i wanted so i boiled it down to one class and with reusable polynomials
>>
>>51439084
you're a bad programmer
>>
>>51439053
https://en.wikipedia.org/wiki/Method_chaining
>>
>>51439262
curvature continuity requires each spline to be a non-local function regardless, why would you need mutability?
>>
>>51439301
python babby detected
>>
>>51439324
you don't want to alloc memory all the time, especially not on mobile devices
>>
>>51439342
I see, there are opportunities for space optimization if your have a fixed problem space.
>>
I am working on applying to some companies.
>>
>>51439327
guy with autism confirmed
>>
>>51437684
>are lisp/Haskell/meme functional languages good for gayme dev?
functional programming is the inverse of OO

when you design OO you combine data into related data structures and then use functions as an API to access and manipulate the data

when you design a program functionally you start bottom up with low level functions that work on a specific set of data and then build on those functions to higher more abstract functionality. So functional programs are usually DSLs for working on a specific data processing job. You dont very often see libraries used in functional programming except for the most base functionality because a functional program is usually always tailored to a specific task and will not abstract properly for someone else do to the heirarchy of functions that functional programs are made of
>>
File: 1488.jpg (102 KB, 600x600) Image search: [Google]
1488.jpg
102 KB, 600x600
Best languages to learn for the information security field?
>>
>>51438994
Drupal isn't a language. And it's awful and outdated. If you meant PHP the same goes.
>>
>>51436885
underrated post
>>
>>51439452
English
>>
>>51439452
J
>>
>>51439452
russian and c
>>
>>51439440
This is a confusing post
I don't know how somebody could use a functional language and then think any of that
>>
>>51436976
>>51437378

Me three

I've got a basic Forth interpreter written in C++. Writing in a mixture of C++ and Forth I have implemented a basic Lisp REPL that handles builtin simples like +, -, *, etc. I will continue on to lambdas, to macros, and to continuations.

Thanks to the Forth interpreter being threaded code and having tail-call optimisation, I can implement features of scheme like call/cc (Call with Current Continuation) easily.

Who else here writing their own Lisp? Or Forth, or whatever?
>>
>>51439522
I was writing a scheme interpreter but have put that on hold.
>>
>>51439522
yeah I just got my let and lambda/closure stuff working last week. working on lists/cons stuff today.
>>
>>51439463
I already know English friend.
>>
>>51437684
The language is the game, senpai.
>>
Lattice Gas Automata
>>
>>51438531
I would imagine it's based on amount the amount of people who have tried it and have it completed vs those who don't. Score is based on speed and memory usage. Which is sort of unfair because C obviously wins.

Sorry for the long wait. Boss took the office to pizza hut. Shit was tight. All you can eat. Kill me now I'm not going to make it until 5pm.
>>
>>51439522
>tco
C++ doesn't support tail calls, so what did you do? Trampoline?
>>
File: notchsavior.png (111 KB, 605x674) Image search: [Google]
notchsavior.png
111 KB, 605x674
>>51439440
>functional programming is the inverse of OO
not at all, OO is a data abstraction technique and the inverse of that technique is Abstract data types. Functional programming has nothing to do with that. Read your sicp.
>>
>2015
>OOP STILL hasn't died
wake me up 2bh
>>
>>51439713

It hasn't died because there's nothing wrong with it. People abuse it, but people abuse every paradigm.
>>
>>51439713
>not liking the most efficiently modular system
>>
>>51439662
>fox news are comparable to kotaku
fucking liberals
>>
Do anyone have experience with c++ and unordered maps? (hash tables)
I don't know why exactly, but according to massif, I use about 3 times more memory than expected.

The map contains a string as index and a pointer as the content.

I print the size of the map to see how many entries there exists.

Does anyone know why this might be?
>>
>>51440060
Do you add and remove elements regularly?
>>
would a 3d array be a bad idea for a text-based game?
>>
>>51440085
3d arrays aren't a bad idea

just don't do three nested loops every time
>>
Why is programming so hard?
>>
>>51436976
>I am finishing up a LISP interpreter for my compilers course

I'm doing this, but for Java instead of lisp.

>optimal neural network player for a specific game my adviser is interested in

What game? ANN seems like a weird choice for a game, I've done one for some cancer data though.
>>
>>51440060
Try giving the map an initial size that is closer to what you're going to put in it.
>>
File: stallman.png (976 KB, 816x640) Image search: [Google]
stallman.png
976 KB, 816x640
Made a github for the VN. If anyone wants to contribute, get in touch.
>>
>>51440174
Whoops, forgot link:

https://github.com/gitgood/Living-in-the-fast-Lain
>>
>>51440174
Where it at senpai?
>>
>>51440131
It's not
>>
>>51440186
>https://github.com/gitgood/Living-in-the-fast-Lain
sad and pathetic.
>>
>>51440085
>is a hashmap a bad idea for financial software??
>>
>>51438968
ok thanks
>>
>>51440082
yes.
This is a simplified setup
str_fun(){
std::string str = "abc";
return std::move(str);
}

while( !complete){
index = str_fun();
hash_table.emplace(index, node);
}
>>
>>51440174
If it focuses on Stallman, shouldn't it be under GPL?
>>
>>51440207
This might be related then

When you have a vector, and add an element past it's range, it will usually double its size (not increase it by one) so that it won't need to reallocate and move again very quickly
>>
File: plsnobully.png (192 KB, 710x384) Image search: [Google]
plsnobully.png
192 KB, 710x384
>>51440202
>>
>>51440226
It's riddled with weaboo nonsense so it should be under >>>/trash/
>>
>>51440226
>>51440238

GPL should be part of the credits screen for the best/true ending

You have to unlock it

(Bad ending is a commercial license)
>>
>>51440226
MIT is GPL compatible, it doesn't really matter much to me.

Source: http://www.gnu.org/licenses/license-list.en.html
>>
File: 1422463232944.png (310 KB, 691x591) Image search: [Google]
1422463232944.png
310 KB, 691x591
>>51440174
>>51440186
>Doesn't use GPL
>uses @outlook.com email
>>
>>51440232
so massif mistakenly reports this as the string being larger as it is responsible for increasing the size of the hash table?
>>
>>51439522
I wrote my own Lisp that compiles down to JS last month but I got bored with it so I stopped working on it. Still trying to find the time/energy to write my real language I've been planning but I've been way too busy to put any time into it.
>>
>>51440174
>>51440186
I would suggest giving an option of what text editor Lain uses (instead of assuming ST) which obviously get different RMS reactions.
>>
>>51440340
Okie dokes. Will do it later.
>>
>>51440311
I'm not sure, it's just a possibility that the reserved size is much larger than expected.
It could always be something else with the string. Can you debug it and inspect the strings while it's running?

I think a lot of people use this:
Past end --> Double size
< 1/3 occupied --> Third size
It's implementation defined tho
>>
>>51440320
Wtf did hiro just change the tripcode hash function?
>>
Suggest me a programming language that would lend itself well to in memory computation and hashing.
>>
>>51440382
C
>>
>>51440360

Why would he do that?
>>
>>51440174
Think about this from an outsider's viewpoint, without your 4chan mindset.
You're making a VN about a 60 year old man becoming romantically entangled with a 14 year old japanese transfer student?
>>
>>51440415
Probably the same reason he's throwing up Anonymous documentaries.
>>
>>51440402

Forgot to add: I need something with garbage collecting.
>>
>>51440415
>>51440434
He's leet hacker sjw
>>
>>51440445
C
>>
>>51440426
Lain isn't a girl, you'd know this if you watched the animu.
>>
>>51440465
2dpd
>>
>>51440465
he didn't say Lain is a girl or a boy. Please seek help from both an english teacher and a psychiatrist
>>
>>51440509
SPOILERS She's software. If there's something wrong with a man loving software, then I don't want to be right.
>>
>>51440174
Your VN better have a lisp interpreter and you shouldn't be able to get the good end without finishing all the SICP problems.
>>
>>51440533
I do intend to teach basic Scheme through lectures and reading.
>>
File: ss+(2015-11-20+at+04.00.51).jpg (9 KB, 184x195) Image search: [Google]
ss+(2015-11-20+at+04.00.51).jpg
9 KB, 184x195
Question:

In C, is it better to write a function that

A. Writes to a given pointer as a parameter instead of returning, or
B. Returns a value and assumes you know how to handle it

?
>>
>>51440558
>>>/g/sqt
>>
>>51440590
If its such a stupid question, why not answer it and entertain the fact that this is a programming related thread?
>>
>>51440558
A function that returns a value is much more flexible than a void function that writes in place.
>>
>>51439662
>not at all, OO is a data abstraction technique and the inverse of that technique is Abstract data types

>data abstraction technique
>inverse of that technique is Abstract data types

try listening to yourself before you talk, OO is about abstract data types, not the inverse of it

Id really like to see a link in SICP where it calls abstract data types the inverse of OO
>>
>>51440558
B
>>
>>51440358
The string contains what I think it contains.
I write numbers to it, but I make sure they are never zero.
Massif just tells me it is my str_fun (basic_string.h:1073) that takes a lot of space.
Almost equal to the std::pair (which is only used for the hash table)
>>
>>51440611
Your mom is much more flexible than a void function.
>>
>>51440558
>assumes you know how to handle it
You shouldn't have to assume, your function's name should make it clear what will be returned
>>
>>51440694
I've got a few parameters to pass to her
>>
>>51440694
ayy
>>
>>51440611
>>51440657
Thank you for your answers.

I would still ask, why is it that the many Unix libraries operate on A? For example, many of the string.h functions like strcat and strcpy, which write to the first given param. Whilst certainly not void functions, their returns are still redundant given that we know where the change is occurring - the first param.

Yet B is a better practice?
>>
>>51440701
std::uncaught_infection
>>
>>51440728
it depends. B is better in general but you could have a situation where you pass one or more pointers to the function and then it's kinda unnecessary to return the pointer especially if you'd rather return a status code or something instead
>>
>>51440728
Their returns are for error handling.
If something goes wrong, they return a non-zero return code and you can mitigate errors or terminate the thread if something goes wrong.
>>
>>51440728
These do both, so they aren't operating on what you call A.
>A. Writes to a given pointer as a parameter instead of returning
>instead of returning
>>
>>51440768
http://www.cplusplus.com/reference/cstring/strcat/
http://www.cplusplus.com/reference/cstring/strcpy/
>>
File: 1442715083452.jpg (14 KB, 288x344) Image search: [Google]
1442715083452.jpg
14 KB, 288x344
>tfw your program has seven levels of indentation
>>
>>51440762
>>51440768
>>51440770
I have actually learnt something today. Thank you, /g/.
>>
currently finishing up my UNIX-like hobby OS for my class, just have to work on scheduling and gonna add support for multiple terminals. shit is so much fun. c gets me wet
>>
>>51440728
B is better for small functions.
A is good for functions which produces more than one output or the output is larger than what you would like to return (anything more than 16 bytes really)
>>
Racket vs Scheme vs Common Lisp vs Clojure

hardmode: dont answer with "C"
>>
>>51440871
Java
>>
>>51440871
Clojure
>>
>>51440871
clojure is built on abstract data structures which gives it immutability and pushes it in the direction of ML style languages and gives it good concurrency ability
>>
>>51439599
It's essentially a trampoline. The standard technique for implementing Forth is to do so. Implementing TCO for Forth was pretty simple since in Forth if you return something you never ignore it, so I can just test if the last operation before a return from a function is to call another function, and if so, I can avoid allocating a new stack frame.

The Lisp interpreter's apply and eval portions are implemented in the Forth side so I have no additional concerns there.
>>
I hate C, it makes me play with pointer arithmetic for any serious string manipulation and I hate it.
>>
File: lain.png (756 KB, 816x638) Image search: [Google]
lain.png
756 KB, 816x638
You now have the option to read SICP. When clicked, it opens your default browser at:

http://sarabander.github.io/sicp/html/index.xhtml

and tells you to read SICP.
>>
>>51441155
>living in the fast lain
epic. show me the source code.
>>
>>51441164
https://github.com/gitgood/Living-in-the-fast-Lain
>>
>>51441164
The source code should be a reward for beating the game.
>>
>>51441155
epic meme
a girl wouldn't have a room like that though
and the carpet is blocking the drawer under the bed
>>
>>51441204
She just arrived, give her a fucking break friendo.
>>
File: Chaika_on_the_front_page!.jpg (77 KB, 487x460) Image search: [Google]
Chaika_on_the_front_page!.jpg
77 KB, 487x460
>>51441171
>stallman "LISTEN HERE YOU FUCKING BITCH!"
>stallman "I WROTE THE FUCKING COMPILER THAT RUNS THE FUCKING WORLD."
>stallman "THIS IS ALWAYS WHAT HAPPENS TO NICE GUYS, WE FINISH LAST."
>stallman "FUCK YOU, 'Lame Iwa-ching-cong' OR WHATEVER THE FUCK YOU'RE CALLED!"
>stallman "I GAVE YOU MY COPY OF SICP AND THIS IS HOW YOU TREAT ME? SUCK A DICK."
>>
Is this the correct way to create an array of a C struct ?

typedef struct node {int foo;}Node;
Node* array = malloc(no_elements*sizeof(Node));

With that way, I would get into trouble:
 array[1].foo = 0; // Segmentation Fault


I thought it had to be
 Node** array = malloc(no_elements*sizeof(Node));
array[0]->foo = 1; // No trouble here
array[1] = NULL; // No trouble too.


But the first one compiled and executed on it's own perfectly, given that I don't screw with the array. What did it do ? If it's the correct way how do you access the elements with the first one ?
>>
>>51441225
He's right.
>>
>>51441338

is your no_elements just 0? you're not actually malloc'ing any space, thus you're dereferencing an uninitialized pointer which is an insidious bug since it compiles but leads to undefined behavior
>>
So I'm writing a program (or webapp, I honestly don't even know what to call it). The end game is to import a .csv file w/ a list of Judge's firstName, lastName, password, and permission (a 'y' or 'n' char). But for the time being, I'm just going to have a "add Judge" file in php.

So theres two login types:
>admin, permission = 'y'
>judge, permission = 'n'

So I hardcoded the admin's login info into the .sql file:
INSERT INTO LOGIN VALUES ('admnin', '$2y$10$ZTNlZjZmMWVkMjMxOWE3MOsaMyvDRUPJSR5VWJ.QwG0zd4rkdLaMu', 'y');


So here, the password is added already hashed. Is there any way to add the password (which is "secret" btw) as the actual word "secret?" Basically, I'm afraid I'm going to run into problems later on if I cant solve this now.
>>
>>51441403
No it's a #define macro that I set to 1 million
 #define no_elements 1000000
>>
>>51440621
ADTs are a core concept of both OOP and functional programming. Anywhere that some abstraction occurs at the type level can use ADTs.
>>
>>51441338
Your second example is overallocating. If you want a node ** array, you malloc for the element size and node *. You can then either put existing node * inside, OR malloc for the size of node (not node *) and put a new thing inside.

Your first example should work. How many elements did you try to allocate? Also, remember that arrays are zero-indexed: If you want to be able to use array[1], you need to malloc 2 * sizeof node, not 1.
>>
>>51441428
I think the database may have an md5 or sha1 function that takes a string and makes a hash from it.
>>
>>51440818
>seven levels of indentation

Doing what?
>>
I'm really bad at writing algorithms, is there any way to look at the individual variables in a loop function so I can see what I'm doing wrong, or am I limited to printing all the variables with printf?
>>
>>51441553
It's called a debugger. They let you look at the state of a program at any given breakpoint.
>>
>>51441553
If you're using an IDE learn how to use the debugger.
>>
Is peppering your code with printf's still the best way to trace debug?
>>
>>51441638
It never was the best way.
>>
>>51441456
Ok I got greedy and try no_elements = 1billions that's prob why the heap got screwed.
>>
>>51441705
Donald Knuth said it was, though... was he lying to me all these years...?
>>
>>51441757
asserts
>>
I created a linked list, and am trying to organize the list based off an inputted numerical value. The higher the number, the closer to the start of the list I want the node placed at. Any advice on how I can get this done on C++?
>>
>>51441848
when you're going to insert a new node into the list, keep two references to the current node and the next node. If the number is between the two node's values, insert it there.
>>
I'm doing some exercises from Bjarne Stroustrup's PPP book.

Got stuck on "[...] Also give the Token_stream constructor (§ 7.8.2 ) an istream& parameter so that when we figure out how to make our own istream s (e.g., attached to files), we can use the calculator for those. Hint: Don’t try to copy an istream ."

I got
 class Token_stream {
public:
Token get();
void putback(Token t);
void ignore(char c);
Token_stream() {} -> ERROR: complaining that my istream has a protected default constructor
Token_stream(istream& is) { this->is = is; } -> ERROR
private:
bool full {false}; //flag to indicate if there's a Token in the buffer
Token buffer;
istream is;
}


any thoughts?
>>
Is it bad if I have to write loops out on paper to debug them?
>>
>>51441997
Depends on how complex it is, I tend to write a ton of stuff down while I'm programming
>>
File: wisdom_of_the_ancients.png (27 KB, 485x270) Image search: [Google]
wisdom_of_the_ancients.png
27 KB, 485x270
>>
It seems feasting on programmers flesh has made my semen leak.I am aroused.Fuck I'm crazy.I fuck the blood. I need meat on my cock.No meat can satisfy me. I must spew my seed.Spunk flows throughout the mangled programmer now I'll chop it up.
>>
>>51441992
>Token_stream
Make it either TokenStream or token_stream.
>>
>>51441997
way they teach you in school
>write out the iterations and contemplate why it's doing what it's doing and what the correct computation should be

way you do it in real life
>spit out data
>oh this is backwards; this needs to go 1 more; this needs to start 1 earlier; etc.

It's easier to tell what's going wrong when you look at the data in situ.
>>
>>51442010
>>51441997
I used to do this kind of shit a lot but I sort of grew out of it a while back. I haven't really done it at all for the past year or so.
>>
>>51441430
...

#define NUM_ELEMENTS 1000000

thank you
>>
>>51441770
To be fair to >>51441757
I'm a senior comp sci major and I only learned about
assertEquals(...);
last spring semester. And even then, it wasn't a teacher who taught me, it was a fellow student.
>be in Software Design and Development class
>emphasis on Group Programming b/c teacher says in the real world most programmers don't sit in a basement fueled off mountain dew coding in the wee hours of the morning, but working in groups in open offices
>group is composed of me (I hate programming, computer science, etc, but I'm decent/alright at it), one guy who is an amazing programmer, and like 5 other guys who are useless pieces of shit
>me and good programmer doing all the work
>he told me what "user stories" to write
>later we look over code together before turning it in
>asks me why the fuck I have so many printf statements commented out
>oh yeah I'll remove them, they were just for error checking
>asks me why I didn't just use assertEquals
>spaghetti

Thankfully he wasn't a dick about it. He knows I'm never writing a single line of code ever again after I graduate, but he was still willing to explain what it was.

Maybe its the school I go to (we aren't exactly known for our Comp Sci program). Our department is still very small, and as such there isn't a large variety of classes, and the same teachers teach the same classes every year.

In all honesty though, how bad is it that I didn't know of assertEquals until my junior year?
>>
File: lain.png (596 KB, 814x637) Image search: [Google]
lain.png
596 KB, 814x637
Stallman wants the normies to leave.
>>
>>51442183
>Group Programming
C
U
C
K
>>
>>51442183
A friend of mine from uni still did not know what a return statement did in his 3rd year.
>>
>>51440841
source?
>>
>>51442113
Yeah, I was going to name it something like that, but the book said Token_stream. I guess I was blindly following the book.

also, I changed the code to
class Token_stream {
public:
Token get();
void putback(Token t);
void ignore(char c);
Token_stream() {}
Token_stream(istream& is) : is{&is} {}
private:
bool full {false}; //flag to indicate if there's a Token in the buffer
Token buffer;
istream* is{nullptr};
};


and it works now. Is this shitty code?
>>
>>51440871
common lisp
its the only real lisp of the bunch
>>
I feel the need to practice some language other than C for employability reasons. I'm familiar with C++ but haven't done a project in it.
Python?
Java?
C#?
I can't imagine myself actually wanting to use any of those three but I need to learn something different. But sitll employable (i.e. not lisp you fuckheads)
>>
>>51439462
overrated idea about how much of a shit others give to his/her opinion
>>
>>51442360
It was a mandatory class. It wasn't that bad in the end, but yeah I generally hate group projects, unless its for a non-STEM class and its with my friends.
Thread replies: 255
Thread images: 30

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.