[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: 29
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>53721251

What are you working on, /g/?
>>
>>53726474
First for D
>>
how do i stop being a huge weeaboo /g/?
>>
>>53726488
get a job
>>
>>53726488
why do you want to?
>>
>>53726488
/dpt/ is the only good thing on /g/

Stop visiting the rest of /g/
>>
>>53726488
Simple you pick up a real man's language called Java. I don't even watch anime or care for it but I enjoy programming in Java drinking tea
>>
>>53726326

Reminder that we still havent gotten the assignment.
>>
File: 1425318106132-2.png (641 KB, 1000x801) Image search: [Google]
1425318106132-2.png
641 KB, 1000x801
Can you finish this function, /g/?
bool is_odd(int n) {
// code here
}
>>
>>53726540
Your not real anon, what part of 0 don't you understand?
>>
File: cute anime pic 0627.png (148 KB, 418x310) Image search: [Google]
cute anime pic 0627.png
148 KB, 418x310
Is it a bad idea to write a h2testw implementation using the rand() function in C?
It seems to work as intended if I use the same seed value for both the write and verify stages.
>>
>>53726554
bool is_odd(int n)
{
return n % 2 != 0;
}
>>
>>53726554
return ( !(n % 2) );
>>
>>53726554
bool is_odd(int n) {
return (n / 2) * 2 != n;
}
>>
>>53726554
Easy!
if (n == 1 || n == 3 || n == 5 || n == 7 || n == 9)
return true;
else
return false;
>>
>>53726554
if(n==1)
return true;
else if(n<0)
return is_odd(n*-1);
else
return is_even(n-1);
}
>>
>>53726554
return n & 1
>>
>>53726554

bool is_odd(int n)
{
return n & 1;
}
>>
>>53726554
bool is_odd(int n) {
return here's your (you);
}
>>
>>53726571
yes

>>53726572
no

>>53726583
>>53726591
kek

>>53726596
no

>>53726603
no

>>53726606
thanks
>>
>>53726514
this tbqh famalam
>>
>>53726554
return n&1;

best code golf kek
>>
>>53726612
>no

You do realize >>53726596
>>53726603
are the fastest, right? Modulo is an expensive operation while bitwise anding is extremely fast.
>>
What language should I attempt to learn?
>>
>>53726612
>>53726603
>>53726596
Faggot these are right

There is no need for a comparator

Test in code if you don't believe me
>>
>>53726631
your stupid bitwise autism hack doesn't work on big endian systems

also, your compiler is going to optimize that modulo into a bitwise anyway.
>>
>>53726631
>>53726628
>>53726642
>muh signed bitwise

I hope your CS degree was mail-order
>>
Fibonacci sequence is defined as follows:
F1 = 0, F2 = 1. For each i > 2: Fi = Fi - 1 + Fi - 2.
So the sequence starts with 0,1,1,2,3,5,8,13, ....

Your goal is to find the last digit of the nth number in this sequence, i.e. find F(n) mod 10.

Example

LastFibDigit(1) = F(1) mod 10 = 0 mod 10 = 0
LastFibDigit(2) = F(2) mod 10 = 1 mod 10 = 1
LastFibDigit(8) = F(8) mod 10 = 13 mod 10 = 3

[input] integer n
1 ≤ n ≤ 109.

[output] integer
The last digit of the nth Fibonacci number.



int LastFibDigit(int n) {

}



Are you good enough /g/ to finish this programming challenge?
>>
>>53726496
I did this, hasn't helped me.
>>
File: loliscripotexample.png (15 KB, 1304x393) Image search: [Google]
loliscripotexample.png
15 KB, 1304x393
>>53726633

loliscript
>>
>>53726652
In Java that matters, not anywhere else tard.
>>
>>53726663
JESUS CHRIST SENPAI
>>
File: smug.png (36 KB, 268x237) Image search: [Google]
smug.png
36 KB, 268x237
>>53726666
>he thinks little-endian 2's compliment is in the language spec
>>
>>53726652
>>53726649
Wow, look at all this wrong.

C/C++ must use:
1) two's complement
2) one's complement
3) sign magnitude

all of these implementations result in the program working :^)

endianness has literally nothing to do with this. you don't understand C if you think it does.
>>
>>53726698
>C/C++ must use:
>1) two's complement
>2) one's complement
>3) sign magnitude

Citation needed
>>
File: fight_kick.png (17 KB, 966x492) Image search: [Google]
fight_kick.png
17 KB, 966x492
>>53726680
>>
>>53726612
So what's your rating on the recursive one? Transcendent?
>>
so averaging two ints is too hard, we must first figure out how to properly check if number is odd
>>
>>53726682
cast to unsigned int

Problem solved

