Naming Conventions

Scalar

Vector

Matrix

Any
rank

Non-
scalar

Boolean

BS

BV

BM

BA

BN

Integer

IS

IV

IM

IA

IN

Float

FS

FV

FM

FA

FN

Numeric

NS

NV

NM

NA

NN

Character

CS

CV

CM

CA

CN

Enclosed
vector

ES

EV

EM

EA

EN

enclosed
Text vector

TS

TV

TM

TA

TN

Simple

SS

SV

SM

SA

SN

Any

AS

AV

AM

AA

AN

phrase e.g.: .X...Y. ⍝ X←BS; Y←IV

combinations: use ISV for Integer scalarvector

B3, I4 &c. to specify higher ranks.

Open full technical reference

DeleteLeadingBlanks

The task to delete leading blanks from a string is a very common one. APL dialects might provide a utility function for this. Common names are rlb (remove leading blanks) and dlb (delete leading blanks).

There are a couple of approaches available but one which is supposed to run in almost all flavours of APL is this one:

      (+/∧\' '=CV)↓CV

Examples

      ⎕FX ⊃'r←dlb cv' 'r←(+/∧\'' ''=cv)↓cv'
      '|',( dlb'    hello world   '),'|'
|hello world   |

Specialities

Dyalog

This dfn (direct function):

      {(+/∧\' '=⍵)↓⍵}

is recognized in Dyalog as an Idiom and therefore recognized as such and executed faster than the ordinary APL expression.

Compatibility

CheckedWith: APL2, APLX, Dyalog, NARS2000

Test Cases

Show test cases

Test
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
⍝⎕ML←3      ⍝ Enable this line in Dyalog APL if appropriate
  ⎕FX ⊃'r←dlb cv' 'r←(+/∧\'' ''=cv)↓cv'
⍝ ---- Start Test cases (do not delete this!)
 ''≡dlb''
 ''≡dlb' '
 'APL'≡dlb' APL'
 'APL is great'≡dlb'  APL is great'
 'APL is great   '≡dlb'  APL is great   '

For details see the PhraseBook/TestCasesGuidelines.

Test my code, both Examples and Test Cases.

See also: DeleteTrailingBlanks and DeleteMultipleBlanks

Mentor: KaiJaeger

Tags: <Blanks> <DeleteBlanks> <RemoveBlanks>


CategoryPhrasesAll - CategoryPhraseCharacterManipulation

phrasebook/deleteleadingblanks (last edited 2012-02-03 21:13:55 by KaiJaeger)