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

/dpt/ - Daily Programming Thread

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

Thread replies: 318
Thread images: 35

File: K&R himegoto waifux2.png (1MB, 1000x1400px) Image search: [Google]
K&R himegoto waifux2.png
1MB, 1000x1400px
old thread: >>59761113

What are you working on, /g/?
>>
>>59770337
it means the variable you used to iterate the vector is not incrementable
>>
>>59770337

Are you calling erase inside your loop?
>>
>>59770362
fuck. I totally assign a vector to a vector inside the loop.
thanks for the clue.
>>
>>59770385
how does it read the flag file then?
a71@shell-web:~/top/mid/problems/f49abea6827cafa20a035340d3812d09$ ../../../../../../problems/f49abea6827cafa20a035340d3812d09/./justno
Oh. Well the auth file doesn't say no anymore so... Here's the flag: 6882905ccde9eeceac01f98cb0260fc2


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char **argv){
FILE* authf = fopen("../../problems/f49abea6827cafa20a035340d3812d09/auth","r"); //access auth file in ../../../problems/f49abea6827cafa20a035340d3812d09
if(authf == NULL){
printf("could not find auth file in ../../problems/f49abea6827cafa20a035340d3812d09/\n");
return 0;
}
char auth[8];
fgets(auth,8,authf);
fclose(authf);
if(strcmp(auth,"no")!=0){
FILE* flagf;
flagf = fopen("/problems/f49abea6827cafa20a035340d3812d09/flag","r");
char flag[64];
fgets(flag,64,flagf);
printf("Oh. Well the auth file doesn't say no anymore so... Here's the flag: %s",flag);
fclose(flagf);
}else{
printf("auth file says no. So no. Just... no.\n");
}
return 0;
}


i don't even have a file named flag in the directory i made. why does it read the flag file relative to where the executable is, but the auth file relative to where i am?
>>
disassembling a video bios right now.
holy shit I forgot how comfy IDA is.
>>
>>59770418
The flag file is an absolute path, notice it starts with /. The auth file us a relative path(relative to the current working directory).
>>
>>59770418
relative directories and file read permission
>>
>>59770458
so if it was
flagf = fopen("problems/f49abea6827cafa20a035340d3812d09/flag","r");


then it would have been accessed relative to the current working directory, and i would have needed to have the file or it'd be a segmentation fault or something?
>>
>>59770490
That is correct.
>>
>>59770503
Well more specifically, fopen would return NULL and it would segfault on the call to fgets.
>>
How do you feel about higher level conditionals?

if (!(fp = (!strcmp(path, "-")) ? stdin : fopen(path, "r")))
return NULL;
>>
>>59770565
How is this used?
>>
Wrote a function to find the probability of k out of n s-sided die adding up to x

Did you know there's a ~40% chance of 3 out of 5 6-sided die adding up to 7? Now you do.
>>
>>59770280
Actually, Fix doesn't even require polymorphic recursion. It's just a recursive type. The only requirement is that the size of the functor applied to any type is constant. Good thing my language has dependent refinement types to express this.
// without the constraint, this wouldn't type check
Fix : (F : Type -> Type | forall X -> size (F X) = n) -> Type
Fix F = F (Fix F)

// B8 is the 8-bit boolean type
// type families are always unions
// thus this is a tagged union
ListF : Type -> Type -> Type
ListF A X = (t: B8, if t then (A, Box X) else Unit)

// type checks because (size (ListF A X)) does not depend on X, thanks to the Box
List : Type -> Type
List A = Fix (ListF A)

BadListF : Type -> Type -> Type
BadListF A X = (t: B8, if t then (A, X) else Unit)

// doesn't type check because (size (BadListF A X)) depends on X
BadList : Type -> Type
BadList A = Fix (BadListF A)
>>
>>59770526
>>59770503
thanks m80, i really wish capture the flags like this would explain the reason why the various hacks work. they never do. another one i'm curious about is this
http://shell2017.picoctf.com:37907/
at first i suspected you'd have to inject code through the box but i was able to just run
javascript:var server_res = make_ajax_req(true);

by typing it into the url bar. how the hell does that force their program to actually run that though?? if anyone can explain i'd appreciate it
>>
>>59770585
returning a filebuffer
>>
>>59770642
javascript isn't done on the remote server, it's done on the client(your web browser). You make it do whatever you want.
>>
>>59770585
Gives you stdin if file is "-".
>>
>>59770565
isn't stdin a fd and fopen returns a FILE * ?
>>
>>59770704
stdin is a FILE *
>>
Why is Lisp and functional programming in general making a comeback?
>>
>>59770704
stdin is a FILE *.
0 stdin's fd (or stdin's fd is 0).
>>
>>59770641
This is just pseudocode, by the way. I haven't nailed down the concrete syntax yet.
>>
>>59770675
why would anyone use javascript then? isn't that a massive security vulnerability?
>>
>>59770764
I don't know about functional languages, but talking about Lisp: it was always good, but now we have better implementations and better computers (I'm not saying that Lisp implementations are slow).
>>
>>59770808
it's fine if you don't trust the user input
double sanitize every bit of data received from the user
it's easier to just abort if you detect anything weird
>>
>>59770648
>>59770676
Oh I see. It would be great for simplifying code, but it would sacrifice readability
>>
>>59770808
modding your browser's colour scheme isn't a security vulnerability
>>
I've been trying to learn c after using mostly scripting languages for 15 years. I just can't wrap my head around bits and bytes and hex and binary and shifting xanding xoring. I don't know if it's because I have dyscalculia or if I haven't found the right learning materials. Has anyone else overcome this? If so how?
>>
>>59770808
No, javascript is meant to do dynamic actions on web pages. Like when you click something, something happens.

Any security checking on the input should be done server side.
>>
>>59770764
FP is needed to reach the level of abstraction necessary to make modern programming practical
>>
>>59770851
What are you having trouble with?
Most people have trouble with the pointers part.
You should at least have a basic understanding of how computers work, how the lowest addressable unit of memory is a byte and a byte is comprised of 8 bits and you can perform individual operations on those bits through cheating with bitwise arithmetic.
>>
Daily reminder that wearing programming socks makes you a better programmer.
>>
>>59770896
The bitwise arithmetic is my problem I guess. I learned pointers from go so they're not that foreign to me.
>>
>>59770764
Nowadays applications are rising in complexity. Lisp allows you to build abstractions over abstraction, moving away from the dust you can't evade in Fortran based languages (C=>C++=>Java=>Python).
>But muh performance
Sometimes performance is not everything. Complex applications would be an uneditable peace of spaghetti if they were written in low level languages. Anyways, Lisp is fast; it's comparable to C and JVM's performance using the right declarations.
>>
>>59770926
it's just logic applied to individual bits in a byte/
>>
>>59770926
This is actually a pretty good explanation, even if it's for javascript.
>>
>>59771062
whoops
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
>>
>>59770882
so what would be the safe way to do what they were doing on that webpage?
>>
>>59771091
Not doing that in javascript at all. You would have a login POST form, this sends your username/password to the server. The server would do the check and if it's valid give them an authentication token(which would be set in a cookie).