unsigned int isOdd(int i);

int main(){
int de = -1;

printf("%i", isOdd((unsigned int) de));
}

unsigned int isOdd(int i){
return i&1;
}
>>
File: Screenshot_2016-03-27_23-26-43.png (10 KB, 441x444) Image search: [Google]
Screenshot_2016-03-27_23-26-43.png
10 KB, 441x444
>>53726656
Where's my prize?
>>
>>53726712
ISO C (C99), section 6.2.6.2/2

now back to your cuckshed
>>
>>53726656
def last_fib_digit(n):
if n < 2:
return n
else:
return int(str(last_fib_digit(n-1) + last_fib_digit(n-2))[-1])
[/code]
>>
>>53726732
works 100% of the time

get niggered
>>
>>53726753
Enter 50 for me m8
>>
>>53726732
But honestly if you're using negative numbers in a program, you're doing it wrong.
>>
>>53726554
if(n / 2 == 0){ return true;}
if(n / 2 == 1 { return false;}
else return false; // an error occured


are you actually retarded?
>>
>>53726726
which one?

>>53726732
no

>>53726738
sign-magnitude and one's compliment don't work with your bitwise trick

e.g. in ones' complement 5 & 1 is 1111 1111 1111 1010 & 0000 0000 0000 0001 which is not 0
>>
>>53726763
cmon man, it's python. it'll take a couple hours.
program looks frozen atm
>>
>>53726663
your a sick fuck anon
>>
>>53726773
>not using negative values as errors
>not using a negative number as an index
>>
>>53726779
meant -5
>>
>>53726779
meant IS 0, god damnit
>>
>>53726721
do shota script too anon
>>
>>53726663
>>53726721
make a github pls
>>
>>53726833
>s/she/he/g
>s/pussy/boy pussy/g
>>
>>53726753
RuntimeError: maximum recursion depth exceeded
>>
>>53726853
just iterate instead of recursing
>>
>>53726779
>no

Good argument. It works 100% of the time

unsigned int isOdd(int i);

int main(){
int de = 5;
for (; de > -10000; --de) {
printf("%i", isOdd((unsigned int) de));
}
}

unsigned int isOdd(int i){
return i&1;
}
>>
My friend's telling me that C is better than C++ because it's what Torvalds uses and Boost and STL are unstable. Is this true?
>>
>>53726871
Yes
>>
>>53726779
bool is_odd(int n)
{
if(n==1)
return true;
else if(n<0)
return is_odd(n*-1);
else
return is_even(n-1);
}

bool is_even(int n)
{
if(n==0)
return true;
else if(n<0)
return is_even(n*-1);
else
return is_odd(n-1);
}


>>53726753
Not tail call optimizable and you forgot to preform a mod 10 operation on the last line.

But does python even do tail call optimization?
>>
>>53726871
no
>>
>>53726871
Linus uses C because it's the best for the Linux kernel
>>
File: loliscript2.png (29 KB, 1106x782) Image search: [Google]
loliscript2.png
29 KB, 1106x782
>>53726801

Hey, would you rather I scripted the dialogue inside of the C++ code?

What I'm doing with the outcomes is that it treats the attributes as vectors in the vectorspace of all attribrutes with all unspecified ones as some default expected value, and then sees which vector has the shortest L^2 distance to the loli's attribute vector to determine which outcome matches her attributes the most.

Also this way people can mod in more dialogue without even needing the game's sourcecode/to compile while still getting the freedom to embed code in result {}.

>>53726833

So loliscript with a penis keyword?

>>53726846

Pretty sure it'd get flagged by SJWs pretty fast.
>>
>>53726871
In this day and age who gives a shit. Boost is a fucking mess though.
>>
>>53726891
do i have to do a mod 10? its the right answer anyway.
also neither python nor c++ is cooperating in computing the 50th fib number so i googled it

>>> int(str(12586269025)[-1])
5
>>
>>53726906
You need mental help and to seek a therapist right away t b h f a m
>>
>>53726779
fair catch with one's comp -- i'm getting ahead of myself correcting people who think endianness matters

>>53726866
you forgot to change isOdd's param type to unsigned int
>>
>>53726496
>Get a job
>Spend all money on figmas and dakis
>>
>>53726663

loliscript would be a scripting language through the medium of a loli syntax. this is just a script that happens to involve "lolis". please correct this.

onto the watchlist we go
>>
>>53726939
also doesn't work with sign/magnitude
>>
>>53726949
> a scripting language through the medium of a loli syntax

..what exactly would this look like?
>>
>>53726928
Yes you have to because 8 + 3 = 11 !< 10 and those recursive calls might return 8 and 3 for example.

Try upgrading to longs. I'm having trouble reading that but it looks like 12 billion which is larger than a 32 bit int's size.
>>
File: Screenshot_2016-03-27_23-42-55.png (9 KB, 490x407) Image search: [Google]
Screenshot_2016-03-27_23-42-55.png
9 KB, 490x407
>>53726656
>>53726736
Fixed, but it only works for n <= 93
I guess unsigned long long just isn't enough
#include <stdio.h>

unsigned long long int fib(unsigned long long int a, unsigned long long int b, int n)
{
if(!n)
{
return a;
}

return fib(b, a + b, n - 1);
}

int main(void)
{
int n;

printf("Enter n: ");
scanf("%d", &n);

printf("Answer: %llu\n", fib(0, 1, n) % 10);

return 0;
}
>>
>>53726949
Terms of art transcend their grammatical meaning though, so it's all cool.

>>53726991
Use a bignum library then, or use a real language which, with the right flags, silently falls back to bignums.
>>
>>53726954
it's implementation defined. the standard doesn't require that the unsigned 1 bit be the sign bit
>>
>>53726991
fib recursion is fucking cancer. So many threads.
>>
>>53726871
your friend is wise, most wise

but tell him D is better still
>>
>>53727018
>recursion
>threads
lol recursion doesn't generate threads, and that's tail call optimizable so it's not compiled to recursion you webdev.
>>
>>53727005
>Use a bignum library then
Eh, I'll wait until I do a more important project that requires it
>>53727018
>implying no TCO
>>
>>>/pol/69074298
>ITT boomers who actually think their algebra classes are anywhere near the modern ones.
You know that SAT/ACT test changes every year, and the people there just love adding new equations right?
Because confusing people with problems such as
>simplify.
>(3^2/x^4+x+5)+(48/x^2+x+3)-(5^7/x^4)=4+7^2/x-2
Go ahead and simplify that rational expression boomers :^)

