[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/ - Daily Programming Thread
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: 27
File: image001.jpg (236 KB, 1624x626) Image search: [Google]
image001.jpg
236 KB, 1624x626
Old thread >>54469966

Only good programming related picture I had for the OP picture edition

Tell me what you scrubs are working on
>>
>>54479913
First for Perl comeback
>>
>>54479913
FIRST4TRAPS
>>
File: Denise_Milani_Wallpaper.jpg (118 KB, 1600x1200) Image search: [Google]
Denise_Milani_Wallpaper.jpg
118 KB, 1600x1200
>>54479913
Second for D
>>
Anyone got a good resource for studying all of the must know algorithms?
>>
>>54479913
what fucking lang is that
>>
>>54479978
APL, it requires a special keyboard to use
>>
Whats the best framework for making a very very basic game in c++.
Literally only want to make a single player game of scramble.
Im handicapped when it comes to guis as well.
>>
>>54479940
i want to suck her feminine D
>>
>>54480007
get input through stdin, prinnt it to stdout
>>
>>54479913
Working on a drum practice exercise generator. Very slow progress though. I suck at programming.
>>
>>54480038
maybe i could drum your bum
>>
>>54479913
So /g/, what do you think about this article.

https://reaktor.com/blog/node-js-satellite-means-anyone-can-space-programmer/

Note that Reaktor is the most hip and fashionable web dev company in Finland.
>>
>>54479913
an AI for a board game I made
>>
File: 1462820954130.jpg (189 KB, 720x720) Image search: [Google]
1462820954130.jpg
189 KB, 720x720
>>54479913
We all know C is the best language, but what's the 2nd best?

My vote's on Python
>>
>>54480136
C++ because you can still write C and it will compile most of the time
>>
>>54480136
Scheme
>>
>>54480136
Java or Haskell
>>
>>54480153
>most of the time
webshit detected
>>
What should I do as summer project, everyone says, "whatever you have a problem with" but that's never any use.

I'm not trying to make the next big things just something to keep the skills sharp/learn a new language.

Tips /g/?
>>
>>54480007
Use C# + Unity
>>
>>54480156
>>54480157
worthless
>>
>>54480170
nice meme
>>
>>54480165
you can work on my project if you want
>>
>>54480161
It is not all backwards compatible tard, there are valid C code that is not valid in C++
>>
>>54480183
And what does that entail?
>>
>>54480165
>whatever you have a problem with

Oftentimes, I find myself doing something multiple times a day, and then i figure out how to automate it.
>>
>>54480194
daily sucking each other's dicks
>>
>>54480183
What is your project?
>>
>>54480194
whatever I tell you to do basically
>>
>>54480136
>C is the best language
Okay, Rajesh.
>>
>>54480170
This, in all honesty.

Literally the easiest way to dump out a cross-platform, working game.
>>
I have to make a GUI for a University graded project in Java.
I missed the lecture on the basics, so I'm shit outta luck. Is the introduction to the topic on the Java website good enough, or are there better tutorials?
>>
>>54480190
>I'm a css cuck
>>
>>54480161
struct foo { int x; int y[2]; };
struct foo x = {.y = {[1] = 7, [0] = 4}, .x = 6};
>>
>>54480215
>rajesh knows c
>anon doesn't
m8...
>>
>>54480230
>the lecture on the basics

>one lecture is the difference between knowing how to write an application and knowing nothing

Jesus christ, are you lectures 8 hours long?

There are intro books that do GUI alongside basics. Murach's is good for C# in this, not sure about Java.
>>
>>54480223
>2016
>still thinking about cross-platform
There are too few architectures and all modern compilers work for each of them
>>
>>54480215
indians hate C
>>
>>54480241
>html programmer
>>
>>54480223
>dump
you got that right
>>
>>54480190
the strawman had no chance, amirite?
>>
>>54480275
>virgin NEET
>>
>>54480328
>got told
>now mad
>>
>>54480136

Scheme is better than C.
>>
>>54480182
Nice bait
>>
>>54480361
sure
>>
>>54480363
python is better than scheme
>>
>>54479913
Any app developers here?

How do you take an idea and implement it? Where do you start?
>>
>>54480394
>app
kid, you mush be 18+ to post in this subreddit
>>
>>54480411
so what are you doing here?
>>
>>54480394
download an android/ios book. Follow the steps, and make ur first game.
>>
>>54480411
As in iPhone apps, Android Apps. So yeah, apps.
>>
>>54480420
apps
>>
>>54480430
so yeah, kids are not allowed on this site
>>
>>54480425
Oh, I am already learning how to program for iOS. What i mean is, how do you take an idea from thought, to coded up. Do you start with UI design? Code? Other?
>>
>>54480394
I buy ideas off of business people. I then go and build it. Usually they give me 10-15% of the equity in the idea! I've made a fortune off of these morons.
>>
>>54480458
Other.
>>
>>54480385

I disagree. I'd also like to say that Racket is probably better than both, because it's a LISP, but it's also got a good standard library.
>>
>>54479964
College
>>
>>54480500
you'd be wrong
>>
>>54480500
Faggot, python IS better than Scheme
>>
>>54480528
>>54480535

ur both fuckign retarted
>>
Is blender the best free 3D modelling tool or just the most popular?
>>
>>54480535
How can you be better than scheme with lambdas and expression ifs that are so shit?
>>
>>54480543
>no u
>>
Mine

https://play.google.com/store/apps/details?id=eu.depa.captionr
>>
>>54480559
yes
>>
>>54480566
How can Scheme be better when it can't do a quarter of the things python can do?

Checkm8 altruists

>>54480543
nah you are fampai
>>
>>54480566
how can you be better than python with worthless parentheses and standard library that are so shit?
>>
>>54480467
>10%
i don't think an "ideas guy" should be receiving 90% of the income on an idea that they had no hand in building on their own
>>
File: layne-staley-gi.jpg (58 KB, 500x300) Image search: [Google]
layne-staley-gi.jpg
58 KB, 500x300
>arguing over 1's and 0's
>arguing over electricity being passed through various gates to create a meaningful result
>>
>>54480624
>implying creating the app is the only thing that makes it successful
son i have a bad news for u
>>
is 7 months a lot?
i mean i've made some progress, but there's so much
>>
>>54480624
the guy who sold me his 'uber for schoolchildren' idea could be rich but he only made a few pennies :)
>>
File: carlos.png (138 KB, 350x350) Image search: [Google]
carlos.png
138 KB, 350x350
>>54479940
more like double d
>>
>>54480624
he's memeing
>>
>>54480535
>>54480385
almost anything is better than python even lisp
>>
>>54480743
I C what (You) did there Carlos
>>
>>54480743
lol nice
>>
>>54480778
nice meme pajeet
>>
>>54480795
nice meme literal underage minecraft playing shitkid
>>
>>54479913
How do I add my own custom autocomplete templates in atom? cant find shit on the web about this

