Comment detail

文字列のセンタリング (Nested Flatten)
1
2
3
4
5
6
7
let center str width =
  let len = String.length str in
  if width>len then
    let res = String.make width ' ' in
    (String.blit str 0 res ((width-len)/2) len; res)
  else
    String.sub str ((len-width)/2) width ;;

Index

Feed

Other

Link

Pathtraq

loading...