Skip to content

Instantly share code, notes, and snippets.

View diakopter's full-sized avatar
💭
🤠

Matthew Wilson diakopter

💭
🤠
View GitHub Profile
in t
hi from toplevel
in Frame_3
hi from sub 1
$a is: foo
in Frame_5
hi from sub 2
$a is: foo
in Frame_3
in Frame_5
CursorBase.pmc | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/CursorBase.pmc b/CursorBase.pmc
index 91c6546..2eb2460 100644
--- a/CursorBase.pmc
+++ b/CursorBase.pmc
@@ -525,9 +525,10 @@ sub delete {
# Cursor transformations
#############################################################
/// <summary>
/// Pops a value from a low level list (something that
/// uses the P6list representation).
/// </summary>
/// <param name="TC"></param>
/// <param name="LLList"></param>
/// <returns></returns>
public static RakudoObject lllist_pop(ThreadContext TC, RakudoObject LLList)
{
dddddddddd
class knapsackItem{
has string $!name; has int $!weight;has int $!unit
method ToString(-->string) {
return self.name ~ ' ' ~ self.weight ~ ' ' ~ self.unit
}
}
sub makeItem(string $n, int $w, int $u --> knapsackItem) {
my $i = knapsackItem.new;
my $answers = List[int].new();
$answers.Add(1);
$answers.Add(0);
$answers.Add(-2);
$answers.Add(0);
$answers.Add(1);
$answers.Add(0);
$answers.Add(1);
$answers.Add(-1);
$answers.Add(-10);
at Rakudo.Runtime.Ops.get_lex(ThreadContext TC, String Name) in c:\src\6model\dotnet\runtime\Runtime\Ops\Variables.cs:line 32
at Rakudo.Runtime.Ops.llcap_get_at_pos(ThreadContext TC, RakudoObject Capture, RakudoObject Index) in c:\src\6model\dotnet\runtime\Runtime\Ops\P6capture.cs:line 32
at NQPOutput_1296157879.block_98(ThreadContext TC, RakudoObject Block, RakudoObject Capture) in c:\src\6model\dotnet\compiler\P6Objects.cs:line 1234
at Rakudo.Metamodel.Representations.RakudoCodeRef.<type_object_for>b__0(ThreadContext TCi, RakudoObject Obj, RakudoObject Cap) in c:\src\6model\dotnet\runtime\Metamodel\Representations\RakudoCodeRef.cs:line 97
at Rakudo.Metamodel.SharedTable.Invoke(ThreadContext TC, RakudoObject Obj, RakudoObject Cap) in c:\src\6model\dotnet\runtime\Metamodel\SharedTable.cs:line 112
at NQPOutput_1296157989.block_1(ThreadContext TC, RakudoObject Block, RakudoObject Capture) in C:\src\6model\dotnet\compiler\x.cs:line 57
at Rakudo.Metamodel.Representations.RakudoCodeRef.<type_o
class knapsackItem {
has string $!name;
has int $!weight;
has int $!unit;
method ToString(-->string) {
return self.name ~ ' ' ~ self.weight ~ ' ' ~ self.unit
}
}
sub makeItem(string $n, int $w, int $u --> knapsackItem) {
my $i = knapsackItem.new;
my $three = BigInteger.Parse("3");
my $five = BigInteger.Parse("5");
sub updateFrontier(BigInteger $value, SortedSet[BigInteger] $frontierSet) {
$frontierSet.Add(BigInteger.op_LeftShift($value, 1));
$frontierSet.Add($value * $three);
$frontierSet.Add($value * $five)
}
sub getHammingNumbers(int $howMany, boolean $all --> List[BigInteger]) {
my $limit = 32;
sub powers_of ($radix) { 1,[\*] $radix xx * }
my @hammings =
( powers_of(2)[^ $limit ] X*
( powers_of(3)[^($limit * 2/3)] X*
powers_of(5)[^($limit * 1/2)]
)
).sort;