When the server receives a request that contains an authentication token, it verifies that it's correct(and up to date) and knows the user is "logged in".
>>
File: 1461444393999.gif (2MB, 320x180px) Image search: [Google]
1461444393999.gif
2MB, 320x180px
>>59770964
>it's comparable to C's performance
>>
File: dogs.png (60KB, 1024x768px) Image search: [Google]
dogs.png
60KB, 1024x768px
>>59771288
>>59771091
to add, you'd also have CSRF tokens to prevent XSS and you'd hopefully be running HTTPS so nobody could snoop the traffic.
>>
File: ok.jpg (7KB, 429x422px) Image search: [Google]
ok.jpg
7KB, 429x422px
>>59771298
>I've never heard of SBCL
>>
>>59771288
i guess i'm just in the dark regarding web anatomy. i'm looking on the wiki page for js and they say there's such a thing as server side js too. how would you control whether JS is run on the server or on the client? like, a website me and a team are working on has javascript and php. the php can't be seen with view-source, but the js can. is js code default client side, but can be overriden to be server side? how would you do that?
>>
>>59771353
node.js is serverside js. it's pretty neat check it out some time. I use Python so I haven't done too much with it other than build architecture for node apps.
>>
>>59771351
hmmm
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=sbcl&lang2=gcc
>>
>>59771353
The server side thing is not important. They mean node.js, some retard said to himself

>hey, here's this horrible shitty language that nobody likes writing(javascript)
>why not use it server side too?
>>
>>59771385
I can't even imagine using js outside of client side fluff scripting, how the fuck do people write an entire software application with it?
>>
>>59771387
Maybe you would complain less if he'd said "comparable to Java's performance" but then again, C programmers are fundamentalists who believe that all software is either 100% fast or 100% slow
>>
>>59771385
i think i get it now. the problem with that web page was that they used javascript to verify the password, and then send if it was correct with ajax. they should've just sent the password with ajax and then used php or something to check the password. thanks for sticking with me
>>
So have anyone used Go and built something?
>>
File: 1433048483491.png (65KB, 322x261px) Image search: [Google]
1433048483491.png
65KB, 322x261px
>>59771437
>>
>>59770764
People come to realise that state is a bad thing and that you want to have as much stateless computations as possible. Functional programming allows you to strictly separate between stateful and stateless computation in an effective way.
>>
>>59770964
>>59771351
SBCL is not even close to C.

Clojure is arguably the fastest Lisp since it runs on JVM and it's not even near C.
>>
give me 1 good reason not to learn assembly in the next 30 seconds
>>
>>59771474
>People come to realise that state is a bad thing
*shared mutable state
>>
How can I find the sum of two variables of the type params double[] in c#?
>>
>>59771474
Does this come from the increased hate towards OOP?
>>
>>59771437
>he
stop pretending someone else agrees with you
lisp is a technological
dead end and nobody wants to hear about it you shriveled autist
>>
>>59771434
no idea either, I'd never try
>>
>>59771526
trump is banning OOP. there was a war on the programming reddit b/t neets and p*****s for trump taking "computer programming" off of the automatically accepted professions for h1b's. made me chuckle
>>
Is recursion a meme? Why would you ever use recursion instead of loops? I am a programming newbie, and I am learning about recursion, and while it makes your programs looks more "sophisticated", it can be kind of tricky to implement correctly. So, as a complete newbie, when/why is recursion used?
>>
>>59771575
Some algorithms are easier to express with iteration. Some algorithms are easier to express with recursion. Converting between the two is trivial. Iteration can be converted to tail recursion (and tail recursion can be directly converted back to iteration). General recursion can be converted to iteration using a trampoline.
>>
>>59771575
I can testify that recursion is harmful, the call stack is literally a linked list and linked lists are bad. You should only use languages that statically allocate their procedure activation records.
>>
>>59771596
>>59771597
Aight, thanks for the answer anons.
>>
>>59771575
Some things is easier done with recursion.

Didn't NASA go against recursion in their code base as they want it to be "simple" as possible?
>>
>>59771575
some problems are naturally recursive, like exploring a tree.

check(node, desiredval)
if node.value = desiredval return true;
else return check(node.left, desiredval) || check(node.right, desiredval)

very elegant and intuitive
>>
>>59771575
>Is recursion a meme?

imagine, you're at class and you ask the professor:

"professor, is recursion a meme?"

kys
>>
So today I helped a friend out with some interview questions. They were all pretty easy, but one gave me a bit of trouble.

It was about "beautiful subarrays" or something. You're given a number N and list of numbers and you have to (1) generate all possible slices of that list, and (2) compute how many of those slices have exactly N odd numbers (apparently that makes the thing beautiful or some shit).

Seems straightforward:

for (i = 0; i < array.length; ++i)
for (j = i; j < array.length; ++j)
for (k = i; k <= j; ++k)
// count odds in this range
// if number of odds = N, then increment beautiful count


It passed most test cases, but timed out on some...

Is there a more efficient solution?
>>
>>59771597
>the call stack is literally a linked list
No, it's not.
>>
>>59771508
Yeah, sorry.

>>59771526
I don't think so. I think it has something to do with the requirements that modern application need to fulfil these days. If you consider a web-server with 10 million requests per second, then you quickly realise that the shared state is a bottleneck in your application.
>>
>>59771658
It's a stack allocator containing a linked list of stack frames.
>>
>>59771644
made me laugh imagining an anon doing this
>>
>>59771639
I actually didn't know that anon. That is pretty interesting. Thanks for the answer.
>>59771641
Oh cool. I guess I better get good with recursion. So that I make my code more A E S T H E T I C.
Jokes aside, thanks anon. Definitely see the usefulness of recursion now that you, and other anons gave me some pretty cool examples.
>>
>>59771673
No, it's a chunk of memory with a pointer. The stack frame allocation is just moving that pointer. It's not a linked list.
>>
>>59771707
i don't even know how you'd traverse a tree iteratively. a bunch of algorithms i don't know how you'd do them without recursion. it isn't the 1990's so unless i get a stack overflow i'd go to recursion as my first way to solve a problem like that
>>
>>59771713
>what is a frame pointer
>>
>>59771747
Fine 2 pointers, it doesn't make it a linked list.
>>
>>59771747
>what is a stack pointer
>>
What's an obscure sorting (or really any) algorithm that could use some parallelism? Something that most cs students won't know about
>>
>>59771771
The frame pointer points to the frame pointer of the previous frame, and so on. Linked list.