>not being redpilled on useless algebra like based /pol/
>>
you think highschool algebra's easy?
answer this, assholes >>>/pol/69074658

protip: you can't. this is what highschool algebra's REALLY like nowadays. you don't know what we're going through.
>>
>>53727110
Hello /pol/

So you think algebra is useless huh?

>>53727144
So you don't know the difference between algebra and calculus huh?
>>
>>53727144
That's Calc
>>
>>53727110
>>53727144
what are you doing here

If you don't think algebra's a breeze then gtfo
>>
>>53725887
backend is in Ruby (sinatra, but it's pretty much a one-page application)
>>
>>53726474
I'm working on a programming language, because I hate myself and love pain. Also I wanna learn Scheme
>>
>>53726488
Wee on another country's culture?
>>
>>53727039
Sorry, a shit load of stack frames.

It's still cancer.
>>
I'm learning haskell, and I'm confused

learn you a haskell has this

addThree :: Int -> Int -> Int -> Int
addThree x y z = x + y + z


which makes sense. Take three ints and get one out

I tried to write

mod3 :: Int -> Bool
mod3 x = x mod 2 == 0


which takes an int and sends out a bool, but I get an error when I try to run it.
>>
>>53727210
>He doesn't know about TCO
>>
>>53726776
shouldn't this be nested?
>>
>>53727210
>tail call optimizable
Even if your tail call optimization was trampolining, which it isn't for gcc, then that wouldn't matter because such small stack frames are almost free.

You should probably learn about recursion before you shitpost about recursion.
>>
>>53727233

How are you going to do that with fibonacci? If you're going to do it recursively then just use memoization, but TCO isn't going to help you as one of the two calls will not be a tail call.
>>
>>53727225
that should say x `mod` 2 == 0
or mod x 2 == 0
>>
>>53727252
Look at his function you nigger. It ends in a tail call or a parameter return in either case.
>>
>>53727245
if(n / 2 = 0){ 
return true;
if(n / 2 = 1) {
return false;
else return false; // an error occured
}
}



happy, nerd?
>>
>>53727260
what's the difference between x mod 2 and mod x 2?

they both seem to output the same thing at first glance.
>>
>>53727252
>How are you going to do that with fibonacci?
Exactly as I wrote it plus -O2
>>
Give me problem, I'll try to write code for it in c.
>>
>>53727304
just a second, I need an answer to this one. It's been bothering me for like half a year
>>
>>53727304
average 2 ints
>>
>>53727299
>>53727281

I didn't read his code and just assumed fib(n -1) + fib(n-2), not writing the iterative style of fib as a recursive function.
>>
>>53727304
Write a C tail call optimizer that takes C code and trampolines all the tail calls.
>>
>>53727319
int average(int a, int b) {
return (a / 2) + (b / 2) + ((a % 2) + (b % 2)) / 2;
}
>>
>>53727297
x mod 2 is an error.
most functions in haskell are called with prefix notation. only binary functions (ones that work with 2 arguments) can be called infix, and you have to use backticks to make them work
>>
>>53726572
why doesn't this work?
>>
>>53727304
http://pastebin.com/HhG4617W

I have python code that your code must be algorithmically better than, if you want that.

Let me know if you're taking this on.
>>
File: 1441684460338.jpg (92 KB, 1280x720) Image search: [Google]
1441684460338.jpg
92 KB, 1280x720
>>53727005
>silently falls back to slownums
>>
>>53727347
condensed:
int average(int a, int b) {
return (a / 2) + (b / 2) + (a % 2) * (b % 2);
}
>>
made a makefile to compile sqlite3 statically, all comments are welcome
CC=gcc
CFLAGS=-I. -Wall -Werror -Os
OBJS = sqlite3.o
AR = ar -cvq

.PHONY: all clean

libsqlite3.a(sqlite3.o): sqlite3.o
$(AR) $@ $%

all: libsqlite3.a

clean:
rm -f *.o *.a
>>
>>53727363
huh I coulda sworn "3 mod 2" worked when I was testing things out. oh well, thanks for the help
>>
>>53727373
>flag
>something you can enable or disable
>>
>>53727347
pro stack overflow skills you got there
>>
>>53727384
>setting CC
>>
>>53727394
its literally the most obvious b8 question you could ask

[spoiler]
i saw the condensed version in >>53727383 when i googled to check my work though
[/spoiler]
>>
>>53727319
 int a,b,c;
printf("enter two integers\n");
scanf("%d",&a);
scanf("%d",&b);
c=(a+b)/2;
printf("average of two numbers is %d\n",c)
>>
>>53727225
This is unrelated, but what on earth is mod3 supposed to do?

It definitely isn't a curried modulus = 0 operation, because mod3(2) returns true
>>
Hey guys, nigger programmer reporting in.
Do you prefer to do,
int some_function(int x, int y) {
result = x + y;
return result;
}

or
int some_function(int x, int y) {
return x + y;
}

Is one more optimized than the other?
>>
>>53727401
clang?
>>
>>53727432
>Is one more optimized than the other?
They'll run equally fast with a modern compiler. Stylistically, I prefer the second.
>>
>>53727432

'The compiler will optimize the first into the second anyway.
>>
>>53727432
the latter
The compiler while compile it to the same shit, so they're the same speed.
>>
>>53727449
>>53727450
>>53727454
Good to know fellow niggers. Thanks, and have a nice day
>>
>>53727193
I bet my gut it's the GC. Maybe pick a compiled language with no/smaller pauses?
>>
>>53727431
>>53727431
I typo'd, it's supposed to be a function to determine if a number is divisible by 3 for use in a filter later, I was going to add to it for divisible by 3 or 5 to get

mod3or5 :: Int -> Bool
mod3or5 x = mod x 3 == 0 || mod x 5 == 0


as my final function, once I got the basic version working
>>
>>53727444
Let the user decide what compiler they want to use. You NEVER have to set CC
>>
>>53727488
unless you're using gcc only features
>>
File: Denise_Milani_Wallpaper.jpg (118 KB, 1600x1200) Image search: [Google]
Denise_Milani_Wallpaper.jpg
118 KB, 1600x1200
>>53727110
>7^2/x-2
Expression is already false for x = 2
>>
>>53727532
>undefined
>is the same thing as false
Lol
>>
>>53727553
My b
>>
>>53727553
the other one isn't undefined for x = 2, so that means it's false
Lol
>>
>>53727480
I'll profile the GC to look into it. If it's the case, I guess I'll have to switch. Any recommendations for such a language? I'd use Nim (for better GC control) but it has shit for websockets support.
>>
>>53727401

Personally, I always set CC in my makefiles. If I don't, I get an error like this:

process_begin: CreateProcess(NULL, cc foo.c -o foo.exe, ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2
>>
this is probably the wrong place to ask this, but how do i go about learning how to code? my life is spiraling out of control and i'd like to do something constructive with it -- maybe learn how to code an app for android. how should i go about starting? all i have right now is a shitty macbook a friend gave me a while back from 2011. the wiki has a bunch of books to look at but there doesn't seem to be instructions on learning how to code in C or python and what not. please, i just want to learn
>>
>>53727584
Oh really?
https://www.wolframalpha.com/input/?i=%283^2%2Fx^4%2Bx%2B5%29%2B%2848%2Fx^2%2Bx%2B3%29-%285^7%2Fx^4%29%3D4%2B7^2%2F%28x-2%29
>>
>>53726474
main = do
d@[j:jobs] <- findJob
if (null d)
then killSelf
else (highestSalary d >>= apply)
>>
>>53727709
>foo.exe

found the problem
>>
>>53727704
Go, C++, Erlang, Elixir. The latter has Ruby-ish syntax, if that is to your fancy.
>>
File: lrg.jpg (126 KB, 500x578) Image search: [Google]
lrg.jpg
126 KB, 500x578
>>53727784
maybe pic related could help
>>
>>53727882

>Implying Windows is not a valid target for compilation
>>
>>53727784
Pick up a book.
>>
>>53727110
>>(3^2/x^4+x+5)+(48/x^2+x+3)-(5^7/x^4)=4+7^2/x-2
that's not an expression, it's an equation

and just plug it in to mathematica to simplify it
>>
>>53727903
It's rather a valid target for a nuclear bomb
>>
>>53727903
>building anything that isn't C# on Windows
senpai...
>>
>>53726656
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
lastDigit n = last (show n)
lastFibDigit nth = lastDigit (fibs !! nth)


output
> lastFibDigit 110
'5'
it :: Char
(0.01 secs, 0 bytes)
> fibs !! 110
43566776258854844738105
it :: Integer
(0.00 secs, 0 bytes)


also, do your homework
>>
>>53727970

What about games? Should be using C++, preferably built with g++ and not MSVC++.
>>
>>53727995
XNA :^)
>>
>>53727995
>P-please make games for Linux, I'll take anything at this point
>>
Why doesn't C have a primitive data type specifically for binary?
>>
>>53727888
Looks like it was the gc, too. Damn, I should have known better than to choose ruby.. guess it's time to learn some Erlang
>>
>>53728023
You mean unsigned char?
>>
>>53728006
shit
>>
>>53728023
because it's the same thing as unsigned char or uint8_t
>>
>>53728023
unsigned
>>
>>53728034
Could you do something like this?

unsigned char bin = 0b01001101;


What would this output?
>>
>>53727485
you use x `mod` 3 because adding backticks makes it an infix function
for example (+) is an infix function (by default)
e.g. 3 + 2, you can do (+) 3 2, and it'll work too
infix means in the middle, and only works with functions that take two inputs (aka binary functions)
>>
>>53728061
w
>>
File: image_27.jpg (62 KB, 640x563) Image search: [Google]
image_27.jpg
62 KB, 640x563
Should I read SICP or HTDP to start off in computer science/programming when I have literally no experience
>>
>>53728095
ehhhhhhhhhhhhhhhhhhhhhhhhhhhhh if you can understand SICP then all power to you.

Usually it's read by experienced programmers. *Usually*
>>
>>53727284
everything after return true; won't execute
>>
>>53728095
Go with HTDP m9
>>
>>53728061
If you
printf("%02x", bin);

output: 4d
>>
>>53728006
XNA is dead Anon. It's no longer under active development.

>>53728021
Who said anything about Linux? You can very easily develop proprietary, Windows-only applications using g++. I won't argue for the use of g++ from a point of view of portability, although that is certainly one of its strengths. I'll argue for g++ because it's a better compiler than MSVC++.

But go ahead and say it's acceptable to not support SFINAE or extended constant expressions in 2016. It is the current fucking year. Why doesn't MS support all of the C++14 and C11 standards?

>>53728061

Perfectly legal. Why would C have a problem with binary literals?
>>
>>53728095
SICP is a bit of an advanced book. MIT used to use it as an intro to programming book, but now they use it as a textbook for a graduate level class.

If you're a mathfag then read SICP.
>>
>>53728176
>but now they use it as a textbook for a graduate level class
Do they really?
I mean, SICP isn't easy, but I didn't think it was that hard.
>>
>>53728190
It's not that hard, it's just the information it has isn't exactly relevant to the average compsci.
>>
>>53728176

>SICP in graduate level classes
Should I actually bother to read SICP now? I already pretty much know Scheme.
>>
>>53728209
You will either love or hate Lisp by the end of it.

In any respect, go for it. Everyone I know who reads it says it changes the way they think about programming.
>>
>>53728190
Well it's a book about very abstract theoretical computer science.

The average freshman isn't going to get anything out of the book.

>>53728209
It's a pretty cool book but I'm also a mathfag.
>>
>>53728209
Does:
>rewriting eval so that Scheme becomes Lazy
>writing a computer algebra system
>learning how to numbers and data structures with only lambda calculus and no concept of numbers
>learning programming styles that won't be efficient until quantum computers come out
>building register machines
interest you? These are a few of the topics in SICP
>>
>>53728246

>I'm also a mathfag
Hey, you know anything about hyperoperations? Do you know if it would be acceptable to use something like n ↑↑ 0.5 to indicate something like a super square root? I know n ↑↑ k is basically tetration, but I'd figure if n ↑ 1/k undoes n ↑ k (fractional powers in exponentiation equivalent to roots), I want to say the same is true for tetration, pentation, etc... I am not sure if this is correct, however, and have seen nothing in searches to suggest that such a notation is used.
>>
>>53728286

Sounds like something I could do for fun when I have some time (why does tomorrow have to be my last day of Spring break?).
>>
>>53728312
I don't know the properties of n up up x. I highly doubt n up up 0.5 is the inverse of n up up 2 though. x^0.5 being the inverse of x^2 happens because of properties of fields.
>>
File: tetration.png (6 KB, 467x462) Image search: [Google]
tetration.png
6 KB, 467x462
>>53728357

All I've been able to find out about n ↑↑ x is in pic related.

It's called Knuth up arrow notation, and I know no way of representing higher order square roots (i.e. ssqrt(n)) with it.
>>
>>53728487
Yeah I know.

To have that property you're wondering about,

x up up 2 up up 05 = x, you'd need something similar to a logarithm for that to happen. In other words you'd need (R,*,up up) to be a field. It also begs the question of what the fuck n up up 0.5 would look like.

See if (R, *, up up) is a field.
>>
>>53726871
C is better than C++ is a meme is a myth
>>
>>53728525
>>53728487
Well to answer you, the answer would be no.
http://www.wolframalpha.com/input/?i=%282^2%29^%282^2%29^%282^2%29%3D2^2^2^2^2^2


>>53728547
C++ is overdesigned and bloated; it's syntax is pure evil. C isn't a replacement for C++, but C still does C's job better than C++ does C++'s job.
>>
>>53728563
C syntax is logical if you know what a computer is doing under the hood. Evil syntax is Java's domain.
>>
>>53728487
I'm guessing the answer you're looking for is a super logarithm

https://en.wikipedia.org/wiki/Super-logarithm
>>
>>53728668
Calling that thing a logarithm is a little deceptive. it's not even remotely similar to a logarithm in properties.
>>
>>53728682
on the other hand it looks to be the inverse of kunth arrows.

you also have super roots if you like
https://en.wikipedia.org/wiki/Tetration#Super-root
>>
>>53728668

Not the same as a super square root though. Super logarithms use Knuth down arrow notation, but super roots lack any standard notation.
>>
>>53726656
fib_mod10(n):
a, b = 0, 1
for _ in range(n):
a, b = b, (a+b)%10
return a


All the other solutions in this thread are stupid in one way or another.
>>
>>53728717
logs and roots aren't the same, so why would slogs and sroots be?

as far as standard notation goes, I assume there's a lack of it because of lack of practicality in using kunth arrows to begin with. There aren't many numbers that you would find anywhere and also need to represent with a kunth arrow, even in mathematics.
>>
>>53728798

>[input] integer n
>1 ≤ n ≤ 109.

this can be optimized

def fib_mod10(n):
return [0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7, 0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9, 0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3, 0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1, 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7, 0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9, 0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3, 0, 3, 3, 6][n]

>>
>>53728864
this doesn't look right.
>>
>>53728864
correct that to n-1 because the question is stupid and states f(1) = 0
>>
>>53727978
>lastDigit n = last (show n)
could do mod 10 instead
>>
>>53728805

But isn't mathematics supposed to be a field of study that is full of concepts that will never find much use in real life? Why not make a proper notation, if only for completeness?
>>
>>53728864
this can be optimized too

arr = [0, 1, 1, 2 ...]
def fib_mod10(n):
return arr[n]
>>
>>53728880
>>53728864
def fib_mod10(n):
return [0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7, 0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9, 0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3, 0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1][n%60-1]


it can be further optimized and extended to allow for any n, when you take in to account the period of last digits of Fibonacci numbers
>>
is a timer in c++ just a literal timer which keeps track of how long your program takes in ms? last time i remember using them was back in high school when i thought they were just loops
>>
>>53726474
>What are you working on, /g/?
Babby's first (Twitter) scaper.
>>
I want to get into programming friends, is there a website which gives you problems to solve with programming? I figure that'll be the best way to start
>>
>>53726871
D > C++ > C
>>
>>53729522
Is it just me, or has the number of D programmers here increased enormously in the past ~2-3 days?

not complaining
D is pretty great
>>
>>53729535

I'm convinced it's all one D programmer who decided to post more. That said, D has some pretty interesting properties. I really wish C++ had D's static if.
>>
>>53728982
arr =  [0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7]
def fib_mod10(n):
return abs((arr[(n-1)%15] - (10*((n-1)%60 > 30))) * ((7*((n-1)%30 > 15)) or 1))%10



further optimizations can get it down to a length 15 array, still constant time.

I can't spot any patterns in this one to get it down farther though.
>>
>>53727225
>addThree :: Int -> Int -> Int -> Int
That doesn't make sense though, as in, there's no syntatic distinction between what's going in and what's going out as they're all chained so it doesn't necessarily look like it takes 3 ints and returns one. I mean it's unrelated to your problem but I'm just saying how it looks like from a perspective of non-Haskeller.
>>
>>53729535
Nah, every now and then D gets shilled to the max here then it calms down and repeats after a few days or so or at least that's the trend I've noticed.
>>
Where can I read up on Object oriented patterns(for C++) and specific detailed case studies involving them.
Trying to organize my code properly.

This post is probably gonna get a lot of butt-mad functional programmers replying or something.
>>
>>53729580
I just realized I've been staring at this for more than half an hour without noticing a pattern

[0, 1, 1, 2, 3, 
5, 8, 3, 1, 4,
5, 9, 4, 3, 7]

[0, 1, 1,
2, 3, 5,
8, 3, 1,
4, 5, 9,
4, 3, 7]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14]
[0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7]
[1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]


