Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node {
- has Int $.data;
- has Node $.next = Nil;
- }
- class LinkedList {
- has Node $.head;
- method concat_list_str(Node $curr) {
- if !$curr {
- "";
- } elsif !$curr.next {
- $curr.data.Str
- } else {
- $curr.data.Str ~ "," ~ .concat_list_str($curr.next)
- }
- }
- method gist() {
- "[" ~ .concat_list_str($.head) ~ "]"
- }
- }
- my $list = LinkedList.new(head => Node.new(data => 1));
- say $list;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement