4 ms·
Best practice for performance for large left-pad jobs is to call the service recursively using mapreduce. Remember that left-pad(str,pad,n) is equal to left-pad
by jameshart 11y ago
Best practice for performance for large left-pad jobs is to call the service recursively using mapreduce. Remember that left-pad(str,pad,n) is equal to left-pad(left-pad(str,pad,n/2),left-pad("",pad,n/2),n). This should run in logarithmic time and is highly parallelizable.
If you don't like the "" magic string in there you could replace it with a call to left-pad(null, null,0).
- capitalsigma 11y agooh god it's too real
- lucastx 11y agoPoe's law for programming culture extremists
- pajop 11y agoif you put https://api.left-pad.io/?len=1017 https://api.left-pad.io/?len=1017 or anything higher than 1016 it says: {"errorMessage":"len exceeds 1007 characters. Contact a left-pad.io sales engineer for an enterprise license","errorType":"Error","stackTrace":["exports.handler (/var/task/index.js:33:22)"]} wow. they even have an enterprise sales engineer! :)
- paulclinger 11y agoYou should be using emptystring.io instead of the "magic string" or a "null, null" hack.
- rkuykendall-com 11y agoHere you go: https://api.left-pad.io/?len=0 https://api.left-pad.io/?len=0
- kdma 11y agoShouldn't it be leftpad(leftpad (str,pad,n/2),leftpad("",pad,n/2),1)?