plz help
>>
>>54480817
nice meme pajeet
>>
Is there any negative to aligning every label to 16 bytes on x86? Especially if the preceding operation is a jmp?
>>
>>54480837
>atom
nice meme
>>
>>54480601
>standard library
Try knowing your memes. Racket's is perfectly good. Besides missing features can be added, bad design decisions can't be fixed.
>>
tfw no gentoo cock inside my bp
>>
>>54480855
everytime
fucking eat shit autistic ide meme lord
>>
>>54480837
Don't use Atom. I went down that rabbit hole, and it's just atrocious
>>
>>54480914
>is against ides
>uses a web browser to code in
lmao
>>
>>54480743
>>>/r/shittycarlospuns
>>
>>54480007
SFML is probably the most used modern framework.
>>
File: image.jpg (81 KB, 1280x720) Image search: [Google]
image.jpg
81 KB, 1280x720
>mfw realized i spent 7 hours yesterday getting one small aspect of my emacs setup just right, instead of actually working on my project

help guys i think i'm addicted to emacs, what do?
>>
>>54480840
>python is all i know
ok babby
>>
>>54480929
No, SDL is better than that piece of shit
>>
>>54480950
SDL is fucking old and hardware acceleration is disabled by default IIRC.
>>
>>54480931
Keep going, it's worth it.

>sunken costs fallacy
I've never heard of such... ?
>>
>>54480939
nice meme pajeet
>>
>>54480960
I don't think I'll be switching anytime soon, because I essentially have a C/Python IDE set up exactly to my preferences. It's also my IRC client, and PDF viewer.
>>
>>54480929
It's taught me matrices. No seriously, my teacher was all like
>What the fuck is with these 4x4 matrices for non linear 3x3 transformations anon? Can't you just waste neurons doing it like everyone else???
>>
>>54480847

