Skip to main content

shiftl

Function shiftl 

Source
pub fn shiftl(in_: &str, nshift: i32, fillc: char, out: &mut str)
Expand description

Shift left

Shift the contents of a character string to the left. Characters moved past the beginning of the input string are lost. Vacant spaces are filled with a specified character.

§Brief I/O

 VARIABLE  I/O  DESCRIPTION
 --------  ---  --------------------------------------------------
 IN         I   Input string.
 NSHIFT     I   Number of times to shift.
 FILLC      I   Character to fill spaces left vacant.
 OUT        O   Shifted string.

§Detailed Input

 IN       is the input character string.

 NSHIFT   is the number of times the string is to be
          shifted. If NSHIFT is negative, OUT will be
          identical to IN.

 FILLC    is the character with which spaces left vacant by
          the shift are to be filled.

§Detailed Output

 OUT      is the output string. This is the input string,
          shifted N times, filled with FILLC.

          OUT may overwrite IN.

§Exceptions

 Error free.

§Particulars

 As a string is shifted left or right, the leftmost or
 rightmost characters of the string disappear (as if pushed
 off the end of the string). This is .TRUE. regardless of
 the length of the output string.

 The remaining characters are shifted simultaneously, and
 the spaces vacated by those characters are filled with a
 replacement character.

§Examples

 If FILLC = ' '

    'abcde'   shifted left twice becomes     'cde  '
    'abcde'   shifted right once becomes     ' abcd'

 If FILLC = '.'

    '12345 '  shifted right once becomes     '.12345'
    'Apple '  shifted left ten times becomes '......'

 Given the declarations

    CHARACTER*3         SHORT
    CHARACTER*10        LONG

 The calls

    CALL SHIFTR ( 'abcde ', 2, '-', SHORT )
    CALL SHIFTR ( 'abcde ', 2, '-', LONG  )

 yield the strings

    SHORT = '--a'
    LONG  = '--abcd    '

 while the calls

    CALL SHIFTL ( 'abcde ', 2, '-', SHORT )
    CALL SHIFTL ( 'abcde ', 2, '-', LONG  )

 yield the strings

    SHORT = 'cde'
    LONG  = 'cde ..     '

§Author and Institution

 J. Diaz del Rio    (ODC Space)
 M.J. Spencer       (JPL)
 W.L. Taber         (JPL)
 I.M. Underwood     (JPL)
 E.D. Wright        (JPL)

§Version

-    SPICELIB Version 2.1.0, 12-AUG-2021 (JDR)

        Added IMPLICIT NONE statement.

        Edited the header to comply with NAIF standard.

-    SPICELIB Version 2.0.1, 22-AUG-2001 (EDW)

        Corrected ENDDO to END DO.

-    SPICELIB Version 2.0.0, 01-SEP-1994 (MJS)

        This version correctly handles negative shifts.

-    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)

        Comment section for permuted index source lines was added
        following the header.

-    SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)