Post your code and be judged
Post your code and be judged
That's a shit language and you should feel bad for using it.
nobody cares about your unremarkable code, OP. this thread is shit
Ia that rust?
What editor for such quality
probably jetbrains material theme
come join us in /dpt/ and talk about code OP ^_^, the rest of this board is trash
source : github.com/nuxed/framework
nice
My first FizzBuzz
template
T *get_component(COMPONENT_TAG tag) {
BaseComponent* out = get_base_component(tag);
if (!out || out->ghosted) return nullptr;
else return dynamic_cast(out);;
};
BaseComponent* Entity::get_base_component(COMPONENT_TAG tag) const{
auto ent_tags = get_tags();
auto tags_to_check = get_inheritors(tag);
for (const auto& t : tags_to_check) {
auto a = ent_tags.find(t);
if (a != ent_tags.end()) return components.find(*a)->second.get();
}
return nullptr;
}
a polymorphism bit
Is this JavaScript?
template
T *get_component(COMPONENT_TAG tag)
{
BaseComponent* out = get_base_component(tag);
return (!out || out->ghosted) ? NULL : dynamic_cast(out);;
};
BaseComponent* Entity::get_base_component(COMPONENT_TAG tag) const
{
auto ent_tags = get_tags();
auto tags_to_check = get_inheritors(tag);
for (const auto& t : tags_to_check) {
auto a = ent_tags.find(t);
if (a != ent_tags.end())
return components.find(*a)->second.get();
}
return NULL;
}
Rust
Obj-C?
are you programming a file manager?
How could you possibly think that's JS?
I love haskell!
-- largest increasing subsequence
lis [] = 0
lis (x:xs) = f xs x 1 `max` lis xs
where f [] _ n = n
f (x:xs) y n
| x > y = f xs x (n + 1) `max` f xs y n
| otherwise = f xs y n
It's swift :) and I'm making something similar to feh, but for macOS. I know there is already tons of alternatives, but I want to make my own for practice.
Why are STACK and HEAP mutable?
Because they're both mutated?
Yes
Uhh, no? Is rust really that much of a shitty language that pushing to a data structure is considered mutating it? The address stays the same.
Unreadable
for you
completely wild guess but is this an emulator?
>pushing to a data structure is considered mutating it?
Of course it is?
>The address stays the same
How in the actual fuck can you think that is only thing that qualifies as mutation?
it's pretty much a haskell translation of the algorithm in section 2.6 of this book
jeffe.cs.illinois.edu
without the 'hack' of the sentinel value, since I wanted lis to be generic
what theme is this?
What are peoples favourite programming fonts?
Looking for something new to treat my eyes to.
good lad
now make a program that calculates fibonacci sequence or one that calculates n digits of pi
//declaration
void printSomething();
void printThis(char something[]);
struct printer{
void (*printSomething)();
void (*printThis)();
int number;
};
void printerConstructor(struct printer *a, int numberParam);
//implementation
void printerConstructor(struct printer *a, int numberParam){
(*a).number = numberParam;
(*a).printSomething = &printSomething;
(*a).printThis = &printThis;
}
void printSomething(){
printf("Something\n");
}
void printThis(char something[]){
printf("%s\n", something);
}
//main, usage
int main(int argc, char **argv){
struct printer printer;
printerConstructor(&printer, 5);
printf("%i\n", printer.number);
(*printer.printSomething)();
(*printer.printThis)("mfw someone says they like OOP");
}
Yes I just learned about function pointers as javalet, fuck off
It looks identical to JS
class FizzBuzzCommandlet extends Commandlet;
event int Main(string Parms)
{
local int i;
local string S;
while(i++ < 100)
{
S = "";
if(i % 3 == 0)
S $= "Fizz";
if(i % 5 == 0)
S $= "Buzz";
Log(Eval(S=="",i,S));
}
return 0;
}
You're retarded and don't know a lick of JS then
I don't need to know JS to know it's shit and anything that looks like it is also shit
>void printSomething();
void printSomething(void);
An empty argument has a subtle difference than an explicit void in C which you don't want to happen. Basically, it can actually lead to the compiler not checking how you're supposed to pass arguments to the function.
>(*a).printSomething = &printSomething;
There is a nicer syntax for this.
a->printSomething = printSomething;
& on function pointers is technically unnecessary, but it's perfectly fine to leave it there.
>(*printer.printSomething)();
You don't actually need to dereference a function pointer with * to use it.
printer.printSomethng();
Also, you'd normally wouldn't write code like this in C unless you have a pretty good reason to.
I was explicit because I want to know what I am doing.
It was just an exercise, but its interesting reimplementing things you use in java yourself.
It's Rust.
It's shit
Coding the fibonacci sequence was honestly easier than expected
>let
into the trash it goes
>I name my variables with cryptic names so the code looks more complex.
kys
wut, I'm not him and it's pretty clear what each variable means, in the context of an emulator/vm
???
Unreadable mess
PROGRAM BUBBLESORT
LOGICAL sorted
INTEGER n, tmp
INTEGER t(10)
c Parses file into array
OPEN (log, FILE='array')
DO 10 n = 1, 10
READ (log, *) t(n)
10 CONTINUE
CLOSE (log)
c Sort
DO 30 WHILE (sorted .EQV. .FALSE.)
sorted = .TRUE.
DO 20 n = 1, 9
IF (t(n) .GT. t(n + 1)) THEN
tmp = t(n)
t(n) = t(n + 1)
t(n + 1) = tmp
sorted = .FALSE.
ELSE
CONTINUE
ENDIF
20 CONTINUE
30 CONTINUE
c Print sorted array
DO 40 n = 1, 10
PRINT *, t(n)
40 CONTINUE
END PROGRAM BUBBLESORT
Did this a few years ago, am still quite proud of it.
: "sr" dup PI neg < if 2PI + else dup PI > if 2PI - then then ;
: sin 2PI % "sr" >r 1.27323 I f* 0.40528 I f* I f* I 0 < if + else - then r> drop ;
: cos 1.57079 + sin ;
>cryptic identifiers
>no explanation of what code is for or what it does
Please fucking kill yourself, 0/100.
Best language reporting in.
> swift
> using ;
why?
Well that's because it's the most inefficient one available, try calculating the 1000th fibonnaci with that
Piping and Forking is fun, but incredibly confusing.
Ignorant retard.
fuck how does swift always manage to look so clean?
making a little 2d ECS game engine, it's fun
doing some web scraping today
looks like ts/kot
what makes it better?
Good thing you're using Rust with that shitty bounds checking. Have you considered encoding the instruction lengths in a more reusable way so you don't need to copy-paste this shit for your inevitable disassembler?
looks like objective-C raped kotlin, what the fuck is this shit
>objective-C raped kotlin
and that's a good thing!
>nouns as function names
Stop
> vk.com
slav nigger
kys
are you retarded
total = 0
for i, page in enumerate(bucket_iterator, 1):
page_queue = []
# Find all out of date objects
for obj in page['Contents']:
key = obj['Key']
last_modified = obj['LastModified']
if last_modified
Source Code Pro
i dont want to be judged
I don't have anything to be judged.
is it possible to make fonts look like that without mactype?
py-fag
Jesus Christ user, never show this code in an interview
reading, writing, creating jsons should be done in seperate functions to make code more readable.
Why throw in everything together within a "with" clause?
Solution to Day 2 part 2 of AOC 2017. I was really into coming up with a solution that only used map, reduce and filter because I thought for _ in _ was for plebs. Not sure it was worth it.
ok i did it
def fib(n):
return int(0.4472135954999579*1.618033988749895**n-0.4472135954999579*-0.6180339887498949**n)
puts "I love cum"
It does look like js because variables are declared without specifying the type. And the word "let" is used. Don't get so offended
the type is declared
let mut pc: usize = 0;
in the above line usize is the type
there are also several operators (* & ::) that aren't used in javascript
finally javascript doesn't define functions by starting the line with fn
is this Javascript?
>try calculating 1000th fibonacci
>program is only accurate to 71st fibonacci
retard
meh, good enough. We never go over the 71st fibonacci anyway.
What font?
No, Fortran
I did that too just to test the limits of it and it took about a second.
#include
#include
#include
#include
void fibonacci(uint64_t n) {
using namespace boost::numeric::ublas;
using namespace boost::multiprecision;
matrix m(2, 2), fib(2,2);
m(0,0) = m(1,0) = m(0,1) = 1;
m(1,1) = 0;
fib = m;
while(n){
if(n&1)
fib = prod(fib, m);
m=prod(m, m);
n>>=1;
}
std::cout
try to make it like this wikimedia.org
434665576869374564356
885276750406258025646
605173717804024817290
895365554179490518904
038798400792551692959
225930803226347752096
896232398733224711616
429964409065331879382
989696499285160037044
76137795166849228875
Nigga, you high? Wtf do you think "mutable" means? Something either can change its state during runtime (mutable) or can't (immutable). Pushing something onto stack is changing its state, dingus.
Same guy here, calculating the 100 000th number took 6m and 48s
>Decide to play with Clojure for an idea I had
>Need HTTP/2 client
>Test three different HTTP libraries
>None of them support it
>Give up with no code
There you go, plz judge.
>uses vertical typing mixed with spiral convergence style
>big fucking orange cross to highlight module's kernel
>using only ONE kernel
>syntax error near 1-10-6 squiggle
what a fucken scrub
C++ was a mistake
No really, that's good code, but needing three different boost imports to do it is pretty shit.
You can delete the io.hpp, the matrices aren't being printed out.
And delete the matrix.hpp if you just roll your own 2x2 matrix class.
Vs theme name?
:3
Color scheme?