Zulip Chat Archive

Stream: general

Topic: How to make a String.nextn function


Tamas Hadhazy (Oct 20 2025 at 14:20):

For subString we already have Substring.nextn how would I write one from scratch for a String? It only has String.next, which only advances the position by 1

Kenny Lau (Oct 20 2025 at 14:29):

@Tamas Hadhazy

import Mathlib.Logic.Function.Iterate

set_option autoImplicit false

def s := "áéíóúabcdefg"
def i : String.Pos := 0

#eval s.next^[3] i

Last updated: Dec 20 2025 at 21:32 UTC