This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(StringInput)=> | |
let | |
/*function for reversing the bits in a 8-bit number*/ | |
reverse = (x) => | |
Number.Mod(Number.BitwiseAnd((x* 0x0202020202),0x010884422010),1023), | |
/*function for reversing the bits in a 32-bit number*/ | |
reverse32 = (x) => | |
let | |
b0 = Number.BitwiseAnd(x,0xff), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(){ | |
param([Int32]$b) | |
$b = (($b -band 0xf0) -shr 4) -bor (($b -band 0x0f) -shl 4) | |
$b = (($b -band 0xcc) -shr 2) -bor (($b -band 0x33) -shl 2) | |
$b = (($b -band 0xaa) -shr 1) -bor (($b -band 0x55) -shl 1) | |
$b | |
} | |
# on a 64bit machine this is an alternative to reverse() function | |
function reverse64(){ | |
param([Int32]$x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(n) => | |
let | |
swapAnyOrder = (_,from,to)=> if from = to then _ else | |
(if from < to then swap(_,from,to) else swap(_,to,from)), | |
swap = (_,from,to)=> List.Range(_,0,from) | |
&{_{to}} | |
&List.Range(_,from+1,to-from-1) | |
&{_{from}} | |
&List.Range(_,to+1) | |
in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(A,B) => | |
let | |
//vector multiplication | |
dotProduct = (v1,v2) => | |
List.Accumulate( | |
List.Zip({v1,v2}), | |
0, | |
(agg,_)=> | |
agg+(_{1}*_{0})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ZIPFile) => | |
let | |
Header = BinaryFormat.Record([ Signature = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger32,ByteOrder.LittleEndian), | |
Version = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), | |
Flags = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), | |
Compression = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), | |
ModTime = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), | |
ModDate = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), | |
CRC32 = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger32,ByteOrder.LittleEndian), | |
CompressedSize = BinaryFormat.ByteOrde |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ZIPFile) => | |
let | |
//shorthand | |
UInt32 = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger32, | |
ByteOrder.LittleEndian), | |
UInt16 = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16, | |
ByteOrder.LittleEndian), | |
//Local File Header | |
Header = BinaryFormat.Record([ | |
Version = UInt16, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= List.Generate( | |
()=> [ | |
can_expand=true, | |
level =1, | |
input =json, | |
output =[level.0=Record.FieldNames(json){0}] | |
], | |
each [can_expand], | |
each [ | |
can_expand =Record.FieldValues([input]){0} is record, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expandableColumns = (_) => List.Accumulate( | |
Table.ColumnNames(_), | |
{}, | |
(s,c)=>s&(if Type.Is(Value.Type(Record.Field(_{0},c)), type record) | |
or Type.Is(Value.Type(Record.Field(_{0},c)), type list) | |
then {c} | |
else {} | |
) | |
), | |
columnHasConsistentType = (T,Cname) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(json) => | |
let | |
//List the expandable columns | |
expandableColumns = (_) => List.Accumulate( | |
Table.ColumnNames(_), | |
{}, | |
(s,c)=>s&(if Type.Is(Value.Type(Record.Field(_{0},c)), type record) | |
or Type.Is(Value.Type(Record.Field(_{0},c)), type list) | |
then {c} | |
else {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse = (x) => | |
Number.Mod(Number.BitwiseAnd((x* 0x0202020202),0x010884422010),1023), |
OlderNewer