Skip to content
#

stdlib

Here are 3,160 public repositories matching this topic...

ivan-pi
ivan-pi commented Apr 23, 2021

Description

A function to pad a string with zeros or another symbol to a given width could be helpful in many cases, especially together with the to_string() function for integer to string conversion.

Currently available methods to achieve this are using concatenation

width = 32
str = "hello"
padded_str = repeat('0',width-len(str)')//str

and perhaps also internal file I/O

good first issue idea easy topic: strings
varnerac
varnerac commented Jun 23, 2022
import gleeunit
import gleam/bit_builder

pub fn main() {
  gleeunit.main()
}

pub fn bit_string_size_test() {
  <<1:int-size(1)>>
  |> bit_builder.from_bit_string()
  |> bit_builder.byte_size()
}

crashes with

λ ~/bitstringsize/ master* gleam test
  Compiling gleam_stdlib
  Compiling gleeunit
  Compiling bitstringsize
   Compiled in 1.41s
    Running bitstrings
bug good first issue help wanted

Improve this page

Add a description, image, and links to the stdlib topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the stdlib topic, visit your repo's landing page and select "manage topics."

Learn more