package org.test;

import org.nlogo.api.*;
import java.util.Random;

public class BuildRandomList extends DefaultReporter {

    Random r = new Random();
    public Syntax getSyntax() {
        return Syntax.reporterSyntax(new int[]{Syntax.NumberType()},Syntax.ListType());
    }

    public Object report(Argument args[], Context context) throws ExtensionException, LogoException {
        LogoListBuilder list = new LogoListBuilder();

        int n;
        try {
            n = args[0].getIntValue();
        } catch (LogoException e) {
            throw new ExtensionException(e.getMessage());
        }

        for (int i = 0; i < n; i++) {
            list.add(Double.valueOf(r.nextDouble()));
        }

        return list.toLogoList();

    }

}
@@ -698,32 +698,74 @@
 ()));%0A        %7D%0A
+        // Java autobox double into Double
 %0A        return 
@@ -772,21 +772,8 @@
 list
-.toLogoList()
 ;%0A%0A 

add comment