Downside of alignment is always wasted space. You can decide for yourself if this is a worthwhile trade-off (it probably is unless you're very space constrained).
>>
>>54480959
still better than SFML
>>
>>54480991
He's not doing 3D dumb fuck.
And Matrices are piss-easy.

>>54481001
Cool, good for you. I bet you get a lot of things done.
>>
File: 20160410_104201.png (72 KB, 233x289) Image search: [Google]
20160410_104201.png
72 KB, 233x289
>>54480981
Agreed. A Lisp interface is the best approach. Anything else annoyingly reinvents the textbox in a slightly different way. I don't use it to pdfview tho, it crashed last time. I should try again.
>>
File: 1448561031003.png (1 MB, 1702x2471) Image search: [Google]
1448561031003.png
1 MB, 1702x2471
>>54480959
>SDL is fucking old and hardware acceleration is disabled by default IIRC.
only if you use it's blit/text etc function

if you use SDL only to blit the image you keep in some unsigned char scrbuf[320x240]; I doubt you lose anything

also you can easily hook opengl with sdl
>>
File: 1434811358714.gif (2 MB, 280x296) Image search: [Google]
1434811358714.gif
2 MB, 280x296
>>54480628
>there are people on this board that didn't read The Art of Electronics
>>
>>54480921
where did you get that im against ides you sperg
>>
>>54480915
care to elaborate?
>>
>>54481039
>Ask for a c++ framework
>reply with a C framework created the previous millennium

Good job, anon.
>>
>>54481020
>Cool, good for you. I bet you get a lot of things done.
Thanks, I do. Finished my emulator and some games in it thanks to SDL
>>
>>54481035
pdf-tools works really well for me on Linux, and they supposedly support building on Windows through mingw, but I haven't tried that out yet.
>>
>>54481070
SDL is configured for native C++ use, it may as well be a C++ library as well. The benefit over SFML is that it's not shit
>>
>>54481020
>>original content
>LOL NO UR DUMBB
1/10
>>
>>54480959
Didn't SDL2 completely change this, though?

I thought SDL2 brought a lot of new acceleration features and is now more performant than SFML.

Can anyone weigh in on this? I used SFML a couple years back for some shitty games, but if SDL has really improved as my as I've heard, I would rather use that now.
>>
>>54481098
>Still calling something shit without anything to back up your claim

Yup. You sound totally credible.
>>
>>54480929
only neckbeards making VERY basic games use SFML
>>
>>54480999
I figured I shouldn't do it in a few cases, like control flow inside a tight loop. NOPs still take 1/3 a cycle, and there can be up to 15 with a 16B alignment. I am working through PE in assembly and I thought I'd try aligning the code (hadn't cared before, but after realizing my C code was performing faster than, I thought I'd give it a try) and it cut execution to less than half of what it was.

There is a ton of space on modern hard drives. I really wonder what the size differences are in an actual application.
>>
File: fc1.gif (107 KB, 320x240) Image search: [Google]
fc1.gif
107 KB, 320x240
>>54481117
>SDL has really improved
only trouble I really had with SDL is that hard to link SDL_Mixer in mingw
>>
>>54481140
>VERY basic games use SFML
>single player scramble

Perfect, then.
>>
>>54481133
Still not worse than the person defending SFML without backing up his claim
>>
>>54481152
I see, thanks for the input

What about other aspects of SDL?

How hard is it to intertwine SDL primitive shapes with some of my own OpenGL code?
>>
>>54479978
Perl, you have to be special to use it.
>>
>>54481142

I'd be more concerned about RAM usage, and more importantly, usage of the instruction cache, which is more limited, and more relevant to size of code.

But yes, profile your shit.
>>
>>54480457
>Pissy that someone is coding mobile

Someone has to do it anon, just be glad it isn't you.

>>54480458
Normal design principals say that you should first try and refine the idea, break it up into it's core components, figure out multiple ways of creating those components, draw up and design UI, then code away.
>>
>>54481208
>Perl
>literally says APL in the header
expect nothing less
>>
#include <stdio.h>

main(){
printf("ПPИBET\n");
return 0;
}

why this dont work?
>>
>>54481046
I haven't, only book I've read (that wasn't comp. history) was the Blue Nowhere. What's it about anon?
>>
>>54481255
You're a dirty commie
>>
>>54481255
Because you're trying to use moon runes.
>>
>>54481255
it works for me. also fix your main signature, its not the late 70s any more

(your terminal probably is set to the wrong locale/codepage)
>>
>>54481255
implementation defined
>>
Non-programmer trying to learn C, what terminal program should I try that will be interesting?
>>
>>54481203
>How hard is it to intertwine SDL primitive shapes with some of my own OpenGL code?
You just include GL header like you usualy do
SDL creates window for you and manages the HW descriptor, handles events/keyboard/mouse/joystic and e.t.c.

when you want to update screen - you just
SDL_GL_SwapBuffers();
>>
>>54481316
>C
>doing anything interesting
>>
File: pnh.png (215 KB, 604x453) Image search: [Google]
pnh.png
215 KB, 604x453
>>54481255
лoшapa, ты пиши чтo тeбe кoмпилятop cкaзaл лoл
>>
>>54481334
pelle c
>>
>>54481334
Agreed
>>
>>54481316
>what terminal program should I try that will be interesting?
https://www.youtube.com/watch?v=ew5x7Bhxl5U
>>
>>54481334
on ne po ruski otvechaet, tvarb
>>
>>54481334
cyкa блять
зa cтaлиa! ypaaaaaa!
>>
File: 14521227878130.jpg (128 KB, 919x1024) Image search: [Google]
14521227878130.jpg
128 KB, 919x1024
>>54481409
>on ne po ruski otvechaet, tvarb
oн тeбe oшибкy гoвopит cyкa блядь RUSH B
>>
>>54481442
>RUSH B
dnina tbi
>>
Another idea for a project: Take Tiny Scheme, make it smaller/more modular or some shit (i.e. if you're not using the math functions, you can toss them out. If you're not using the vector functions, you can toss them out, etc...). Call it Planck Scheme.
>>
>>54481487
post feet u dumb slut
>>
>>54481500
he probably has really gnarly feet
>>
>>54481487
all you need is lambdas
>>
File: 1449700279793.png (74 KB, 300x256) Image search: [Google]
1449700279793.png
74 KB, 300x256
>mfw I realize that the "Observer pattern" is literally just a collection of objects that have a common method
What the fuck is special about this?
>>
>>54481517
but he posts trap pics on 8ch all the time
>>
>>54481360
Fine, what console programs should I try?
>>
>>54481529
>mfw I realised dependency injection is basically a constant (final) reference.
Naming things allows us to discuss them. Nevertheless, we should always stay aware of the limitations of these names.
>>
>>54481214
>I'd be more concerned about RAM usage, and more importantly, usage of the instruction cache
GCC on O2 seems to like the idea of aligning most labels and all functions.

Question though.
lea     rdi, [rdx+5]

I've seen GCC output operations like this before. Is this really just addition? I'm guessing it's an optimization, offloading the operation onto an AGU instead of over-committing to the ALU ports. Is that correct?
>>
>>54481526

lambda, if, +, -, =... not much else that you need... but to be honest, I'd be rather pissed if I didn't have define and a few common scheme functions.

>>54481500

Why do you want to see my stinky feet?
>>
>>54481563

No, actually I do not. I don't think I recall ever posting any pictures of myself on 8ch.
>>
>>54481605
you don't need any of those if you have lambda
>>
What, exactly, is the point of struct alignment and padding?

Since x86 systems are byte-addressable, why would it matter if we leave a certain amount of space between data values in the struct?

Can't you just squeeze all of them together and access the bytes you want?
>>
>>54481644
okay, so how to do you do addition with just a lambda statement. (no reader macros. just a lambda)
>>
>>54481680
https://en.m.wikipedia.org/wiki/Church_encoding
>>
>>54481585
jesus fuck i always thought dependency injection was some ebin meme but it's fucking trivial

why do you need some fucking framework for that?!
>>
>>54481680
Church encoding.
>>
File: 7phuJaq6.jpg (42 KB, 512x512) Image search: [Google]
7phuJaq6.jpg
42 KB, 512x512
So I bought Modern C++ Design for cheap a while ago with the intent to improve my coding skills but as soon as I got to the 10th page I realized it is waaaaay too hard for me still.

Like even if I try and read it, I feel like I need easier stuff. I'm not a beginner, but I'm not a pro either. I'm at an almost-intermediate level, if that would make sense.

I actually tried to search online before buying it and figured out it would be fine, turns out it wasn't.

So, given you guys don't know shit about me, do you have something to recommend, still? I just wanna learn..
>>
What are you working on in the functional paradigm?

I'm coding a library for linear algebra and stats in Scheme.
>>
>>54481690
>always thought
>meme
classic 4tard: doesn't know what the fuck he's talking about, it must be a meme
>>
>>54481680
f x = 0
f f x = 1
f f f x = 2
f f f f x = 3

x+1 = f x
e.g.
2 + 1 = f (f f f x) = f f f f x = 4

x+y = f^(x+1) y
>>
>>54481700
Developing a language based on a type theory with observational equality.
>>
>>54481689
I know what church encoding and church numerals are. I'm asking you to write a scheme expression with just lambdas to do addition.
>>
>>54481712
tell me what's the point of shit like guice
>>
>>54481587
Ahh, turns out it's still put into an ALU, but it has other uses. You can add up to two registers and an immediate with the same instruction, it doesn't alter the flags, and you can specify the destination apart from the source, like what is in the example.
>>
>>54481696
How much have you programmed?

Also C++ is a pretty terrible language. There's a reason the guy who wrote that book became one of the main guys in the D community.
>>
>>54481721
>I know what church encoding and church numerals are.
>I'm asking you to write a scheme expression with just lambdas to do addition.
Pick one.
>>
im taking a shitty class at uni over summer in a few weeks
i havent looked at assembly in a while (my shitty uni uses MIPS)
this class requires that i use MIPShit assembly, give me an idea for something that i could work on to kind of refresh my memory on assembly
>>
>>54481713
but you still need some kind of a define statement for any of this to be practical right
for exaple the x and the f etc
>>
Ok guys, how do we turn C into a perfect language that will never be beaten? C is great, don't get me wrong, but some features would be incredible to have, such has namespaces, function overloading, direct references, and a proper macro system that would blow C++'s templates out of the water.

What other features would you like to see implemented in or around C? Keep in mind that the main goal is to add pre-compilation features, so the language would still be as fast as it is.
>>
>>54481742
literally C++
>>
>>54481737
What's wrong with MIPS?
>>
>>54481674
pls respond
>>
>>54481700
still getting ready for the next release of my telegram bot library. it's up-to-date for the 2.0 API but I want to fix up the docs a bit and then add some convenience functions before I push.
>>54481721
I mean ideally you'd still have define like Ruby was saying, but you could just copy paste the function to add around whenever you need it
>>
>>54481587

>GCC on O2 seems to like the idea of aligning most labels and all functions.
Because unaligned memory access often is worse than a few cache misses loading extra code into the instruction cache.

>lea
Load effective address instruction. Basically a fused multiply add instruction on integers, except it's a shift and add rather than a proper multiply and add (so you can only multiply by powers of 2). It's original intention was for array access (think: base + offset * sizeof(object)), but it can be used for a lot of optimizations.
>>
>>54481738
(define foo 12345)
(print foo)

can be transformed to
((lambda (foo)
(print foo))
12345)
>>
>>54481723
don't worry your little head, it's surely just an ebin meme :^)
>>
>>54481748
its not used anywhere
its shit
>>
>>54481742
C code that generates other C code
AST macros
currying, ad hoc polymorphism, namespaces
done
>>
>>54481731
I've been programming for years (maybe 5+?) but only as a hobbyist. I know C++ is terrible, but I like it. It's not the only language I know anyway.
>>
>>54481765
low effort/10
>>
>>54481767
Assembly in general is useless if you look at it in that sort of naive way

The concepts, which are what matter, are the important things
>>
>>54481674
think about cache lines in a cpu, think about their width. think about cache locality and cache coherence. think about the penalities of missing out on a cache hit

this is why padding and alignment can be important, if you need data to fit in the cache (any cache) you have options of aligning it, packing it or padding it so the struct fits.

also what if you're on a memory constrained system? say you have like 68 bytes, or even 34 bytes of memory total (on a PIC for example).
>>
>>54481066
The plugins that are out there, even the ones with a million downloads, are unacceptably slow (t. 8GB late 2012 Macbook Pro). The only workflow which isn't frustrating as hell is one where you have minimal stuff going on, which sorta kills the whole point of even using Atom in the first place.

Honestly, if you have OSX or Linux, Emacs might be worth looking into.
>>
>>54481782
>expects effort to be explained basic shit
>as if you can reason with the mentally handicapped
please, stick with "ebin meme"
>>
>>54481746
Nah, nigga, C++ is great, but there's a lot wrong with it.
>>
>>54481806
>he doesn't know what guice is
>pretends it's not a shitty meme
fuck off to /b/
>>
>>54481735
the topic was, "you don't need addition to solve this problem for a planck-style scheme."

it fits both of those, or it fits neither -- thats the point I was making. the math exists, but can you do it in tiny scheme (as the OP suggested)? (not directed to you, whichever anon was just saying "lambda" instead of answering the other guys question with an implementation -- this is the dpt afterall)
>>
>>54481762
I know this, but you still need a define statement for functions, otherwise it would be impractical to copy paste this anon. function all over the place
this in the context of making a new language
unless one can define a define statements purely in terms of lambdas, which one probably can desu
>>
>>54481820
this. it's kinda like old versions of Perl. huge language where all the features are hit-or-miss and half are amazing but the other half are pretty terrible. as long as you know what to avoid it's not too bad.
>>
>>54481529
>tfw the observer pattern has no observing and instead has a lot of notifications
>>
>>54481841
well I'm on my phone right now and can't be arsed trying to type code
if I were sat down at a computer I'd actually provide the examples
>>
Can I have ffmpeg send images directly to my program rather than saving them to a file and then reading that file with another program?

I feel like this has something to do with the concept of pipes but I'm on Windows and also fairly noob.
>>
>>54481841
(define (foo x) (...))

is just
(define foo (lambda (x) (...))

which can be transformed in the same way.

You wouldn't want to do this, of course, but it's a good exercise in language implementation.
>>
>>54481793
But if we compress a struct's values closer together, won't it be better for cache locality, as there is a higher chance for different values in the struct to be loaded into a cache line, because there is no wasted "padding" space between data values?

If I'm on a low-memory system, then wouldn't it be better to drop alignment all together, and pack everything as much as possible?
>>
>>54481887
Forgot a parenthesis on the second snippet, but you get the idea.
(define foo (lambda (x) (...)))
>>
File: aks.png (52 KB, 469x311) Image search: [Google]
aks.png
52 KB, 469x311
How is my implementation of the AKS primality test? (I know python, but it's a poc)
>>
i just cant finish this!
excercise is to reverse an integer.
so 1234 should become 4321
54321 -> 12345
etc...

prohibited are loops and just cout<<;
the reversed number must be received by return statements from recursion. my code gives me my original number back.
anybody an idea?

 
int turn(int a, int &sum) {

if (a) {
int m = a%10;
return m +
10*turn(a/10,sum);
}return 0;

}

int main() {
int sum=0;
cout << turn(12345,sum) <<
endl;
return 0;
>>
>>54481850
>>54481820
There are a lot of really interesting libre libraries which get around a lot of the bullshit parts of c++, like Folly (https://github.com/facebook/folly).

I think that when c++11 rolled around, with auto especially, it went from large language with some great features to huge but manageable language with some great features.
>>
>>54481962
wait theres the sum missing;

int turn(int a, int &sum) {

if (a) {
int m = a%10;
sum = m + 10*turn(a/10,sum);
return sum;
}return 0;

[(code]
>>
>>54481962

void printlast(int a) {
if (a < 0) {
std::cout << "-";
printlast(abs(a));
}
if (a > 10) {
std::cout << (a%10);
printlast(a/10);
}
else
std::cout << 0;
}
>>
>>54481971
>it went from large language with some great features to huge but manageable language with some great features
Pretty good.
>>
>>54482007
thanks but print or cout is prohibited

sum must return through
 return 
>>
>>54480931
>>54480931
I'm almost done customizing my Emacs setup. It only took about 8 months. Just a few more weeks to go!
>>
>>54481962
I hope this isn't a class.
There's no case in the real world where you would be given arbitrary limitations to dick around with numbers.

just char buf[log10(num) + 1], sprintf the number and reverse the string in place, and atoi it back.
>>
File: 1460930166973.gif (941 KB, 627x502) Image search: [Google]
1460930166973.gif
941 KB, 627x502
Hi /dpt/. I have a project I am looking to start but it is much larger than any project I have done before so I am having trouble wrapping my head around how I should structure it.

Are there any good concise resources to learn how to structure medium sized software projects? In the past when attempting to do something like this despite thorough planning I have still found myself buried in spaghetti code.
>>
>>54481971
Definitely, before C++11 I just couldn't bring myself to use the language.

The main "problem" I see with C++ is that after dealing with so many languages, some really stuck with me for the way they handle their name resolutions and things like that. I don't think the C syntax is the syntax that is going to give us the best language ever. For me, the best language even is Lisp. It is concise and predictable, as well as extendable as fuck. I want to write a language that has a Lisp like syntax (using parentheses everywhere for separations and shit), but fully compiled and with 0 underlying systems (just as C is), so it is as fast as C and potentially even more.

If only I wasn't so lazy and got around to learning how to write debuggers...
>>
>>54481962
Don't know if you are allowed to use pow and log functions, but here's my take on it:

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

int turn(int num, int digits) {
if(digits > 1) {
int temp = turn(num/10, digits-1);
temp = (num%10) * pow(10, digits-1) + temp;
return temp;
} else {
return num;
}
}

int main() {
int mynum = 12345;
printf("%d\n", turn(mynum, (int)(log10(mynum))+1));
return 0;
}

>>
>>54482218
kys

>>54481962
>recursion
lol
>>
>>54482283
>kys
n-no bully pls
>>
>>54480136
I'd probably say python too, although I've never used it for the web
>>
>>54482218
thank you very much!
unfortunately no external libraries were allowed

>>54482072
it was a test in a class which i couldnt finish

>>54482283
pls no bully CS not my major but im willing to learn it
>>
>>54482340
write it using a loop and then convert it into the recursive autism
>>
Just messing around with haskell to learn a bit, I made these two functions which you pass a list to, and it returns a list with the numbers which aren't square numbers removed. The first one appears to be very slow, and the second one is kinda ugly but works. How would I do this better?

ispow xs = [x | x <- xs, x `elem` [y^2 | y <- xs]] --very slow
ispow2 xs = [x | x <- xs, if floor (sqrt x) == ceiling (sqrt x) then True else False]
>>
>>54481962
int rev(int n, int ret)
{
if(!n)
{
return ret;
}
else
{
ret = ret * 10 + n % 10;
return rev(n / 10, ret);
}
}
>>
>>54482439
dunno why the code section is super long, guess i accidentally hit enter like a retard a few too many times
>>
File: 002.png (160 KB, 400x400) Image search: [Google]
002.png
160 KB, 400x400
>>54480136
>>54480156
But Scheme and Common Lisp are the actual best languages.
>>
>>54482439
It will look nicer if you separate the concerns of testing for a square number from only taking elements that satisfy a predicate. The second part already exists as filter, by the way.
>>
>>54482543
Absolute dumbass
>>
>>54482459
thank you so very much

no i feel sad
>>
where do you guys find all this motivation to program?

my motivation dies pretty quickly...
>>
>>54482591
It feels nice creating useful programs from scratch.
The fact that you can create something from nothing really motivates me.
>>
>>54482569
It's also TCO
>>
>>54479913
Why do I get SIGPIPE'd when I send()?
My connection should still be open right?
I'm just trying to dump html.

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>

int main(int argc, char *argv[])
{
const char *host = "www.google.com";
const char *port = "80";


int rv;
struct addrinfo hints, *server_info, *rp;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
hints.ai_protocol = 0;
rv = getaddrinfo(host, port, &hints, &server_info);

if (rv)
{
fprintf(stderr, "%s\n", gai_strerror(rv));
return 1;
}

for (rp = server_info; rp != NULL; rp = rp->ai_next)
{
sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);

if (sfd == -1)
continue;

if ((rv = connect(sfd, rp->ai_addr, rp->ai_addrlen != -1)))
break;

close(sfd);
}

if (!rp)
{
perror(strerror(rv));
return 1;
}

freeaddrinfo(server_info);

char buf[256];
const char *s = "GET / HTTP/1.1\r\n\n";

send(sfd, s, strlen(s), 0);

for (int i = 0; i < 256; ++i)
{
recv(sfd, buf + i, 1, 0);
}

puts(buf);
}
>>
>>54482439
The if is unnecessary. == returns a Bool.

Also, the type is probably not what you want:
 ispow2 :: (RealFrac t, Floating t) => [t] -> [t]
>>
File: ce mn.png (19 KB, 638x249) Image search: [Google]
ce mn.png
19 KB, 638x249
I honestly feel like I have the dumbs after reading that error in pic related.

Aren't SLINK and struct Snod* supposed to be the same thing?
>>
>>54482764
A data object and a pointer to a data object are different things
You'll have to initialize *SLINK separately
>>
>>54482439
first is slow because its O(n^2) and the second is O(n). List comprehensions are basically for loops. I'd do this with filter, which has type filter :: (a -> Bool) -> [a] -> [a]
ispow3 xs = filter (\x -> floor (sqrt x) == ceiling (sqrt x)) xs
>>
>>54482909
and the other anon is right, you should split up the test logic from the filter logic
ispow4 xs = filter isSquare xs
isSquare x = floor (sqrt x) == ceiling (sqrt x)
>>
>>54483002
that is a lot nicer, thank you anon
>>
>>54482439
On top of what others said, your first function doesn't actually work unless you pass it in [1..x].
>>
>>54482796
Urm.. How?
>>
File: 2016-05-10-141103_800x600_scrot.png (649 KB, 800x600) Image search: [Google]
2016-05-10-141103_800x600_scrot.png
649 KB, 800x600
Image viewer with tagging.

If you like, you can take a look at github/lehitoskin/ivy
>>
>>54483196
what is the tag itself? Just wondering. Do you just attach a random string to it or something?
>>
File: IMG_20160510_141633.jpg (3 MB, 3120x4160) Image search: [Google]
IMG_20160510_141633.jpg
3 MB, 3120x4160
CIA recruiters at my university. Tempted.
>>
>>54483258
What does CIA even do anymore?
>>
>>54482107
one of my friends on IRC has been implementing a Common Lisp-based language from the bottom up (his own assembler, linker, IR, etc.) that's got semantics pretty similar to C. It's basically as low-level as C but has more Lisp-y features like macros and homoiconicity. He hasn't released it yet (pretty sure it's gonna be GPL though) but from the demos I've seen it seems to work quite well. I think that the biggest problem to happen to C was the syntax choice, because it castrates the whole macro system and makes so much of the syntax feel hacky.
>>
>>54480500
>Racket is better than Shceme
Retarded tripfags are retarded. Racket is just an implementation. It used to be called PLT Scheme and only changed because MIT is Jewish about the Scheme trademark.

If Racket isn't Scheme then nothing is Scheme except for mit-scheme and then I don't know anyone who uses Scheme.
>>
>>54483290
They fund terrorists in the middle easts and accidentally get in proxy wars with other parts of the US funding other parts of the middle east.

>>54483312
Homoiconicity essentially damns your language to being some kind of lisp.
>>
>>54483290

Don't know. Might be worth looking into though.

Pros:
+ Cushy government job
+ Pay is probably high
+ Badass

Cons:
- Have to live in DC
- People will probably hate you because US foreign policy.
- May not be able to tell people about badass job.
>>
>>54482724
http://stackoverflow.com/questions/18935446/program-received-signal-sigpipe-broken-pipe

http://stackoverflow.com/questions/5196971/tcp-client-server-sigpipe

http://www.unixguide.net/network/socketfaq/2.19.shtml
>>
>>54483242
The taglist appears as a string inside the text field, but internally it is a list of strings that is associated with the image's path.
>>
>>54483196
really cool David
>>
>>54483350
>only changed because MIT is Jewish about the Scheme trademark.
Then what about, say, Chicken Scheme? What did the Racket guys do to piss off MIT?
>>
>>54483433
Why not make a simple extension to some known image format to allow a text chunk? (Or use one that already has that functionality). It should be trivial to convert to that image type if it is just some modified png, and you could make a program to do it in batch with ease.
>>
>>54483350

>Scheme trademark
They trademarked it? What the fuck?
>>
>>54483468
Turns out I was wrong I guess? I have no idea how I came under that impression. Maybe I'm not looking at the right sources.

Anyways it appears they want to distance themselves from Scheme despite me using their api pages as references when writing Chicken code.

I think a little less of them now though because it looks like it's an attempt at establishing a distinct brand. It worked apparently judging by that tripfag's response.
>>
>>54483547
Specifically I remember reading an article explaining the choice of the word "Racket" because the inventor thought the Scheme trademark bullshit was a racket.
>>
>>54483455
I think you've got the wrong person.

>>54483477
Like, create an extended version of jpeg/png/gif to allow a text blob that contains the taglist? That sounds like it'd take a lot more work than you make it seem.
>>
>>54483573
And a Racket is a kind of (criminal) Scheme!
>>
File: new dungeon editor.gif (363 KB, 509x376) Image search: [Google]
new dungeon editor.gif
363 KB, 509x376
>Tell me what you scrubs are working on

Rape dungeon editor.
>>
>>54483609
is this that lolisim?
>>
>>54483576
I don't think so. Here is how I would structure it.

uint8_t image_type
uint32_t image_start_offset
texttexttextext
[from here on you copy wholesale the bytes of the original image]
Thread replies: 255
Thread images: 27

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.