Post your most compact Linked List implementation.
>inb4 /g/ doesn't even know how to code a linked list
>g-guys do my homework for me
lol
>>53324420
it's not my but it should be enough to have an idea of it: http://www.boost.org/doc/libs/1_60_0/doc/html/intrusive/list.html
why do you need a linked list (assuming it's not your homework)? Take a vector or something similar and maybe a few more iterators.
>>53324494
>>53324523
It's just a test to see whether /g/ knows how to implement anything else than hello world
>>53324533
>implement anything else than hello world
I can implement you a hello world program with a boost::list
>>53324523
>>53324546
>using boost
Get a load of this script kiddie
>>53324420
Im in physics and even we had to learn that in the intro to prog course
>>53324563
>using arguments.
>>53324420
lmao i'm not some nerd loser
>Haskelldata LL x = Value x [LL x] | End
>>53324617
Whoops, that's a tree.data LL x = Value x (LL x) | End
from top of my head:struct
{
int someValue;
Banana* next;
} typedef Banana;
Banana* GetNextBanana(Banana* prevBanana)
{
return prevBanana->next;
}
void main()
{
int n = 100;
Banana** bananas = malloc(SizeOf(Banana) * n);
. . .
}
Haven't done C since I left the embedded industry. 3 years of C# made me rust, so don't trust it.
>>53324420
>Ruststruct LinkedNode<T> {
data: T,
next: Option<Box<LinkedNode<T>>>
}
impl LinkedNode<T> {...}
struct LinkedList<T> {
first: Option<Box<LinkedNode<T>>>
}
impl LinkedList<T> {...}
impl Iterator for LinkedList<T> {...}
>>53324635
>embedded industry
>3 years of C#
What sort of work did you do then and now?
>>53324420#include <sys/queue.h>
>>53324635
>linked list
>declares a size
>>53324669
>not being able to read
>>53324679
Hahaha I noticed when I posted. My brain isn't working after a long night awake and only 3 hours of sleep. I'll just shitpost from now.
>>53324668
Gambling machine software, IoT dimmers and home automation shit. Now desktop software in WPF and multiplatform applications with Xamarin.
>>53324701
>Gambling machine software, IoT dimmers and home automation shit. Now desktop software in WPF and multiplatform applications with Xamarin.
Why would anyone trade the first job for the 2nd? Embedded dev sounds way more fun
type 'a linked_list =
| None
| Node of 'a * 'a linked_list;;
>>53324736
No crazy deadlines, no messy legacy code, no manager that would literally hire 9 girls to bear a baby in 1 month because he thinks that's how things work... much easier job atm. for way more cash. But sometimes I do miss the IoT shit.
class LinkedList
attr_accessor :next, :value
end
Linked lists suck
>>53324635
This guy nailed it.
But I'd just copy one from ccan or the kernel. Why independently solve a menial problem which has already been solved by people much smarter than me and tested by others just like me? That's the whole point of open source.
https://ccodearchive.net/info/list.html
>>53324736
>>53324793
I also think embedded dev sounds fun, but literally everyone who has done it says it sucks. I guess you have to have done it to get over it.
>>53324420
typedef struct a a;
struct a {
a * next;
int value;
}
#include <list>
list <filetype> name;
That was hard
>>53325468
Beat me to it
In other news
Why would anyone want to check if /g/ could implement a linked list, its a tiny step above the most trivial things in introductory CS classes, so you are simply asking "is /g/ a programmer or not"
>news
Do your own homework kid its better for yourself, or at least be straight about it when asking for help