Does anybody else see one?
>>
>>53729617
add last two, add last two, add last two, sub last two, repeat.
>>
File: Screenshot_20160328_190716.png (13 KB, 428x350) Image search: [Google]
Screenshot_20160328_190716.png
13 KB, 428x350
>>53726474
Writing a GUI for the vm / assembler I've been fucking around with lately
porting it to C++ because I can't get any Qt bindings for D working

anyone know how I can specify how I want something to resize? Currently everything just stays the same size, but I want certain things to expand horizontally and vertically, certain things to expand horizontally, and certain things to just move while staying the some size
>>
>>53729637
actually, considering it's an array of length 15 that I would generate, I guess it would still be constant time, but I feel like there's a way to do it using fewer operations.
>>
So if I want to read the third nibble of a variable in C++ I can do
variable & 0xF0) >> 4

But if I want to add a value to(not completely replace it) the third nibble of a variable how would I do that?
>>
>>53729664
*of a 16-bit variable
>>
>>53729660
probably using a clever use of bit-manipulation

get those same numbers and look at all the bits and see if there's a pattern with that too. Probably a xor or bit shift of some kind.
>>
>>53729603
bmep
>>
>>53729658
You want to use VBoxLayout and HBoxLayout then put your elements inside of those, then an outer layout that's attached to the window where all other layouts reside inside of.
>>
>>53729677

