[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
Dailly 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: 28
File: haxor.jpg (333 KB, 1888x1232) Image search: [Google]
haxor.jpg
333 KB, 1888x1232
Old one: >>51980217

What are you working on /g/?
>>
gtfo.
>>
File: wat.webm (1 MB, 800x713) Image search: [Google]
wat.webm
1 MB, 800x713
r8 my swift calculator, any advice is appreciated
>>
File: jew-kike-tropes-frequency.jpg (11 KB, 213x250) Image search: [Google]
jew-kike-tropes-frequency.jpg
11 KB, 213x250
Fuck off CIA
>>
>>51985347
Coding a remake of a game I made 6 years ago.
>I should be working on university assignments now
>>
You guys couldn't wait 10 more posts?
I was gonna give you guys a fresh hime OP pic.
>>
>>51985399
Fag.

>>51985406
It's Shit.
>>
>>51985406
I don't like any of the colors.
>>
>>51985406
Wow, so modern!
I r8 -8/8 m8
>>
Who here /unintelligiblecode/?
from itertools import product

data=list(i.split() for i in open("Advent21.txt").read().split("\n"))
a,r=[[0,0,0]],[[0,0,0],[0,0,0]]
w=list(list(int(i) for i in i[1:]) for i in data[1:6])
a.extend(list(list(int(i) for i in i[1:]) for i in data[8:13]))
r.extend(list(list(int(i) for i in i[2:]) for i in data[15:21]))

def fight(myDam, myArm):
myHP,hisHP,hisDam,hisArm=100,104,8,1
myTDam,hisTDam=max(myDam-hisArm,1),max(hisDam-myArm,1)
myHits=hisHP/myTDam+(hisHP%myTDam>0)
hisHits=myHP/hisTDam+(myHP%hisTDam>0)
return myHits<=hisHits

minCost,maxCost=9999,0

for i in product(range(len(w)),range(len(a)),range(len(r)),range(len(r))):
if i[2]!=i[3]:
currCost,currDam,currArm=(sum(m[n] for m in (w[i[0]],a[i[1]],r[i[2]],r[i[3]])) for n in range(3))

if fight(currDam, currArm):
minCost=min(minCost,currCost)
else:
maxCost=max(maxCost,currCost)

print "Minimum cost to win: "+str(minCost)
print "Maximum cost to still lose: "+str(maxCost)


Advent21.txt
Weapons:    Cost  Damage  Armor
Dagger 8 4 0
Shortsword 10 5 0
Warhammer 25 6 0
Longsword 40 7 0
Greataxe 74 8 0

Armor: Cost Damage Armor
Leather 13 0 1
Chainmail 31 0 2
Splintmail 53 0 3
Bandedmail 75 0 4
Platemail 102 0 5

Rings: Cost Damage Armor
Damage +1 25 1 0
Damage +2 50 2 0
Damage +3 100 3 0
Defense +1 20 0 1
Defense +2 40 0 2
Defense +3 80 0 3
>>
>>51985406
>Any advice is appreciated
Stop using Swift
>>
File: calculator.jpg (480 KB, 2880x1800) Image search: [Google]
calculator.jpg
480 KB, 2880x1800
>>51985445
I will change most colors and add more keyboard themes anon, thanx for your opinion!

>>51985427
>>51985450
t-thanks
>>
>>51985511

For literally what reason are you doing this?
>>
match *self {
Slice(data, pos) if pos < data.len() && pred(&data[pos]) => Slice(data, pos + 1),
_ => Empty
}


How can I tidy this up?
>>
>>51985569
I like short code.

If you're talking about what the code is for, it's for adventofcode.com's challenge today
>>
>>51985406
where's muh trig functions, where's muh logs, where's muh e and pi nigga u got some work to do
>>
>>51985573
i have no idea what this does lol
>>
>>51985596
I will add a bunch of new operations on landscape mode, there's a lot to do lmao.
>>
Can you take the average of two unsigned hints in C?
>pro tip: you cant
>>
>>51985630
lmao okay senpai, desu it looks quite good so far, try not to focus so much on the color picking stuff and focus on its functionality baka
>>
>>51985636
STOP
>>
>>51985636
That's too easy.
>>
>>51985651
yeah ikr, The personalization will be only 10 background colors + 10 keyboard themes, pretty simple stuff.
>>
>>51985636
double
average(unsigned a, unsigned b) {
return round(a/2.0 + b/2.0);
}
>>
>>51985636
Please define "hint".
>>
I'm really bored and want something challenging
I'm thinking of writing a driver on Windows.
What should my driver drive?
>>
>>51985714
>average(1,2) isn't 1.5
srsly hope
>>
what if I would make two variables equal to a and b, but floats, do
truncate((float_a + float_b) / 2)
>>
double avg(int a, int b;
{
return (double) a / (double) b;
}
>>
>>51985552
what kind of faggy dead language is that?
kill yourself, savage
>>
>>51985795
looks spanish

could be mexican though
>>
>>51985805
it's portugese
he's BR
>>
>>51985636
double average(unsigned int x, unsigned int y)
{
return pow(10,log(x) - log(2))+pow(10,log(y) - log(2))
}
>>
Reminder that this, all this, everything here is part of a toxic culture
http://workplace.stackexchange.com/questions/59664/why-are-places-specifying-m-f-in-the-job-title
>>
>>51985573
By not using Rust/Swift.
>>
I'm working on a dialect of Go

It's basically exactly the same except it compiles even in the face of an unused function somewhere
>>
why aren't there any mobile rts? it's such a niche market
>>
>>51985406
I think it looks cool
>>
>>51985793
The average of 1 and 2 is 0.5? Seems legit enough; to production it goes.
>>
>>51985873
Please show me a tidier version in a language you suggest.
>>
>>51985879
mobile "gamers" can't handle anything more complex than slide 3 to win puzzle games with artificial stamina.
>>
>>51985900
2 + 1 = 3
3 / 2 = 1.5
>>
>>51985879
I'd make one, I wanted for a while to do one, if I had an android/iphone and could do art
I have a windows phone, where there is no market
I could go with ue4 but it melts my computer case beams, and then there is unity
hell, I could switch for a while from sepples to c# but then there is art, which I can't do
so there's that /blog
>>
>>51985939
Not him, but are you retarded? How do you get 2+1 from that code?
>>
>>51985939
I don't see a single + in that code. I actually don't even see a closing parenthesis for the if-statement, but a semicolon.
>>
>>51985728
Make it drive out the trap and weebshits from our /dog petting thread/
>>
>>51985636
unsigned is ez pz, try averaging two signed ints in C
>>
>>51985793
8/8 if b8
>>
>he can't write code that can be run in 6 different languages
http://www.retas.de/thomas/computer/programs/useless/misc/polyglot/c.html
>>
>started learning programming
>it feels awesome
>want to set my path of self-development

What programming language should I learn after ansi C and why?
>>
>>51986085
Haskell
>>
>>51986085
>after ansi C
anything else
>why?
because C
>>
>>51986085
C11, because C89 is old as fuck and there is very little reason to use it over the latest C standard.
>>
>>51986085
C++(tm)
because it's the best thing ever and the only thing relevant if you want to be taken seriously
>>
>>51986119
the only difference between C89 and C11 are a few extra header files which haven't even been implemented fully in any modern compiler.
Does GCC support threads.h yet?
>>
>>51986147
*glibc
>>
>>51986119

Some people hate new features.
>>
>>51986147
>the only difference between C89 and C11 are a few extra header files
What about all of the convenience features introduced in C99?
>Does glibc support threads.h yet?
threads.h is an optional header. glibc/gcc and clang still fully supports C11 and it is even the default standard used for them.
There are some patches for threads support in the glibc-alpha mailing list, so assuming they get accepted, it will eventually get support for it.
>>
>>51986147

In between the two, C99 has a bunch of goodies on its own (designated initializers, compound literals, etc.)
>>
>>51986085
cpython
>>
working on a simple music player with python
>>
File: what.png (24 KB, 776x695) Image search: [Google]
what.png
24 KB, 776x695
>>51985636
>pro tip: you cant
sorry, what? I can't hear you over my unsigned averager.
>>
>>51986284
not sure if you're an idiot or you're just memeing
>>
>>51986059
>useless
>>
>>51986335
>implying the creator thinks printing 1 line is useful
It's a test of polyglot abilities lad
>>
Posted this in last thread but I think it's gone now. On a scale of shit to very shit, how shit is my code? It's supposed to take a value of resistance, then tolerance, and generate any random ten numbers between the upper and lower tolerances.

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

void main()

{
int v;
int t;
int x;
float rlow;
float rhigh;

srand((unsigned int)time(NULL));

printf("Enter resistance (ohms):\t");
scanf_s("%d", &v);
printf("Enter tolerance (%%):\t\t");
scanf_s("%d", &t);
printf("\n");

rlow = v*(1 - (t / 100.f));
rhigh = v*(1 + (t / 100.f));

for (x=0;x<10;x++)
{
float r = (rand())/(RAND_MAX / (rhigh - rlow))+rlow;
printf("Possible Value = %.2f\n", r);
fflush(stdin);
};

getchar();
}
>>
>>51985636
public class X {
static int avg(int a, int b) {
return (a + b) / 2;
}
public static void main(String[] args) {
int a = 101;
int b = Integer.MAX_VALUE - 100;
System.out.println(avg(a, b));
}
}
12:04AM ~ λ java X
-1073741824
>>
>>51986284
EXP(3) Linux Programmer's Manual EXP(3)

NAME
exp, expf, expl - base-e exponential function

...

ERRORS
See math_error(7) for information on how to determine whether an error
has occurred when calling these functions.

The following errors can occur:

Range error, overflow
errno is set to ERANGE. An overflow floating-point exception
(FE_OVERFLOW) is raised.

Range error, underflow
errno is set to ERANGE. An underflow floating-point exception
(FE_UNDERFLOW) is raised.

Why aren't you checking errno to prevent overflow and underflow?
>>
>>51986085
java and then C++

absolutely do not learn python or haskell
>>
File: 1374574508775.jpg (29 KB, 499x500) Image search: [Google]
1374574508775.jpg
29 KB, 499x500
>>51986368
>void main()
>fflush(stdin);
>getchar();
>using C89 in 2015
>>
>>51986434

We've got to use visual studio senpai someone mentioned in the previous thread about the limitations of it.
>>
>>51986456
Why the fuck are you being forced to write C in VS? That makes no sense.
>>
>>51986456
>somehow using C89 has anything to do with visual studio
does it only support up to C89 or something
>>
>>51986368
Just regular shit.

Find a way to break this up into more functions. I have no idea what's going on as someone who did not write your code, and the names of functions will help me understand.
Please name v, t, and x better. x should be named i; this is just idiomatic for arbitrary loop counters like this one.
Main should look like this:
int
main(void) {

You rarely have to cast in C. Don't cast time() here.
Use more spaces. For loops should look like:
for (i = 0; i < 10; i++) {

Most terminals are newline buffered; that is, your fflush is completely unnecessary. Maybe call it once after the end of the loop, not in the middle of it.
The final getchar() is Windows shit. I would be annoyed by that since I am on Linux.

That's it.
>>
>>51986479

I don't know, it's only an introduction to C. I think its to makes it easier for people who can't into computers. We will be doing embedded C next year and using better toolchains.

>>51986485

Yeah, or at least someone said something to that effect in the last thread, something to do with MS implementation.

>>51986496

Thank you for the constructive criticism.
>>
if(test) {

>Reasonable human being

if (test) {

>Holy shit nigger what the fuck are you doing
>>
File: fixed.png (28 KB, 769x754) Image search: [Google]
fixed.png
28 KB, 769x754
>>51986398
Why would I need to?
As long as x is a valid integer, e^(log(x)-log(2)) <= x.
I'd never have to check for overflow, but you bring up a point about underflow. log(0) is undefined.
>>
>>51986561
wow you really are memeing
>>
>>51986535
>implying if is a function
kill yourself

sizeof() is the only keyword to be used like a function
>>
Implement a command line program in C that can average 100000000000000000 and 200000000000000000, or any number around that size.
>>
File: signed.png (29 KB, 777x787) Image search: [Google]
signed.png
29 KB, 777x787
And the signed version takes just 2 more lines of code

>>51986578
What? Dude, I'm a full time C developer.
>>
>>51986535
this

>>51986586
it looks like shit, hurts readability. the condition should be "attached" to the if
>>
>>51986621
>hurts readability
now we all know you're trolling.
way to give it all away one post in.
>>
>>51986535
>>51986586
It's pretty shitty that you need the parentheses in the first place.
>>
>>51986606
Just use GMP
>>
You forgot "/dpt/" in the catalog.

I only found this thread because of the old thread.
>>
>>51986663
this tbfhfwy (to be fairly honestly fair with you)
>>
File: based.png (43 KB, 735x322) Image search: [Google]
based.png
43 KB, 735x322
>>51986606
>>
>>51986606
Using a bignum library like GMP would make that trivial.
>>
why do I find pajeet here so funny?
am I racist?
https://www.youtube.com/watch?v=OkncKzflw8I
>>
>>51986681
Nice implementation of the C programming language you got there
>>
>>51986669
you can thank the fucking retarded trap fag for making everyone post their shitty threads before the bump limit
>>
>>51986731
You're racist against women and islam
>>
>>51986388
>in C
>>
>>51986731
is it legitimately from the 80's or is that how far behind india is?
>>
>>51986702
Implementing basic multi precision add and shift is trivial too, elementary school pen&paper adding algorithm is enough (and shifting is just rippling higher words downwards, like you would shift array elements).
>>
>>51986744
I warned about this shit months ago.
I said that if you allow people to create threads before bump limits, it creates races between different faggots, causing threads to be made earlier and earlier. There was even a time when the janitor would delete new threads made before the bump limit.
Now look at what we have. I hope you fags are happy.
>>
>>51986744
Yeah, and guns kill people.
>>
>>51986790
Or...you can just link GMP and get it over with.
Why would you waste your time reinventing the wheel and making it a square?
>>
>>51986774
Not sure why the meme is only about C when java and many other languages have the same features that makes averaging 2 int more complex than it first looks.
>>
>>51985636
double avg(unsigned int a, unsigned int b)
{
return a / 2 + b / 2 + a & 1 ? 0.5 : 0 + b & 1 ? 0.5 : 0;
}
>>
>>51986790
No shit. Linking GMP is faster and less error-prone though.
>>
>>51986801
the trap fag just doesn't care, or he enjoys the drama he stirs up. he's truly fucked in the head
>>
File: 1385792865025.png (304 KB, 722x768) Image search: [Google]
1385792865025.png
304 KB, 722x768
How do I learn JS, /dpt/?
>>
>>51986849
>>>>/wdg/
but reading a book probably works
>>
>>51986815
your analogy sucks balls because unlike a gun the trap fag isn't an inanimate object. his actions have consequences and he is the one in control of his own actions.
>>
>>51986827
Probably because signed integer overflow is undefined behaviour in C, or maybe because people are trying to shit on C when it affects any type of modular arithmetic.

>>51986849
Step 1: Don't
>>
>>51986861
I don't like /wdg/, /dpt/ is more fun.
>>
>>51986827
>>/trash/
>>
>>51985409
what is your problem sir?
>>
File: ii.jpg (99 KB, 600x800) Image search: [Google]
ii.jpg
99 KB, 600x800
>That feel when you make something and people beg you to release it but you never release it

Anyone know this feel?
>>
File: 1439863236070.jpg (267 KB, 1280x720) Image search: [Google]
1439863236070.jpg
267 KB, 1280x720
>have to write program that gets the nth fibonacci number
>can't use for loops
>>
>>51984452
>>51984540

Here I made a slightly more advanced version in C.
It will currently read oneline inputs from stdin or an input file specified by arguments.
It will at most hide one letter in a word.
It will prefer to hide in a long word.
It'll try all possible combinations and output all, plus the best one found at the end.
I didn't test much but it seems to be working.

http://pastebin.com/DRmfxgzn
>>
>>51986922
Build a histomorphism with recursion and use that.
>>
>>51986874
JavaScript is essential in today's world, anon.
>>
File: 1449925874811.jpg (26 KB, 631x352) Image search: [Google]
1449925874811.jpg
26 KB, 631x352
>>51986940
>histomorphism
>>
>>51986949
http://stackoverflow.com/questions/24884475/examples-of-histomorphisms-in-haskell

It's a recursion scheme that allows you to access any of the values previously computed, which is what you need for O(n) fibonacci.
>>
How can I make this faster?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <setjmp.h>

#define DECLARE
#define BEGIN
#define END
#define STACK
#define PROGRAM
#define PROCEDURE
#define JMP_BUF(x) jmp_buf x;
#define JMP(x) longjmp((x), 1);
#define SETJMP setjmp
#define INT int
#define IF if
#define GOTO_(x) goto _ ## x;
#define GOTO(line) GOTO_(line)
#define VOID void
#define RETURN return
#define MAIN main
#define PRINT isalpha
#define DIG isdigit
#define _ (void)
#define INPUT getchar()
#define OUTPUT printf("%d\n",
#define VECTOR(x) (sizeof((x)) / sizeof(*(x)))

INT
PROCEDURE MAIN(VOID)
{
STACK DECLARE INT C;
STACK DECLARE JMP_BUF(J)
STACK DECLARE INT CN[5] = {0};
STACK DECLARE INT P = CN[1];
_100: BEGIN PROGRAM MAIN;
_115: P = 0;
_110: *CN = INPUT;
_120: IF (CN[P] == EOF) GOTO (250)
_130: GOTO (140)
_131: GOTO (260)
_140: IF (P[CN] == ' ' || CN[P] == '\t' || *(CN+P) == '\n') { P = 1; if (!SETJMP(J)) GOTO (230) }
_150: IF (PRINT(CN[P])) { P = 1 << 1; GOTO (190) }
_160: IF (DIG(CN[P])) { P = 3; GOTO (210) }
_170: _ (P = 4)[CN]++;
_180: GOTO (115)
_190: ++P[CN];
_200: GOTO (100)
_210: CN[P]++;
_220: GOTO (115)
_230: _ P[CN]++;
_240: GOTO (100)
_250: P = 0; GOTO (131)
_260: IF (!VECTOR(CN)) JMP(J);
_270: *CN = 0;
_280: IF (*CN == 4) GOTO (132)
_290: _ OUTPUT (++*CN)[CN]);
_300: GOTO (280)
_320: RETURN 0;
_132: END PROGRAM MAIN;
}
>>
>>51986922
>>51986949
fib(1): 1
fib(2): 1
fib(n): fib(n-1) + fib(n-2)

No for loops, only recursion
The first 2 base cases can be written as if statements.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>51986961
fib(8) using iteration: 1 1 2 3 5 8 13 21

fib(8) using recursion:
fib(8) = fib(7) + fib(6)
fib(7) = fib(6) + fib(5)
fib(6) = fib(5) + fib(4)
fib(5) = fib(4) + fib(3)
fib(4) = fib(3) + fib(2)
fib(3) = fib(2) + fib(1)
fib(2) = 1
fib(1) = 1
fib(3) = 2
fib(4) = 3
fib(5) = 5
fib(6) = 8
fib(7) = 13
fib(8) = 21

which is more elegant and useful?
>>
>>51986979
The histomorphism is what makes the recursive solution O(n). Recursion doesn't mean naive.
>>
>>51986922
>>
>>51987004
this tbqh
>>
>>51987003
it's still fucking disgusting because with iteration you don't have to memoize the previous function results
>>
>>51987035
The point of the histomorphism is that you don't explicitly memoize. Using the histomorphism, the definition of fib becomes very elegant:
fib = histo phi where
phi [] = 0
phi [_] = 1
phi (x : y : _) = x + y
>>
File: 1447563591402.jpg (461 KB, 1920x1080) Image search: [Google]
1447563591402.jpg
461 KB, 1920x1080
>>51986961
>>51986977
My friend told me recursion is bad because it stops working for high numbers.

>>51986979
Can't use for loops.

>>51987004
Danke!
>>
>>51987078
>histo
What package?
>>
>>51987112
>My friend told me recursion is bad because it stops working for high numbers.
In the strictest sense yes, but depending on the language and how much optimization is going on, this is nullified.
>>
>>51987078
the execution is still inelegant.
>it doesn't exist because i didn't explicitly mention it
fucking python babby

write out fib(n) on a piece of paper.
1 1 2 3 5 etc is how you do it. not that autistic math definition bullshit
>>
>>51987112
Some languages implement recursion in a way where that is not a problem.
>>
>>51986849
I've learnt the most from:

https://developer.mozilla.org/en-US/docs/Web/JavaScript

Than I have from any book or site tbqh.
>>
>>51987112
>My friend told me recursion is bad because it stops working for high numbers.

It stops working because you get a stack overflow from one too many function calls.

However, if the language/compiler is any good, recursive calls can be optimized into loops by the compiler itself.
>>
>>51987112
>My friend told me recursion is bad because it stops working for high numbers.
Recursion is usually implemented using a stack.
Whenever you call a function within a function a new stack frame specifically for that function will be created.
This can cause the stack to run out of space.
That is bad.
However that doesn't have anything to do with what numbers you input, but what you do with them since it's the recursion depth that matters.
>>
>>51987166
>However, if the language/compiler is any good, recursive calls can be optimized into loops by the compiler itself.
Tail recursion at most.
>>
>>51987166
if the programmer is any good, they can write loops in the first place.
>>
>>51987129
>depending on the language and how much optimization
>>51987166
>However, if the language/compiler is any good

Even Haskell and Scheme get stack overflows (although Scheme implementations sometimes use the entire heap for a stack).
>>
>>51986456
>>51986479
VS2015 supports up to C99, IIRC. Just Microsoft things, I guess.
>>
Learning python by making a script to shitpost with. It'll probably never get far enough to actually manage a post thanks to captcha but I'm having fun none the less.
>>
>>51986832
One day someone will respond
>>
File: 4chpython.jpg (71 KB, 694x825) Image search: [Google]
4chpython.jpg
71 KB, 694x825
>>51987335
oops
>>
>>51987250
Yes, but I said depending on the language and how much optimization.

C/C++/C#/Java almost always does tail call optimization where possible.

I don't think it's possible with fibonacci though.
>>
>>51987122
Off the top of my head, recursion-schemes and pointless-haskell. However, both are generalized beyond lists, and so require a somewhat different way of defining data structures to recurse over (as fixpoints of functors).

It wouldn't be hard to write a histo function that only works with built-in lists and integers, you can see a similar definition in the SO page I linked.
histo :: ([a] -> a) -> Int -> a
histo f = head . gen where
gen 0 = [f []]
gen n = let
memo = gen (n-1)
in f memo : memo


>>51987136
You're still doing memoization with the iterative approach. I mean, yes, with Fibonacci numbers you tend to only store the most recent two, and it's not like you can't write a specialized histomorphism to account for this.
data UpToTwo a = Zero | One a | Two a a
histo2 :: (UpToTwo a -> a) -> Int -> a

fib = histo2 phi where
phi Zero = 0
phi (One _) = 1
phi (Two x y) = x + y
>>
>>51987362
Nice, m8, post source.
>>
>>51987335
>CPU at 60c
Careful, anon. Better have a extinguisher around just in case.
>>
>>51987420
60C isn't even that bad. I wouldn't be worried until 80+.
>>
Here are three languages that rape C

Python
def avg(a, b):
return (a+b)/2

Haskell
avg a b = (a + b) / 2

Scheme
(define (avg a b)
(/ (+ a b) 2))
>>
>>51987438
That was idle? it's quite high if it were idle. I imagine compiling something(big, of course) would touch 90c.
>>
>>51986832
why not just
unsigned int avg(unsigned int a, unsigned int b)
{
return a / 2 + b / 2 + (a & b & 1);
}
>>
>>51987448
>haskeklel
>scheme
Why did you waste time learning memes?
>>
>>51987420
It's a first gen mobile i7 in a "desktop replacement" thinkpad. I'd be worried if it was any cooler than that.

>>51987408
http://pastebin.com/raw/ENcypTbk
It's no where near functional. I might finish scrolling through posts tonight and look at getting into replies for each thread tomorrow. The more I work on this the more the irony of displaying an imageboards through terminal increases.

I'm sure the code looks disgusting, I am very very new.
>>
>>51987362
You're the anon that was scraping 4chan.org for valid boards, right?
Nice to see it come this far, good work.
You could make a read-only 4chan browser I suppose.
>>
>>51987393
For fun, a definition of histo2:
histo2 :: (UpToTwo a -> a) -> Int -> a
histo2 f = result . gen where
result (One x) = x
result (Two x _) = x
cons x Zero = One x
cons x (One y) = Two x y
cons x (Two y _) = Two x y
gen 0 = One $ f Zero
gen n = let
memo = gen (n-1)
in cons (f memo) memo
>>
>>51987393
how is that even remotely as elegant as

int fib(int n) {
if(n == 0) {
return 0;
}

if(n == 1 || n == 2) {
return 1;
}

int a = 1;
int b = 1;

for(int i = 3; i < n; ++i) {
int m = a + b;
a = b;
b = m;
}

return a + b;
}
>>
>>51987448
by "rape C" you mean don't follow C-syntax?
>>
>>51987554
This is a joke, right?
>>
>>51987532
That's me, thanks. I finally wrapped my head around the api and found a better version of the python wrapper called basc_py4chan which has documentation I can understand.
>>
>>51987558
By rape I mean being able to compute an average
>>
>>51987393
>>51987550
>>51987572
fucking kill yourself
>>
PSA: VS2015 intellisense lets you type just the camel case parts of a name and it finds it for you

My productivity went up 1000%
>>
>>51987589
C can do it too and is "only" a couple of orders of magnitude faster
>>
>>51987589
It's a problem that affect any language with modular arithmetic. All of those meme languages you posted don't do that.
>>
>>51987592
all me
>>
>>51987448
These all round towards negative infinity, Haskells version doesn't work for
Integer
s and has the same issue as when averaging floats or doubles in other languages.

Can't say much about the other ones.
>>
>>51987643
>those amazing languages do not have that problem
Exactly!
>>
Anyone got the project roller?

Plz post I am bored. Or I will happily rip of someones idea they are too lazy too make
>>
>>51987676
>Haskells version doesn't work for
Integer
s
Oh also any other integer type
>>
>calling a float a real
>>
>>51987676
>These all round towards negative infinity
lmao seriously? that's fucking garbage
>>
>>51987679
Enjoy your high memory usage and slow computations.
>>
>>51987693
It's supposed to represent a real number, where's the problem?
>>
>>51987709
it represents a floating point number
>>
>tfw you're reading a shitty scanned version of a textbook that went through some processing to turn it into a pdf with text and about 5% of the text was indecipherable so the image of the text was substituted and all of the graphs and diagrams are distorted, sometimes unintelligible
>so you google the book again, maybe someone uploaded a better copy
>official pdf version second result
thank rms
>>
>>51987709
Then why does
0.1+0.2
not equal 0.3?
>>
>>51987737
Float represents floating point numbers, however it implements certain functions within the Real typeclass.
>>
>>51987693
>calling a single a float
>>
>>51987777
Because the implementation is imperfect, as in any language.
If you require arbitrary precision you can use Data.Ratio for rational numbers.
>>
>>51987798
>Ratio
What if I want to represent pi?
>>
>>51987250
Haskell gets stack overflows (pattern-match stack, not function call stack, which doesn't exist) because the RTS will by default kill your program if the stack gets too big. You can remove the limit because the "stack" is on the heap anyway. I don't know about Scheme.
>>
>>51987693
A float is a way of representing a real number. A language that calls it "real" probably prefers to think in terms of abstraction, ergo the type is supposed to represent a real, and is only coincidentally implemented with a float.
>>
>>51987825
You cannot using this datatype, however you could write your own abstraction that allows for pi to be calculated to any precision needed on the fly, or implement a CAS that can actually work with the symbol, not just the value.
>>
>>51987777
It does for single-precision floats in C, C++, and Java.
>>
UDP/IP stack for a platform without a C compiler ...
>>
>>51985878
would not call that a dialect
>>
>>51987912
its a troll
>>
>>51987910
What do you have then?
>>
This is more /sqt/ material, but figure there's OS people lurking here

Why aren't desktop OSes adopting the model Android and others have been using for running applications? What I'm talking about is that on those mobile systems manage the memory of the running processes automatically. Old processes get saved on permanent storage and uploaded back to RAM if needed again. Nothing needs to be closed. It's like garbage collection for your VM.

Also there's really no concept of "program instances" - when you click the icon of an app, you go to where you last were in that app, so app launcher and "task manager" are essentially the same which simplifies usage.
>>
>>51988363
because mobile devices are for one thing at a time and not serious work
duh
>>
>>51988363
What is swap?

Also I might want to run more than one instance of a program.
>>
>>51988363
no
>>
File: wheretostart.jpg (173 KB, 1366x768) Image search: [Google]
wheretostart.jpg
173 KB, 1366x768
Sorry to be such a newfag /g/

But where do I start from pic related? A friend of mine downloaded and copied 33 gigs worth of computer information, and mind you I've only built rigs in the past, never learned about computing theory, or programming.

I feel so...small....so lost in a sea of information, so incapable and weak.

I want to be a strong wizard /g/. Help.
>>
>>51987912
if it's true that go won't compile with an unused variable or function, not even in some debug/development mode, it's fucking ridiculous and disgusting
>>
>>51988363
that's how metro apps were prior to windows 10 and it was terrible
>>
>>51988585
>how do i read
>>
>>51988534
>swap
Still need to close and open windows, ie. manage them manually

>more than one
This is the only reason I can come up with, but it's not like every program wasn't using tabs or equivalent already so it would be gotten around fast.
>>
>>51988606
Could you say why? Didn't use anything newer than win7.

I would imagine if the taskbar was kept visible and showed your processes in most recent order it would be pretty close to traditional desktop
>>
File: sds.png (210 KB, 640x360) Image search: [Google]
sds.png
210 KB, 640x360
Great. Divided /dpt/s because OP didn't include "/dpt/" in the OP.

Janny should delete this one and we all move to:

>>51987642
>>51987642
>>
>>51988703
Too late, janitor kept the shit /dpt/.
>>
>>51988703
ayy the jan is awake
>>
you're supposed to put /dpt/ so that our shortcuts work, dumbfuck
also you spelled daily wrong
>>
>>51988789
>>51988792
Shame, he deleted the wrong one.

There will be a load of people that search for /dpt/ in the catalog and assume a /dpt/ thread doesn't exist.
>>
File: yee.jpg (130 KB, 1366x768) Image search: [Google]
yee.jpg
130 KB, 1366x768
/g/ where do I start?

I want to program simple games to make a decent living while going to school to learn about advanced haptics, bio tech, etc. some immortality tier shit senpai therefore I'm thinking c sharp because mac cucks are easily entertained and buy shit for the sake of being cool, ergo a simple game would sell well, yes?
>>
Anyone got the programming tasks for noobz link/info?
>>
>>51988835
take a class at your uni, java works fine
>>
>>51988850
C Primer Plus by Stephen Prata
>>
>>51988816
top kek
>search for dpt
>nothing
>search for daily
>nothing
>>
>>51988835
>I want to program simple games to make a decent living
kek
>>
File: sfsdfsds.jpg (32 KB, 819x276) Image search: [Google]
sfsdfsds.jpg
32 KB, 819x276
I need to do pic related. Keep in mind that each button will have an actionListnener.

Where did I fuck up. It nearly worked a few step back but now everything is fucked up.


import javax.swing.*;
import java.awt.*;
public class Fenetre extends JFrame
{
public Fenetre(String titre)
{
Container c = this.getContentPane();
c.setLayout(new BorderLayout());

Resto rest = new Resto();
JTextArea txt = new JTextArea();
JPanel pan = new JPanel();
JPanel pan2 = new JPanel();
c.add(txt);
c.add(pan, BorderLayout.NORTH);
c.add(pan2, BorderLayout.SOUTH);


setSize(600,300);
setTitle(titre);

JButton com = new JButton();
c.add(com("Prenez une commande"), BorderLayout.WEST);
com.addActionListener(this);

JButton aff = new JButton();
c.add(aff("Afficher la carte complète"), BorderLayout.EAST);
aff.addActionListener(this);

JLabel haut = new JLabel("Type de plat ?");
JButton bas = new JButton("Quittez l'application");
bas.addActionListener(this);

pan.add(haut);
pan.add(new JButton("Plat Chaud"));
pan.add(new JButton("Plat Froid"));

pan2.add(bas);

this.setVisible(true) ;
}

public static void main (String arg[])
{

Fenetre fen = new Fenetre("Gestion des contrats de l'entreprise");



}
}

>>
>>51988869
I want to use Clojure, not some 70s meme language
>>
>>51988833
>Shame, he deleted the wrong one.
This one has more discussion though, discussion is what's important. Discussion about... averaging 2 ints. Also it's older.

>There will be a load of people that search for /dpt/ in the catalog and assume a /dpt/ thread doesn't exist.
No they don't, they'll just have to look for it

>>51988879
exactly. I'm not watching anime because I find it awkward. Watching Downton Abbey though.
>>
>>51988835
no your uninspired, lazy garbage will not sell well. you'll get like 1000 downloads at most for a free game
>>
>>51988897
can I have all of your code? Like where is resto()
>>
File: haskelltan.png (514 KB, 810x698) Image search: [Google]
haskelltan.png
514 KB, 810x698
Reminder that Haskell is the best language
>>
>>51988935
Bernie, he's the only one who cares about internet privacy.
>>
>>51988897
Just do it in netbeans or some shit. Litterally take you a minute
>>
File: 1448690262398.png (1 MB, 958x598) Image search: [Google]
1448690262398.png
1 MB, 958x598
>>51988935
trump

https://www.youtube.com/watch?v=F33n_rAXBHA

https://www.youtube.com/watch?v=MioIksr8i00

https://www.youtube.com/watch?v=nLRbW6NRbfI
>>
>>51988864
>>51988885
>>51988918
Sorry anons my reply was deleted for no reason.

Anyway, so Java instead of C#, hmm. Any particular reason? Also not in Uni, can't afford right now, had a mental break down. Poor fag baka desu senpai ;_;
>>
>>51988953
oh actually nevermind I'd just rather not deal with code in french
>>
>>51988977
>Java instead of C#, hmm. Any particular reason?
They're pretty much interchangeable, but C# tends to be more convenient in many cases. Use Java if you want your programs to work outside of Windows.
>>
>>51988977
java is a lot cleaner than C#. even if you decide to pick up C# later it's a lot easier to go from java to C# or any other C-like language than to go from C# to java or any other C-like language
>>
>>51986922
fib = fibAux 0 1
where
fibAux a _ 0 = a
fibAux a b n = fibAux b (a + b) $ n - 1
>>
>>51988999
C# is supported officially on OSX and Linux platforms now, and has had Linux support in Mono since forever.

>>51989003
>java is a lot cleaner than C#
Hahahahaha how
>>
>>51985409
Terry?
>>
Anyone know how to get through an exe that has multiple pauses/input times? Google and stackoverflow doesn't have answers for me this time.
@echo off
del temp.txt
for /r %%i in (*.jpg) do (
steghide.exe --info %%i >> temp.txt
gosub errorhandling
)
for /r %%i in (*.jpeg) do (
echo %%i
)

:errorhandling
if errorlevel 1 (
errorlevel >> temp.txt
) else (
echo y
echo
)
return
>>
>>51989018
epic fucking meme Cshart. you know C# has more pointless little features with inconsistent syntax while java has a simpler and more consistent syntax.
>>
>>51989018
No it's not. C# does't even have correct GUI (turns purple) with mono, or at least on all my arm devices.
>>
>>51989036
>inconsistent syntax
Give some examples.

>java has a simpler and more consistent syntax
The syntax is basically exactly the same for every feature except lambdas/LINQ. You dot into objects and bracket into collections.
>>
File: 1450591117612.png (413 KB, 2881x1620) Image search: [Google]
1450591117612.png
413 KB, 2881x1620
>>51988999
Is it because Java runs on JVM, which means so long as a machine can run the JVM it can run any Java program? I'm just learning concepts right now.

My goal will be making apps for android then, think I'll be able to make an app that counts down to season changes (and looks semi-pretty) within a few months?

>>51989003
Alright, I'll take your word anon, seem to know what your doing.

Gonna get reading. The only thing I can offer in return for help is where I got my books from.

http://g.sicp.me/books/
>>
>>51988964
I'm doing it for school. I know I can do it in Netbeans but I'm forced not to.

>>51988953
Here's a download link from ou school website but I'm not sure if you'll be able to download the files.
http://www.forminfo.be/moodle29/mod/resource/view.php?id=2721
>>
>>51989030
is that MSDOS?
Is there a command like a scanner or cout?
>>
>>51989036
what you call inconsistent syntax, others will call syntactic sugar
>>
>>51989048
Have you given the official Linux build process a try? I'm not speaking from experience, not claiming Microsoft's xplat is actually good, but it is at least "officially supported."

>>51989079
>seem to know what your doing
Top kek
>>
>>51989018
>C# is supported officially on OSX and Linux platforms now, and has had Linux support in Mono since forever.
You know Mono is nowhere near the support big Java IDEs/compilers have

>Hahahahaha how
It's kind of true though, C# has a lot of cruft on top of Java. It's convenient, and it has many very good features, but C# is to Java a bit what C++ is to C.
>>
>>51989104
>Hating your clients for a language
k
>>
>>51989079
I'd say check out the available IDEs for both (eclipse and that free visual studio version are good candidates) and see which you prefer. It doesn't matter much with which one you start with, though you could argue that Java is a bit more "bare" than C#.
>>
>>51989092
MSDOS isn't C++.
I tried echo, but it isn't working. The exe demands inputs before I can hit the subroutine.
>>
Oh, one thing about Java vs C# is that java docs are god like compared to C#. One of the best language docs of the ones I've seen
>>
>>51989098
>syntactic sugar
(defun trash (resume)
(setf (get 'location resume) (in trash)))
(trash it)
>>
File: 1450124211905.jpg (83 KB, 374x720) Image search: [Google]
1450124211905.jpg
83 KB, 374x720
>tfw I will never learn how to program in HTML
>>
http://strawpoll.me/6332632
>>
>>51989226
that's because you can't program in html :)

>inb4 some autist brings up script tag and whatnot
>>
>>51989243
Simply because the JVM isn't as terrible as the CLR.
>>
>>51989243
I voted incorrectly just to spite you
>>
Seriously people... how do you get employed and/or how do you do freelance?
Do these challenge websites help finding job opportunities if you are good enough?
I look at the projects list in freelance.com, and it makes me feel like shit... there are lots of things that I doubt I'll be able to do, and LOTS of people bidding to each project :(
>>
Any opinions on the best approach for creating cross-platform software?

I want to use C so I was thinking go along the lines of the MVC approach. Use C for the core program (model/controller I guess) and GTK for the GUI.

I want to hear any theories or opinions. This isn't something I'm doing at the moment, but I want to give it a lot of thought before I start any big projects that I would actually want to finish.
>>
Do you get fucked up in the head from staring at a screen everyday?

https://strawpoll.me/6332673
>>
File: oo.png (899 KB, 1600x901) Image search: [Google]
oo.png
899 KB, 1600x901
>>51989255
HTML with CSS is gay cunt complete.
>>
>>51989295
>best approach
>no theories or opinions
>>
>>51989295
Use libraries with system agnostic bindings.
>>
>>51989322
apparently https://github.com/elitheeli/stupid-machines/tree/master/rule110

I have no idea how though, and I'm not gonna start reading that
>>
>>51988980
Just tell me where I fucked up.
>>
I'm creating a xml system to use in my other projects for configs. There's one question I've been facing since I started programming C++. Should I use exceptions or just make it silent + error logging? I mean it's obvious with xml. But is there any benefit to making it silent with other stuff?
node node::operator[](size_t index)
{
if(index > this->nodeCtr)
throw domain_error;
return this->nodes[index];
}

or this
node node::operator[](size_t index)
{
if(index > this->nodeCtr)
{
index = this->nodeCtr-1;
log("out of bounds");
}
return this->nodes[index];
}
>>
>>51989327
>I want to hear any theories or opinions.
>any

i think you misread
>>
>>51989295
program to a C standard and only use the standard library.

if you use gcc/clang, add -std=cXX -pedantic to your compiler flags.
>>
>>51989420
I have no idea, I couldn't access the files you linked and I'm not familiar with the swing library besides
>>
asdf
>>
>>51989515
meme
Thread replies: 255
Thread images: 28

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.