Loading ...
Sorry, an error occurred while loading the content.

repeat with increment?

Expand Messages
  • Bee
    ok... I am learning some commands let hr = repeat( = ,62). r imap ,hv = .hr will output:
    Message 1 of 5 , Sep 30, 2009
    • 0 Attachment
      ok... I am learning some commands

      let hr = repeat('=',62)."\r"
      imap ,hv <c-r>='" '.hr<cr>

      will output:

      " ==============================================================

      How to use something like repeat() to create a string like:

      '" '.(((start at 3 increment by 1) mod 10) for count of 62)

      resulting in:

      " 34567890123456789012345678901234567890123456789012345678901234

      --
      Bill
      Santa Cruz, California


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Christian Brabandt
      Hi Bee! ... fu! Repeat(start, mod, count) let i=1 let s=[] call add(s,a:start) while i
      Message 2 of 5 , Sep 30, 2009
      • 0 Attachment
        Hi Bee!

        On Mi, 30 Sep 2009, Bee wrote:

        > How to use something like repeat() to create a string like:
        >
        > '" '.(((start at 3 increment by 1) mod 10) for count of 62)
        >
        > resulting in:
        >
        > " 34567890123456789012345678901234567890123456789012345678901234

        fu! Repeat(start, mod, count)
        let i=1
        let s=[]
        call add(s,a:start)
        while i < a:count
        call add(s,(s[i-1]+1)%a:mod)
        let i+=1
        endw
        return join(s, '')
        endfu

        :echo Repeat(3,10,62)
        34567890123456789012345678901234567890123456789012345678901234


        regards,
        Christian
        --
        "The Mac OS X kernel should never panic because, when it does, it
        seriously inconveniences the user."
        --http://developer.apple.com/technotes/tn2004/tn2118.html

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Hari Krishna Dara
        ... If you are comfortable with pythonic way of programming, you can get ... 34567890123456789012345678901234567890123456789012345678901234 -- HTH, Hari ...
        Message 3 of 5 , Sep 30, 2009
        • 0 Attachment
          On Wed, Sep 30, 2009 at 10:31 PM, Christian Brabandt <cblists@...> wrote:
          >
          > Hi Bee!
          >
          > On Mi, 30 Sep 2009, Bee wrote:
          >
          >> How to use something like repeat() to create a string like:
          >>
          >> '" '.(((start at 3 increment by 1) mod 10) for count of 62)
          >>
          >> resulting in:
          >>
          >> " 34567890123456789012345678901234567890123456789012345678901234
          >
          > fu! Repeat(start, mod, count)
          >    let i=1
          >    let s=[]
          >    call add(s,a:start)
          >    while i < a:count
          >        call add(s,(s[i-1]+1)%a:mod)
          >        let i+=1
          >    endw
          >    return join(s, '')
          > endfu
          >
          > :echo Repeat(3,10,62)
          > 34567890123456789012345678901234567890123456789012345678901234

          If you are comfortable with pythonic way of programming, you can get
          the same with:

          :echo join(map(range(3,64), 'v:val % 10'), '')
          34567890123456789012345678901234567890123456789012345678901234

          --
          HTH,
          Hari

          >
          >
          > regards,
          > Christian
          > --
          > "The Mac OS X kernel should never panic because, when it does, it
          > seriously inconveniences the user."
          > --http://developer.apple.com/technotes/tn2004/tn2118.html
          >
          > >
          >

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Christian Brabandt
          Hi Hari! ... Not very. But I try to. But usually I do not think in those possible ways ;) ... Nice. regards, Christian
          Message 4 of 5 , Oct 1, 2009
          • 0 Attachment
            Hi Hari!

            On Mi, 30 Sep 2009, Hari Krishna Dara wrote:

            > If you are comfortable with pythonic way of programming, you can get
            > the same with:

            Not very. But I try to. But usually I do not think in those possible
            ways ;)

            >
            > :echo join(map(range(3,64), 'v:val % 10'), '')
            > 34567890123456789012345678901234567890123456789012345678901234

            Nice.

            regards,
            Christian

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Bee
            ... Thank you, that is great, and the style I was looking for. vim is deep! -- Bill Santa Cruz, California
            Message 5 of 5 , Oct 1, 2009
            • 0 Attachment
              On Oct 1, 2009, at 2:50 AM, Hari Krishna Dara wrote:
              > On Wed, Sep 30, 2009 at 10:31 PM, Christian Brabandt
              > <cblists@...> wrote:
              >> Hi Bee!
              >> On Mi, 30 Sep 2009, Bee wrote:
              >>> How to use something like repeat() to create a string like:
              >>>
              >>> '" '.(((start at 3 increment by 1) mod 10) for count of 62)
              >>>
              >>> resulting in:
              >>>
              >>> " 34567890123456789012345678901234567890123456789012345678901234
              >
              > ...
              >
              > If you are comfortable with pythonic way of programming, you can get
              > the same with:
              >
              > :echo join(map(range(3,64), 'v:val % 10'), '')
              > 34567890123456789012345678901234567890123456789012345678901234

              Thank you, that is great, and the style I was looking for.
              vim is deep!
              --
              Bill
              Santa Cruz, California


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.