Internal`PartitionRagged
This one has a usage statement!
Internal`PartitionRagged[Range[14], {3, 5, 2, 4}]
{{1, 2, 3}, {4, 5, 6, 7, 8}, {9, 10}, {11, 12, 13, 14}}
Note that Length[list]
must equal n1 + ... + nk
.
(* changed the last 4 to 3 *)
Internal`PartitionRagged[Range[14], {3, 5, 2, 3}]
Internal`PartitionRagged[Range[14], {3, 5, 2, 3}]
Internal`S1, Internal`S2, Internal`P2
Is it possible to have a documentation of these frequently-used functions with the help of the users in this community?
These guy's aren't frequently used (and probably aren't used at all), but they're really mysterious looking.
After reading this paper, I realized they're submethods used in computing PrimePi
.
With[{x = 10^9},
{
PrimePi[x],
Internal`S1[x] + Internal`S2[x] + Internal`P2[x] + PrimePi[x^(1/3)] - 1
}
]
{50847534, 50847534}
Internal`Square
??Internal`Square
(* Attributes[Internal`Square] = {Listable, NumericFunction, Protected} *)
Test it with a list:
list = RandomReal[{0, 100}, 10^8];
r1 = list*list; // RepeatedTiming
(* 0.118 seconds *)
r2 = list^2; // RepeatedTiming
(* 0.191 seconds *)
r3 = Internal`Square[list]; // RepeatedTiming
(* 0.121 seconds *)
The advantage of this function seems to come when computing higher powers on a list:
lis = RandomReal[{0, 1}, 10^7];
lis*lis*lis*lis; // RepeatedTiming
(* 0.55 seconds *)
lis^4; // RepeatedTiming
(* 0.21 seconds *)
Internal`Square @ Internal`Square @ lis; // RepeatedTiming
(* 0.15 seconds *)