>>59771777
>It's a stack allocator containing a linked list of stack frames.
The allocator part is the stack pointer (e.g. ESP).
The linked list part is the frame pointer (e.g. EBP).
>>
>>59771800
https://en.wikipedia.org/wiki/Patience_sorting

Now get to work.
>>
>>59771800
https://en.wikipedia.org/wiki/Stooge_sort
>>
>>59771645
I think this would work, note just pseudo code:
lowOdds = 0
highOdds = 0
soln = 0
for i in range |A|:
if A[i] == odd:
highOdds += 1
for i in range |A|:
if A[i] == odd:
lowOdds +=1
highOdds -=1
if lowOdds and highOdds == N:
soln += 2
elif lowOdds ^ highOdds == N:
soln += 1
return soln
>>
>>59771800
https://en.wikipedia.org/wiki/Spaghetti_sort
>>
>>59771497
Clojure is slower than SBCL.
>>
>>59771575
Eliminates OBOEs.
>>
>>59771901
what about TGWM?
>>
>>59771817
EBP points to current stack frame, not the previous. The previous is pushed on the stack.
>>
>>59771497
So you like performance memes.
C fibonacci's ASM (gcc -S -O2 -s):
    pushq    %rbp
pushq %rbx
subq $8, %rsp
testl %edi, %edi
je .L6
cmpl $1, %edi
movl %edi, %ebx
je .L7
xorl %ebp, %ebp
jmp .L4
.L5:
cmpl $1, %ebx
je .L11
.L4:
leal -1(%rbx), %edi
call fibonacci
addl %eax, %ebp
subl $2, %ebx
jne .L5
.L1:
addq $8, %rsp
movl %ebp, %eax
popq %rbx
popq %rbp
ret
.L11:
addl $1, %ebp
addq $8, %rsp
movl %ebp, %eax
popq %rbx
popq %rbp
ret
.L6:
xorl %ebp, %ebp
jmp .L1
.L7:
movl $1, %ebp
jmp .L1

SBCL's fib ASM:
; ADF:       48894DF0         MOV [RBP-16], RCX               ; no-arg-parsing entry point
; AE3: 488BD9 MOV RBX, RCX
; AE6: 4883EB02 SUB RBX, 2
; AEA: 488BD5 MOV RDX, RBP
; AED: 488D4424F0 LEA RAX, [RSP-16]
; AF2: 4883EC20 SUB RSP, 32
; AF6: 488BCB MOV RCX, RBX
; AF9: 488910 MOV [RAX], RDX
; AFC: 488BE8 MOV RBP, RAX
; AFF: E8D8FFFFFF CALL #x100295DADC
; B04: 480F42E3 CMOVB RSP, RBX
; B08: 488B4DF0 MOV RCX, [RBP-16]
; B0C: 488BDA MOV RBX, RDX
; B0F: 48895DF8 MOV [RBP-8], RBX
; B13: 4883E904 SUB RCX, 4
; B17: 488BD5 MOV RDX, RBP
; B1A: 488D4424F0 LEA RAX, [RSP-16]
; B1F: 4883EC20 SUB RSP, 32
; B23: 488910 MOV [RAX], RDX
; B26: 488BE8 MOV RBP, RAX
; B29: E8AEFFFFFF CALL #x100295DADC
; B2E: 480F42E3 CMOVB RSP, RBX
; B32: 488B5DF8 MOV RBX, [RBP-8]
; B36: 488BCA MOV RCX, RDX
; B39: 4801CB ADD RBX, RCX
; B3C: 488BD3 MOV RDX, RBX
; B3F: B902000000 MOV ECX, 2
; B44: FF7508 PUSH QWORD PTR [RBP+8]
; B47: B8581C5320 MOV EAX, #x20531C58 ; #<FDEFN T>
; B4C: FFE0 JMP RAX

Where is your god now?
>>
Recursion is ALWAYS a sign of a bad programmer.

If you cannot form your logic iteratively, you have made a mistake in choosing your career and/or hobby.
>>
>>59771937
you have to go back
>>
>>59771929
What is this supposed to show?
>>
>>59771925
The current stack frame is on the stack. EBP points to the current stack frame in the sense that it points to its "old EBP". This "old EBP" points to the previous stack frame (its own "old EBP" to be specific). By offsetting a frame pointer you get the frame's locals, return instruction pointer, and arguments.
>>
I'm getting the error no overload for method Sum takes two arguements with this code Console.WriteLine(_attempt.Sum(1, 2));
static double Sum(double x1, double x2)
{
return x1 + x2;
}

Anybody who can point out the error for me?
>>
>>59771948
the C assembly is far more compact and has way fewer instructions than the SBCL fib
>>
>>59771937
I love a bit of false flagging.
>>
>>59771929
Now go ahead and show us just how much boilerplate you had to insert into your code to tell SBCL to essentially strip everything + hard define your types, etc and then imagine doing that for every single function.
>>
>>59771991
>false flagging
Nice try, brainlet.

Recursion is an incorrect way to program.
>>
>>59771968
If you can't tell the difference between AT&T syntax and Intel syntax it's not SBCL's fault.
It's almost the same code.
>>
>>59771929
>talking about binary size when you didn't use -Os
>>
>>59771848
this... how do you not realize a VM is going to add significant overhead?
>>59771497
has no clue what the fuck he's talking about, obviously.
>>
>>59772002
Genius! Keep them coming.
>>
>>59772021
Neither did with SBCL's code.
I didn't talked about binary size, I talked about speed.
>>
>>59771645
Do you have to actually generate the slices, or just compute the number of beautiful ones?
>>
>>59772049
Post source code.
>>
>>59772023
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=clojure&lang2=sbcl

What's that retard?
>>
Does anyone know if
use lib './whatever';
 will follow symlinks? I'm talking about Perl btw
>>
>>59772057
(defun fibonacci (n)
(declare (optimize (speed 3) (safety 0) (space 0) (debug 0))
(inline + -)
(type fixnum n))
(cond
((= n 0) 0)
((= n 1) 1))
(t (the fixnum (+ (the fixnum (fibonacci (- n 1))) (the fixnum (fibonacci (- n 2)))))))

(the fixnum ...)s are everywhere to ensure inlining.
>>
>>59772078
That's not bad, actually. Can you explain this, though: >>59771387
>>
File: aa.png (274KB, 1540x1969px) Image search: [Google]
aa.png
274KB, 1540x1969px
can anyone beat my meme-of-the-month-algorithm program calculation time?
sum of primes under 2 million
is there even a faster way?
I'm using an i7 4790 cpu
>>
>>59772066
I guess spending 10 seconds seeing for yourself was too hard and it was better to make a pointless post.
>>
>>59772094
Yes, mine runs 0 seconds on 2500k.
>>
>>59772062
>>59772088
While Clojure is using ~2 cores, SBCL is using ~1, with better performance per core.
>>
File: 1469656490556.png (14KB, 166x166px) Image search: [Google]
1469656490556.png
14KB, 166x166px
>>59772078
>have to declare the function itself O3 speed
>have to manually tell it to inline + -
>have to define the type for n
>have to define the type for every opeartion and function you call