Not seeing it here either. Every once in a while I'll think I see one and that gets wrecked by the next digit.

I'm beginning to question if there even is a pattern.

[0,  1,   1,  10 ,11,
101,1000,11, 1, 100,
101,1001,100,11, 111]

[0, 1, 1,
10, 11, 101,
1000,11, 1,
100, 101,1001,
100, 11, 111]
>>
Does anyone use omnisharp with YCM on vim?
>>
I can't do anything. I have no work ethic and have no confidence in my abilities. What do I do?
>>
>>53729838
Set yourself a goal, some sort of a more advanced project, and work your way through using documentations and various resources. Take your time, but force yourself to do at least one commit/thing a day to the project, you will build some discipline and improve your skills once you're far into the project.
>>
>>53726656
lastfib n = let f a b = a : f b (a+b) in mod ((f 0 1) !! n) 10
>>
>>53729887
>not constant time

trash
>>
class Foo
{
public:
...
private:
..
}

or

class Foo
{
private:
...
public:
...
}
>>
>>53729912
>class
>PascalCase
>>
>>53729866
>more advanced project
What though? This is the hardest part. Also what language? I likeC but it's a pain to write anything and no one wants C devs any more.
>>
>>53729912
class Foo
{
// private by default (in contrast to struct where stuff is public by default)
int priv1;
bool priv2;

public:
// stuff
};
>>
>>53729932
>What though? This is the hardest part.
There's a lot of stuff that you can do, I don't know maybe like a torrent client, some chat server/client with encryption, file transfer, friends list and such, some simple video game (or a clone of old classic arcade games), or something that you think you would like to use that would make your life easier.

