Skip to content

Commit

Permalink
Extended the signature of JavaTrieRandomChoice to resemble RandomChoice.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Feb 14, 2017
1 parent 973d869 commit 8577bf6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions JavaTriesWithFrequencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ Mathematica is (C) Copyright 1988-2017 Wolfram Research, Inc.
TrieFunctions`removeByParetoFraction[jTr, paretoFraction, True, postfix];

Clear[JavaTrieRandomChoice]
JavaTrieRandomChoice[jTr_?JavaObjectQ, weightedQ:(True|False):True] :=
JavaObjectToExpression[ TrieFunctions`randomChoice[jTr, weightedQ] ];
Options[JavaTrieRandomChoice] = { "Weighted"->True };
JavaTrieRandomChoice[jTr_?JavaObjectQ, opts:OptionsPattern[] ] :=
JavaObjectToExpression[ TrieFunctions`randomChoice[jTr, TrueQ[OptionValue["Weighted"]] ] ];

JavaTrieRandomChoice[jTr_?JavaObjectQ, n_Integer, opts:OptionsPattern[] ] :=
JavaObjectToExpression /@ JavaObjectToExpression[ TrieFunctions`randomChoice[jTr, n, TrueQ[OptionValue["Weighted"]] ] ];

Clear[JSONTrieToRules]
JSONTrieToRules[tree_] := Block[{ORDER = 0}, JSONTrieToRules[tree, 0, 0]];
Expand Down

0 comments on commit 8577bf6

Please sign in to comment.