(手动滑稽)
leftpad = require './left-pad'
leftpad 'foo', 5
# => " foo"
leftpad 'foobar', 6
# => "foobar"
leftpad 1, 2, 0
# => "01"
module Main where
import LeftPad
main :: IO ()
main = putStrLn $ leftpad "foo" 6 'f'
-- => ffffoo
(load 'left-pad.scm')
(leftpad "foo" 6 #\f) ; => "ffffoo"
<?php
include_once 'left-pad.php';
echo leftpad("foo", 6, 'f'); // => "ffffoo"
?>
1
xuwenmang 2016-03-26 16:52:30 +08:00
|
2
loading 2016-03-26 19:00:31 +08:00 via Android
其实这个函数正儿八经是用来做什么的?
|
3
sox 2016-03-26 19:07:20 +08:00 1
|
4
zhujinliang 2016-03-26 19:18:54 +08:00 via iPhone
@sox 具体到这种情况,我是判断小于 10 的…
|
5
sox 2016-03-26 19:29:54 +08:00
我估计吐槽 left-pad 的人大部分人不知道 lodash.padStart()
|
7
Outshine 2016-03-26 19:35:09 +08:00
|
8
h0wardc 2016-03-26 19:53:39 +08:00
"I ’ ve Just Liberated My Modules"
https://medium.com/@azerbike/i-ve-just-liberated-my-modules-9045c06be67c including "left-pad" https://gist.githubusercontent.com/azer/db27417ee84b5f34a6ea/raw/50ab7ef26dbde2d4ea52318a3590af78b2a21162/gistfile1.txt The npm Blog: kik, left-pad, and npm http://blog.npmjs.org/post/141577284765/kik-left-pad-and-npm |
9
h0wardc 2016-03-26 20:12:44 +08:00
"NPM & left-pad: Have We Forgotten How To Program?"
http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/ |
10
realpg 2016-03-26 22:12:57 +08:00
PHP: str_pad
|
11
dphdjy 2016-03-26 23:05:41 +08:00 via Android
一直~
x 位插入字符+目标字符 取后 n 位~ 不知道性能怎么样~ |
14
ryanouyang 2016-03-30 17:23:05 +08:00
|