>I likeC but it's a pain to write anything and no one wants C devs any more.
This I cannot help you with.
>>
>>53729932
>I likeC but it's a pain to write anything and no one wants C devs any more.

come back with a project.

Your languages should suit your projects, you need to remember that they're tools and pick the right tool for a job.

You don't see people writing webapps in c for the same reason you don't see people using pliers to hammer in a screw
>>
>>53730035
>using pliers to hammer in a screw
I've done this actually. The problem is I kind of dislike other languages. Maybe I just haven't used them properly but I never want to use them.

>come back with a project.
Literally impossible for me to think of anything. There's nothing I want either so I can't look there.
>>
File: 1036355S4-0.jpg (11 KB, 493x328) Image search: [Google]
1036355S4-0.jpg
11 KB, 493x328
Is this image pure bullshit ?
>>
File: coerce.jpg (84 KB, 890x717) Image search: [Google]
coerce.jpg
84 KB, 890x717
>>53730088
>anything is weaker than PHP

Well I'd argue that. But the principle is about right. People often say "static typing" when they mean "strong typing".
>>
>>53730088
?
>>
>>53730088
What the hell is strong/weak representing?
>>
>>53730126
typing
>>
can someone post that roll image for coding exercises? th-thanks
>>
>>53726474
nice meme book weeab