Talk about verbosity.
>>
>>59772062
>treating the benchmarks game like it's any kind of authority

even so, the SBCL programs still win in like half of those.

in capable hands, SBCL will smoke clojure every single time, simply because it's closer to the metal.
>>
>>59772124
I quoted a link to SBCL vs. GCC.
>>
>>59772119
oh yeah?
prove it
>>
>>59772023
>>59772049

As it turns out, SBCL and Clojure are at a dead heat.
>>
>>59772124
half of the tests sbcl lost in were when it was using more than one core.
>>
>>59772132
At least I don't have to declare every variable's type in every single function. You just declare them in hot-code.
>>
>>59772054
Output is just the number. I mentioned slices because I didn't know how to explain it in any other way.
>>
>>59772166
So basically you're showing off one function that is optimized with a ton of boilerplate code while the rest of your program is using unoptimized garbage?
>>
CL-USER> (defun add (x y)
(declare (optimize (speed 3) (space 0) (safety 0) (debug 0))
(fixnum x y)
(inline +))
(the fixnum (+ x y)))
ADD
CL-USER> (disassemble 'add)
; disassembly for ADD
; Size: 19 bytes. Origin: #x1003FB47B9
; B9: 84042500000F20 TEST AL, [#x200F0000] ; safepoint
; no-arg-parsing entry point
; C0: 4801F9 ADD RCX, RDI
; C3: 488BD1 MOV RDX, RCX
; C6: 488BE5 MOV RSP, RBP
; C9: F8 CLC
; CA: 5D POP RBP
; CB: C3 RET


C can't compete
>>
>>59772189
Profile your code. How many functions are using most of the time?
Anyways, you define macros to avoid that verbosity, but it'd be stupid for a single function example like that one.
>>
>>59772242
>you define macros
Why should I use SBCL instead of a language that is statically typed with no garbage collction out of the box?
>>
>>59772232
That's pretty fucking awesome.
>>
>tfw want to go back to writing cl code
>>
File: logo.jpg (17KB, 413x157px) Image search: [Google]
logo.jpg
17KB, 413x157px
>>59770318
Started learning some FreeRTOS. Didn't know RTOS could be so fun.
Will try to simulate it on Windows before I start fucking around with micros.
>>
>>59772273
Disassemble is pretty awesome indeed. Can check how it's going to look at any point and modify it until you're happy.
>>
File: 1491135603926.jpg (60KB, 960x720px) Image search: [Google]
1491135603926.jpg
60KB, 960x720px
>>59771929
>>59772232
>yfw SBCL shits out better assembly than a C compiler
>>
>>59772256
Builtin JIT compiler.
Real macros.
Not needing a scripting language for plugins and user expansion.
Programs are able to modify themselves at runtime.
>>
>>59772304
do you actually get to use SBCL for work? if so, what part of the industry allows you to use such magic

tfw javajobs
>>
>>59772320
Naughty Dog.
>>
>>59772315
>Builtin JIT compiler.
>Programs are able to modify themselves at runtime.
>Not needing a scripting language for plugins and user expansion.
You said the same thing three times.

>Real macros.
Lisps aren't the only languages with decent macros.
>>
>>59772320
I have used SBCL at work, but only because I was given the opportunity to write my own tools without anyone telling me what to do. Wrote a lot of automation in it, was nice.
>>
>>59772313
I didn't post that to show that SBCL is a better assembler than C. Of course, C compilers are better assemblers. But it's competent. It's not interpreted and it's not VM'd.
>>59772337
Being a blob programmer, it shouldn't bother you writing the same thing 3 times in a row.
>>
>>59772333
no shit... somehow i figured the video game industry was just straight C++

>>59772338
yeah, i do similar stuff to try out new languages sometimes... i have a whole shitload of random utils written in haskell
>>
>>59772360
I won't deny that SBCL has real advantages but those are the only two things.

If my language has good macros or is good enough to not need macros, and I don't need JIT, is there anything else that makes SBCL attractive? Even with its nicer macros is there any other reason to use SBCL over a language with a better type system that doesn't do (((this))), because I value the latter two things much more than macros.
>>
>>59772315
>Programs are able to modify themselves at runtime.


Can you give me an example of this? I don't quite see how you do that stuff.
>>
File: 1469843979355.png (231KB, 304x366px) Image search: [Google]
1469843979355.png
231KB, 304x366px
>>59772389
Is this a Rust user?
>>
>>59772409
Among other things, what's your point?
>>
>>59772370
>somehow i figured the video game industry was just straight C++
It pretty much is, bar indie stuff. But like everyone, I love championing ND's use of lisp.

>>59772389
Just build a type system and a parser for CL.
>>
>>59772417
>just make your own language
I'm already doing this, is there any reason to do it as a layer on top of SBCL instead of having 100% control all the way down to the machine code?
>>
>>59772370
In Uncharted 2 they use C++ with Racket (Scheme) scripts, not SBCL. It's still a Lisp.

>>59772389
I don't think you'd be able to find a language without macros able to define an application-specific expression.

>>59772394
Emacs.
>>
>>59772417
>>59772432
And even if I didn't want 100% control why should I use SBCL instead of e.g. LLVM?
>>
>>59772432
>I'm already doing this, is there any reason to do it as a layer on top of SBCL instead of having 100% control all the way down to the machine code?
SBCL does this.
>>
>>59772473
Does what?
>>
>>59771800
I NEED MORE, NEEDS TO BE ABLE TO BE PARALIZED
>>
>>59772445
You write code in LLVM IR?
>>
>>59772491
For the back end of my language dumbass.
>>
>>59770318
I need some advice from you comp sci guys /g/.
>Been programming for 3 years
>Dropped out of Middle School at 15, started jerking off playing games and programming all day and night
>Got my GED 4 months ago, after being told constantly growing up I was an idiot with a math disability.
>Suck at doing multiplication tables, but I'm currently reading through Pre-Calc books and I'm picking shit up
>Still paranoid as fuck about the Comp Sci math classes
I fucking take my entry exam NEXT MONTH on the first. I'm scared as Hell.

It's the TSI test, which I guess is just Texas' fancy Accuplacer. I can't use a calculator on it. And I don't know if I can use a calculator in classes at all in college either. I'm very fucking scared.

I am studying math day in and day out from the moment I wake up to the moment I sleep, and I am making progress, but time is running out and I'm afraid it won't be enough by the time the 30th comes and I begin classes.

Is this shit as bad as I'm making it out to be?
>>
>>59772146
Something like this should do:
#include <cstdio>

template <unsigned Number, unsigned D>
struct is_prime_rec
{
static const bool value = (D * D > Number) ? true :
(Number % D == 0) ? false :
is_prime_rec<Number, D + 1>::value;
};

template <unsigned Number>
struct is_prime
{
static const bool value = (Number < 2) ? false : is_prime_rec<Number, 2>::value;
};

template <unsigned Number>
struct prime_result
{
static const unsigned value = is_prime<Number>::value ? Number : 0;
};

template <unsigned Bound>
constexpr unsigned get_result()
{
return prime_result<Bound>::value + get_result<Bound - 1>();
}

template <>
constexpr unsigned get_result<0>()
{
return 0;
}

static_assert(get_result<2'000'000>() == 142'913'828'922);
>>
>>59772478
Does give you control down to machine code. Google 'SBCL VOPs'.
>>
>>59772542
I mean in the compilation phase, not writing inline assembly.
>>
File: thing.webm (3MB, 500x500px) Image search: [Google]
thing.webm
3MB, 500x500px
>>59770318
Making an engine in Lisp
>>
>>59772604
what is that? 5fps?
>>
>>59772604
Common Lisp? That's OpenGL, right?
>>
Anyone here interested in writing an imageboard in Elixir?
>>
>>59772604
Fuck off and go back to hating yourself, Nicolas
>>
>>59772655
It's psychologically proven that not being able to notice time's speed is a sign of being under 18.
It's just moving slow, not in a high frame time.
>>
>>59772659
Yes and yes
>>59772655
60
>>59772676
Who the fuck is Nicolas?
>>
>>59772094
Is that sieve?
>>
>>59772775
I don't know what that is
>>
>>59772775
No, that's trial division. Kids dumb.
>>
>>59772094
lrn2asymptotic analysis otherwise no one can compare their algorithm to yours
>>
>>59772094
me@me:~/c$ time ./sumOfPrimes 2000000
142913828922

real 0m0.068s
user 0m0.064s
sys 0m0.000s

>>
File: qqqq.png (205KB, 1741x1514px) Image search: [Google]
qqqq.png
205KB, 1741x1514px
>>59772537
can't compile it
>>
>>59772094
>>59772821
here's the code btw, standard sieve
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
if(argc != 2){
printf("Argument required\n");
return 1;
}

int bound = atoi(argv[1]);
int* primes = calloc(bound, sizeof(int));
primes[0] = 1;
primes[1] = 1;
int count = 2;
while(count < bound)
{
for(int multiples = 2*count; multiples < bound; multiples += count)
{
if(multiples < bound) primes[multiples] = 1;
}
for(int newCount = (count+1); newCount <= bound; newCount++) // set the new count to the next unmarked number
{
if(newCount == bound) count = bound; // there were no unmarked numbers remaining
if(primes[newCount] == 0) // an unmarked number was found
{
count = newCount;
newCount = bound;
}
}
}
unsigned long long sum = 0;
for(int sumCount = 0; sumCount < bound; sumCount++)
{
if(primes[sumCount] == 0)
{
sum += sumCount;
}
}
printf("%llu\n", sum);
return 0;
}
>>
File: fffff.png (80KB, 1641x1344px) Image search: [Google]
fffff.png
80KB, 1641x1344px
>>59772845
what's with all these uncompilable codes
>>
>>59772827
sucks to be u
>>
>>59772883
you using winshit
>>
>>59772845
is your solution a branch and bound approach?

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

int main(int argc, char **argv)
{
int newCount;
int multiples;
int sumCount;
if (argc != 2) {
printf("Argument required\n");
return 1;
}

int bound = atoi(argv[1]);
int* primes = calloc(bound, sizeof(int));
primes[0] = primes[1] = 1;
int count = 2;
while (count < bound) {
for (multiples = 2 * count; multiples < bound; multiples += count)
if (multiples < bound)
primes[multiples] = 1;

// set the new count to the next unmarked number
for (newCount = (count + 1); newCount <= bound; newCount++) {
// there were no unmarked numbers remaining
if (newCount == bound)
count = bound;
// an unmarked number was found
if (!primes[newCount]) {
count = newCount;
newCount = bound;
}
}
}
unsigned long long sum = 0;
for (sumCount = 0; sumCount < bound; sumCount++)
if (primes[sumCount] == 0)
sum += sumCount;
printf("%llu\n", sum);
return 0;
}
>>
File: Screenshot_2017-04-06_15-36-54.png (60KB, 423x118px) Image search: [Google]
Screenshot_2017-04-06_15-36-54.png
60KB, 423x118px
>>59772094
pure bool isPrime(uint n)
{
for (uint i = 3; i * i <= n; i += 2)
{
if (n % i == 0) return false;
}
return true;
}

pure ulong sumPrimes(uint n)
{
ulong ret = 2;
uint num = 3;

while (num < n)
{
if (num.isPrime) ret += num;
num += 2;
}
return ret;
}

void main(string[] args)
{
import std.stdio : writeln;
sumPrimes(2_000_000).writeln;
}
>>
any php boi in this thread that can give me answer to this >>59772506

/wdg/ is full of trash
>>
>>59772845
not only you don't check whether allocation succeeded, you don't check whether atoi returned zero. i stopped reading there.
>>
>>59772883
It's C, not C++, you stupid fuck.
>>
>>59772883
>stdafx.h

kys
>>
>>59772883
You're trying to compile C as C++.
>>
Like holy fuck. All these kids actually using trial division to to solve the sum of primes under a limit?
>>
>>59772950
Post yours
>>
>>59772940
>>59772944
I can't find C in visual studio
only C++
>>
>>59772961
Just rename your file .c instead . cpp
>>
>>59772937
Since it's static that'd be just:
$this->VIDEO_NAME = GenerateNameAndCompress::$NEW_VIDEO_NAME;
>>
>>59772961
so this is the power of windows....
>>
>>59772961
to think i used to be scared of C++ devs
>>
>>59772094
anon come on...
(defun is-prime (n)
(declare (optimize (speed 3) (space 0) (safety 0) (debug 0))
(fixnum n))
(let ((lim (the fixnum (1+ (floor (sqrt n))))))
(loop
for i from 2 to lim
do (when (zerop (mod n i))
(return-from is-prime nil))))
t)

(defun sum-primes (n)
(declare (optimize (speed 3) (space 0) (safety 0) (debug 0))
(fixnum n))
(let ((sum 2))
(declare (fixnum sum))
(loop
for i from 3 to n
do (when (is-prime i)
(incf sum i)))
sum))


CL-USER> (time (sum-primes 2000000))
Evaluation took:
1.379 seconds of real time
1.380000 seconds of total run time (1.380000 user, 0.000000 system)
100.07% CPU
5,528,237,716 processor cycles
0 bytes consed

142913828922 (38 bits, #x214653F83A)
>>
>>59772992
i already tried that, thats why i have it as public static but it is not working
>no errors in error_log
>>
>>59773085
>5.5b cycles

jesus
>>
>>59771575
try deallocating the nodes of a binary tree without recursion, I dare you
>>
SHOW ME
THE SIEVE
>>
File: hhhh.png (198KB, 1548x1408px) Image search: [Google]
hhhh.png
198KB, 1548x1408px
>>59772926
nice try
your program gives back the wrong result in 0.343 seconds
>>
>>59773132
Easy, you simply simulate a stack.
>>
>>59773085
(defun primep (integer)
(declare (optimize speed)
(type fixnum integer))
(if (evenp integer) nil
(loop for i from 3 to (isqrt integer) by 2
never (zerop (mod integer i)))))

(defun next-prime (integer)
(declare (optimize speed)
(type fixnum integer))
(loop do (incf integer)
if (primep integer)
do (return integer)
until (> integer 2000000)))

(defun sum ()
(loop with num = 2
while num
sum num
do (setf num (next-prime num))))

CL-USER> (time (sum))
Evaluation took:
0.890 seconds of real time
0.890000 seconds of total run time (0.890000 user, 0.000000 system)
100.00% CPU
3,032,309,888 processor cycles
0 bytes consed

142913828922

>>
File: 1457983662851.jpg (29KB, 550x335px) Image search: [Google]
1457983662851.jpg
29KB, 550x335px
I'm looking into learning practical Java. They won't let me use Common Lisp at work because it's not pajeetable enough, but I still want a performant and reasonably well-defined language to work with instead of an ad-hoc mishmash of hipster languages with poor tooling that are currently being used.

I did learn Java in school, but it was mostly fill-in-the-blanks coding, nothing from scratch, so I'm a bit lost. Any good books for experienced devs to get good with Java? What build tools should I use, and when do I need to look into these so-called application servers, like Spring and JBoss?
>>
>>59773085
is your code jewish or what
>>
File: Screenshot_2017-04-06_15-58-11.png (316KB, 548x532px) Image search: [Google]
Screenshot_2017-04-06_15-58-11.png
316KB, 548x532px
>>59773167
Why'd you break my program
>>
>>59773224
I almost copy pasted your entire code
logically looks the same
yet it gives different results
computers huh?
really reliable
>>
File: 1485652958941.jpg (131KB, 591x800px) Image search: [Google]
1485652958941.jpg
131KB, 591x800px
Hey anons, I just wanted to say that Lain will always be /g/'s girl, and we don't appreciate her enough.
I'd also like to mention that you shouldn't bully D so much.
Thanks.
>>
File: 1491455372874.jpg (51KB, 976x549px) Image search: [Google]
1491455372874.jpg
51KB, 976x549px
>>59773224
>chris@deathconciousness
>>
File: 1479951904349.jpg (23KB, 400x400px) Image search: [Google]
1479951904349.jpg
23KB, 400x400px
>>59773295
>>
File: Lanka 28.png (41KB, 140x208px) Image search: [Google]
Lanka 28.png
41KB, 140x208px
>>59773295
D-don't tell anyone
>>
>>59773275
maybe because you modified it and compiled as C++ rather than using D you ape
>>
>>59773293
lain would never endorse trash like D
>>
File: 1479963255632.jpg (82KB, 408x600px) Image search: [Google]
1479963255632.jpg
82KB, 408x600px
>>59773371
That's why I said we, including myself, don't appreciate her enough.
>>
QT works on mobile. Why don't gtk and other gui libraries also compile on android and such?
>>
>>59773371
>>59773409
We can appreciate her using and protecting Lisp.
>>
>>59773371
>D
>Trash
lmao
>>
File: bbbb.png (188KB, 1490x1444px) Image search: [Google]
bbbb.png
188KB, 1490x1444px
>>59773224
>>59773275
ok I found the error
uint can't into big numbers so I replaced it with long long
and improved your code a bit

I still don't get it
it's exactly the same code as mine (>>59772094) but mine is multithreaded and runs much slower
why
>>
>>59773486
shot in the dark, doesn't multithreading typically make extensive use of system calls? that'd be an issue right there...
>>
File: 1470950158496.jpg (111KB, 1252x1252px) Image search: [Google]
1470950158496.jpg
111KB, 1252x1252px
Should I write my opengl stuff in Common Lisp or C. It's the only two languages I really know, any experts here have an opinion on either?
>>
Is there any generic class in java/android which I can use to store a pair of doubles or do I need to write my own?
>>
>>59772923
my solution is literally just reading the wikipedia article on sieve of eratosthenes and implementing it in C. i didn't come up with the algorithm. everything is assumed prime, and then you start marking things as composite
>>
>>59772938
what are you going to do about it?
>>
>>59773561
I'm the guy who is doing >>59772604
in common lisp
I've done GL stuff in c and c++ before, and all I can say is do it in common lisp, you are not doing the next unreal engine, SBCL will be fast enough.
Writing it in lisp is much more fun.
>>
>>59773548
well I'm creating thousands of threads there
that might be it
>>
>>59773561
https://github.com/cbaggers/cepl
You should also check out this thing
>>
>>59772551
Yup. Compilation generates machine code, too...
>>
>>59773483
explain how D is not trash
>>
>>59773609
How do you handle loading textures? cl-png or something?
>>
>>59772498
But you were referring to SBCL and LLVM as if they fulfilled the same purpose. Unless you're actually programming directly in IR, they don't.
>>
>>59773660
>I make claim, now you explain why it's wrong
lmao
>>
>>59773670
>Just build a type system and a parser for CL.
This was what you (or someone else) recommended. Sounds a lot like using SBCL as a back end for a language in the same way you'd use LLVM.
>>
>>59773667
I did before, but I wanted to cut the amount of non-lisp libraries, especially with standalone binaries so I'm using png-read now.
>>
>>59773688
Trash is the default state of things.
>>
>>59773688
You're in the minority opinion
>>
Quake 3 arena movement system
https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/bg_pmove.c
Source movement code
https://github.com/ValveSoftware/source-sdk-2013/blob/56accfdb9c4abd32ae1dc26b2e4cc87898cf4dc1/sp/src/game/shared/gamemovement.cpp
See how beautiful sepples is? You should all move right now you old farts. Sepples is the future and you can't stop it!!
>>
>>59773689
>Sounds a lot like using SBCL as a back end for a language in the same way you'd use LLVM.
Ah, no. You can write those things directly in CL, which is what I was hinting at.
>>
>>59773688
I think what he's really asking is why he should move to D from whatever unspecified programming language he's using.
>>
>>59773704
>>59773720
lol
>>
>>59773627
xdddd
>>
File: Unbenannt.png (73KB, 806x778px) Image search: [Google]
Unbenannt.png
73KB, 806x778px
I just wrote a small weather desktop application in pygtk3, any ideas to improve it?
>>
File: 1472164812189.jpg (24KB, 390x234px) Image search: [Google]
1472164812189.jpg
24KB, 390x234px
>>59773627
>>
>>59773748
>lmao
>lmao
>lol
go back there
>>
>>59773729
>class
Holy fucking shit why did Bjarne have to destroy decent programming language like C with warts and aids?
>>
>>59773766
well, i just google "meteo" and it shows me the weather for 10 days
>>
File: Untitled.png (25KB, 670x337px) Image search: [Google]
Untitled.png
25KB, 670x337px
>>59772094

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

int main()
{

unsigned long* primes = malloc(2000000*sizeof(long));

int index;

primes[0] = 0;
primes[1] = 0;

for (index = 2; index < 2000000; index++)
{
primes[index] = 1;
}

int checkvalue = 2;

for (index = 2 * checkvalue; index < 2000000; index = index + checkvalue)
{
primes[index] = 0;
}


for (checkvalue = 3; checkvalue < 1414; checkvalue = checkvalue + 2)
{


for (index = 2 * checkvalue; index < 2000000; index = index + checkvalue)
{
primes[index] = 0;
}
}

long long runningsum = 0;


for( index = 2; index < 2000000; index = index + 1)

if( primes[index] == 1)
{
runningsum = runningsum + index;

}


printf("%lld \n", runningsum);

return 0;
}



This was my first attempt, after I fixed shit being too large for the stack and too small for an int.

How can you even get 4 seconds??
>>
File: 1484538633092.jpg (207KB, 903x1226px) Image search: [Google]
1484538633092.jpg
207KB, 903x1226px
Anyone here good with R, who can do a small assignment for me?

Willing to pay a decent amount, should be no more than a few hours of time.

Hit me up:

[email protected]
>>
>>59773609
He SHOULD write the Unreal Engine. The first one was fucking GREAT. All it needed was ragdolls and proper camera hand-off (for vehicles and such) and it was perfect. Fuck newer engines.
>>
>>59773805
He didn't know any better. But he should have caught on quick rather than wait until this decade to change his mind. He has even had people like Dennis Ritchie comment on the language for him without taking it to heart.
>>
File: IMG_0548.gif (147KB, 500x500px) Image search: [Google]
IMG_0548.gif
147KB, 500x500px
What's a good language to learn after C? C++? I heard that was a bad language.
>>
>>59773850
If it is perfect, why bother writing it again?
>>
>>59772094
Can we please start posting rudimentary profiling statistics before we brag about speeds?
It's so much more educational.
>>
>>59773864
It wasn't perfect. It wasn't free.
>>
>>59773853
It's probably still good to know just because it's popular. But with that as argument you might aswell just go for C#, java or whatever.
>>
>>59773853
C++ is too huge, so no one could grasp it as a whole - that's why no one sees all good aspects of the C++.
>>
>>59771082
Thanks anon, that did help to understand some things!
>>
>>59773609
>fast enough
I don't think so. It's a game engine. People are gonna place their arbitrarily demanding games on top of it.
>lisp is more fun
This would be the main motivator. But it's also the case that game developers don't know lisp in general. They do (or should) know C in general.

But to aim for performance for a project you don't think is gonna be a commercial success doesn't make much sense.
>>
>>59773729
>// converts all '\r' characters to '\n', so that the engine can deal with the properly
what did they mean by this
>>
>>59773908
The same is true of your mother.
>>
>>59773931
Who said anything about making a game engine for other developers to use?
>>
>>59773932
Return carriages aren't the same as newlines. History is shit.
>>
>>59773908
>it's so large you can't see its good
So you're saying you have a language where you need to have large cross cutting concerns when using the language to make it seem good.

Perhaps that's not the kind of overhead programmers need when dealing with problems that are already complicated.

And I don't buy it. Just running with the hypothetical.
>>
>>59773908
>>59773949
Actually, it's more like C++ is so large that it's a huge mess unless you carefully pick and choose what features you employ.
>>
>>59773932
Windows uses \r\n (or swapped, idk) for newline.
That description doesn't sound accurate. They wouldn't want double newlines right?
>>
>>59773971
Not unless you work in isolation. There's no way to limit the features used without external tooling. It's been a hot topic from the embedded community in 2016 and the committee is struggling with it.

It's not a realistic view. And you certainly can't constrain external libraries to this subset. So you need to know and work with a set that you don't enjoy most likely.
>>
>>59774003
For a personal or very tight-knit and constantly monitored project it can be done.
>>
>>59774003
>>59774043
Though, yes, if you're using a lot of libraries it's very hard to pick and choose your features.

If all you do is use C libraries and maybe a bit of the STL it's possible. You'd basically just be writing C and using some C++ features like templates and lambdas when convenient.
>>
>>59773971
This is what Google does.
>>
>>59774043
Yes.
>constantly monitored
So basically you have to introduce a code review process for teams. Even very small teams.
But C++ as a language for small teams only is not the image people have of the language.
>>59774057
Lots of people do that now. It's endemic of how problematic C++ is in general. Doesn't tend to be worth it imo.
>>59774059
Yes. But they have their own tools to handle it.
>>
>>59773931
>I don't think so. I
Common Lisp can be quite fast, I'm sure you could make something AAA quality if you optimize it enough.
>People are gonna place their arbitrarily demanding games on top of it
Well, it's a hobby project, if they are going to place unreasonable demands on it they should work on it.
>But to aim for performance for a project you don't think is gonna be a commercial success doesn't make much sense.
Why not though, it's a hobby project.
>>
How does one prepare for a hand written C++ test?
>>
>>59774144
With a noose.
>>
>>59774144
Insulting your teacher for using an ancient and useless way to make a test.
>>
>>59772094
what font is that?
>>
>>59773931
>I don't think so.
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=sbcl&lang2=gpp

Here's some benchmarks.
While not quite as fast, Lisp can get quite close to C or C++ in performance.
>>
>>59774120
Well if you enjoy performance work sure. You can do performance work as a hobby project but most don't tend to enjoy that.
>unreasonable demands
The standard isn't set by game engines written in common lisp
>>59774184
>benchmarksgame
Anon you should be fully aware of how misleading these are if your goal was to have them as an analogy to real world use.
>>
>>59774144
Black market gun and an alibi or a hitman.
>>
>>59774184
Just based on benchmarksgame SBCL is at its absolute best 60% slower and on average 6-7 times slower. What exactly were you hoping to prove by posting it?
>>
>>59774241
That SBCL has acceptable performance for the given task.
>>
>>59774207
>>59774241

While most game engines use a slow and interpreted scripting language for (duh') scripts, Common Lisp does not need one, and it's compiled to native code.
That's why some people call it "the performance meme", sometimes your "must get the best performance" mindset fails when you hit yourself to a wall and use a Python to write your scripts engine.
>>
Is 10k concurrent users enough for stress testing? I have 16GiB of RAM, I can't force JMeter to allocate more threads.
>>
>>59774291
That depends entirely on how many users you expect.
>>
>>59774302
I don't expect any. This is a uni assignment. We're doing capacity tests on a black-box, and they didn't give us expected user load. Try and break it. At 10k I have ~ 3 second RT, which is not critical, with 2% error rate.
>>
>>59774274
But game scripting is widely considered bad now. UE4 even decided to translate their blueprints to C++ now because people complained so much about speed.
>>
>>59774274
LuaJIT is plenty fast for gameplay scripts and everybody knows or can quickly learn Lua for that purpose. It also has a dead simple API for embedding.
>>
>>59774420
>>59774452
So which is it /g/, is scripting acceptable or not?
>>
>>59774420
That'd be nice.

>>59774452
http://benchmarksgame.alioth.debian.org/u64q/lua.html
http://benchmarksgame.alioth.debian.org/u64q/lisp.html

Compare reverse-complement or binary-tress, SBCL wins. Lua is good in pidigits.
>>
>>59774509
I know he already said it, but LuaJIT is fast as shit. Like, Java fast. It really is impressive.
>>
>>59774526
Java isn't scripting though.
>>
File: Screenshot (14).png (21KB, 616x747px) Image search: [Google]
Screenshot (14).png
21KB, 616x747px
Excuse me /g/.

I am making TicTacToe and as I was testing I got this bug where the game thinks it drew even though X clearly wins.
The X in the bottom right corner is the last one to be put down. Check pic related.

I don't know what is wrong and would appreciate any help granted.

Code is in this pastebin: https://pastebin.com/x5KUPcYz
>>
>>59772961
>I can't find C in visual studio
WHAT THE FUCK AM I READING /G/

HOLD ME
>>
>>59774291
Please tell me you didn't make 1 thread per user
>>
>>59772975
>.cpp
wew
>>
>>59774599
>wew
kys
>>
>>59774540
Yeeesssss...? I was just giving an idea of execution speed.
>>
>>59774609
Oh. Sorry.
>>
In firefox if you type in the url bar:
about:memory


and click on the option
Minimize memory usage


it lower memory usage.

how would one write a script that does that automatically for me?
>>
My answer to concatenating two integer with just math. I was too late to that thread.

/**
* SUMMARY: intcat concatenates two integers and prints the result.
* The concatentation will always be positive.
*/

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

// Returns the number of digits in a
long lintlen(long a) {
return (long)(floor(log10(a))) + 1;
}

int main(int argc, char *argv[]) {
if (argc < 3) {
puts("Too few arguments");
puts("Usage: intcat <long integer> <long integer>");
return EXIT_FAILURE;
}

long lints[argc];

// Converts the string args to longs
for (int i = 1; i < argc; i++) {
if ((lints[i - 1] = strtol(argv[i], NULL, 10)) == 0L || lints[i - 1] == LONG_MIN || lints[i - 1] == LONG_MAX) {
printf("The argument \"%s\" is out of range or not an integer\n", argv[i]);
return EXIT_FAILURE;
}
}

long a = labs(lints[0]), b = labs(lints[1]);
long alen = lintlen(a), blen = lintlen(b);

long c = a * (long)(pow(10, blen)) + b; // $500,000 starting sallary

printf("%ld\n", c);

return EXIT_SUCCESS;
}

/* Cirno a cute! */


Here's the pastebin: https://pastebin.com/m6A6N5bj

>>59774547
I feel like this could be done better with some sort of algorithm. I can't remember the name of it though. MinMax, maybe?
>>
>>59774667
And I know
>sallary
no bully pls
>>
what are some actual useful things I can do with programming languages like C and such?
>>
>>59774686
what can you do with water?
>>
>>59774686
You can write programs.
>>
File: tic.png (18KB, 598x731px) Image search: [Google]
tic.png
18KB, 598x731px
>>59774547
Nevermind I actually figured out what was wrong.
Here is the final version, tell me what you think.
https://pastebin.com/NNQcZPBA
>>
>>59774523
Yeah but if you want to use SBCL then everything has to be SBCL.
>>
>>59774844
Actually, if you want to use SBCL then some of it can be in assembly.
>>
>>59774844
what else would you use?
>>
>>59774917
Anything that can embed LuaJIT, i.e. anything that can call into C libraries.
>>
>>59774929
SBCL can call into C libraries.
>>
>>59773224
how is your code efficient if you're using modulus to test for primality? that's On^2 at least isn't it?
>>
File: 1491217911364.jpg (257KB, 596x588px) Image search: [Google]
1491217911364.jpg
257KB, 596x588px
>>59774929
SBCL can call into C libraries.

>yfw this thread is all about SBCL
>>
>>59774815
Gross, store your buttons in a 2D array and initialize/modify them with a loop.
>>
>>59774941
>>59774949
SBCL embedding Lua for a scripting language would be dumb as fuck. The point is you don't need to use the same JIT language for both the application and scripts.
>>
File: 1490613249758.jpg (24KB, 267x274px) Image search: [Google]
1490613249758.jpg
24KB, 267x274px
>>59774815
>that code
>>
>>59774968
Why would you use Lua at all? Just use SBCL.
>>
>>59774968
>SBCL embedding Lua for a scripting language would be dumb as fuck

No it wouldn't. The whole point of scripting languages is to make it easier for others to modify your stuff. In most cases the average person will side with Lua over SBCL.
>>
>>59774956
I tried using arrays JavaFX just gives a few hundred errors.
>>
>>59774981
The point is to not use SBCL at all.
>>
>>59774981
>In most cases the average person will side with Lua over SBCL.
[citation needed]

>>59774990
Why wouldn't you want to use SBCL?
>>
>>59774990
for what reason?
>>
>>59770318

Is it possible to shit SPI or UART out from a VGA port?
>>
New thread:

>>59775004
>>59775004
>>59775004
>>
>>59775000
>>59775003
Static types.
>>
>>59775000
>[citation needed]
lisp advocates really are deluded
>>
>>59775024
SBCL can enforce this with the optional use of declare.
>>
>>59774815

Its pretty good.

However you clean up your code by making the 'check for winner' parts loops.
>>
>>59775045
Ad hominem instead of evidence? :)

>>59775024
SBCL has those.
Thread posts: 318
Thread images: 35


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

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


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