prompt

My shell prompt
git clone https://hhvn.uk/prompt
git clone git://hhvn.uk/prompt
Log | Files | Refs

smallify.go (511B)


      1 package main
      2 
      3 // These functions only work on ASCII
      4 
      5 func Smalltxt(s string) string {
      6 	b := []byte(s)
      7 
      8 	var j int
      9 	for i := range b {
     10 		switch b[i] {
     11 		case 'a', 'e', 'i', 'o', 'u':
     12 		default:
     13 			b[j] = b[i]
     14 			j++
     15 		}
     16 	}
     17 
     18 	return string(b[:j])
     19 }
     20 
     21 func Smallcmp(ss string, sl string) bool {
     22 	s := []byte(ss)
     23 	l := []byte(sl)
     24 
     25 	var j int
     26 	for i := range l {
     27 		switch l[i] {
     28 		case 'a', 'e', 'i', 'o', 'u':
     29 		default:
     30 			if j == len(s) || s[j] != l[i] {
     31 				return false
     32 			}
     33 			j++
     34 		}
     35 	}
     36 
     37 	return j == len(s)
     38 }