Skip to content

Commit d002c2e

Browse files
committed
refactor:Simpler code.
1 parent d7e840a commit d002c2e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/Graph/Relation.rakumod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ use Graph;
77
class Graph::Relation is Graph {
88
multi method new(&f, @v, $w is copy = Whatever, :with(:&as) is copy = WhateverCode, Bool:D :d(:directed-edges(:$directed)) = True) {
99
if &as.isa(WhateverCode) { &as = {$_} }
10-
my @w;
1110
given $w {
12-
when Whatever { @w = @v }
13-
when $_ ~~ (Array:D | List:D | Seq:D) { @w = |$w }
11+
when Whatever { $w = @v }
12+
when $_ ~~ (Array:D | List:D | Seq:D) {
13+
# do nothing
14+
}
1415
default {
1516
die 'The third argument is expected to be a list or Whatever.'
1617
}
1718
}
18-
my @edges = (@v X @w).map({ &f(&as($_.head), &as($_.tail)) ?? Pair.new($_.head.Str, $_.tail.Str) !! Empty });
19+
my @edges = (@v X $w.Array).map({ &f(&as($_.head), &as($_.tail)) ?? Pair.new($_.head.Str, $_.tail.Str) !! Empty });
1920
my Graph $graph = Graph.new(@edges, :$directed);
2021
return $graph;
2122
}

0 commit comments

Comments
 (0)