too bad it's shit for c11
>>
>>53730126

A strong example, using Ruby:
irb(main):009:0> S = "a string"
=> "a string"
irb(main):010:0> A = 4 + S
TypeError: String can't be coerced into Fixnum



Looks sane. I mean how would that actually work? Apparently, PHP has the answer.

$a = "a string";
var_dump($a + 4);


Output is apparently 4, with no errors thrown.
>>
>What are you working on, /g/?
I'm working on learning OpenGL by writing toy programs.
>>
>>53730084
Find a FOSS project you like on SJWHub and become a major contributor.
>>
>>53730291
How?
>>
>>53730330
How what?
>>
>>53730088

>C++
>More weakly typed than C
C++ allows a bit less in terms of implicit conversions than C, and all of the features it tacks on could be considered more strongly typed.
>>
>>53730348
How are you learning openGL? Just by experimenting? By tutorial?
>>
>>53729664
Nvm, got it.
>>
>>53730371
https://open.gl/ mainly, but I'm not following it exactly.
>>
>>53726487
>D
>C/C++
>Ass(embly)
>Perl/Ruby
>PHP

Why are programming language names so lewd?
>>
>>53730488

They aren't. You just have your mind in the gutter.
>>
>>53730088
How does Haskell not have the strongest typing?
>>
>>53730088
>C++ as weak as JS
Yes.
>>
>>53730548
It has weaker typing than, say, Coq and Agda.
>>
How would I express
// D code
void foo(alias func)(int[3] args)
{
// do some stuff
}

// e.g. to add
auto add = (args) => binary!((a, b) => a + b)(args);
add([1, 2, 3]);


In C++?
i.e a template function that takes a lambda expression at compile time
>>
Anyone got that 'roll one of 100 programming challenges' image? I'd be grateful
>>
>>53730779

>template function that takes a lambda expression at compile time
You want a template parameter to be a function? I know C++ has template template parameters, but I don't know if a function itself is a valid template parameter...
>>
>>53730878
this is a problem
mostly because I wanted like a hundred different variations on similar template functions to be stored in an array of functions, and I don't to have to make 2 layer deep indirect calls
guess it's switch statement of doom time then

>template template parameters
how the shit would that work
and for what purpose?
>>
Is there a good html5/css/js validator (other than throwing it in a browser and seeing if it works)?

I tried the w3c one, but the 'nu' one is shit and beta,, what happened to the old good one?!
>>
>>53730924

>template template parameters
The parameter to the template... is another template. I can't think of a good use for them off the top of my head. Ask a Haskeller what higher kinded types are for. It's basically that.

Also, by the looks of things, it might just be possible with function pointers...

https://stackoverflow.com/questions/1174169/function-passed-as-template-argument
>>
File: ê+ÄEï¦Ä¦ æµ03è¬ 152.jpg (561 KB, 827x1377) Image search: [Google]
ê+ÄEï¦Ä¦ æµ03è¬ 152.jpg
561 KB, 827x1377
I've heard great things about Haskell, but I love the expressiveness of Lisp and the macros.

Is Haskell worth looking into? And if so, why?
>>
>>53726721
>changing the loli's state in EVERY scenario, rather than letting the loli object's innate health properties determine that she's dead upon reaching a particular threshold

Fucking retard.

This is why OOP gets meme'd on.
>>
>>53731485
> rather than letting the loli object's innate health properties determine that she's dead upon reaching a particular threshold
Elaborate.
>>
>>53731494
Instead of determining whether the loli is dead on each individual scenario, utilize the loli object to change its state.

Basically, if at any point the loli object's hp goes to 0 or below, the logic to change its state to
deadloli
resides in the object itself.

Hypothetically, you later decide the loli can go into rage that prevents the loli from dying at 0 health (from which she could potentially use a healing item to get out of the threshold). If you have 80 scenarios, that's 80 times you're going to have to copypaste
&& loli.buffs != "rage" 
or whatever.
>>
File: dpt programming advice.png (6 KB, 433x91) Image search: [Google]
dpt programming advice.png
6 KB, 433x91
Thread replies: 255
Thread images: 29

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.