Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1004488 // aToAn - convert "a" to "an" where appropriate anywhere in string

JavaX fragment (include)

static S aToAn(S s) {
  ret jreplaceIC(s, "a", "an", new O {
    bool get(L<S> tok, int i) {
      S w = _get(tok, i+3);
      if (w == null) false;
      w = toLower(unquote(w));
      if (empty(w)) false;
      if (startsWith(w, "x ")) true; // what?
      ret contains("aeiou", w.charAt(0)); // rough
    }
  });
}

Author comment

Began life as a copy of #1004475

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004488
Snippet name: aToAn - convert "a" to "an" where appropriate anywhere in string
Eternal ID of this version: #1004488/6
Text MD5: 1df3ee8463253deba19b681b6182362e
Author: stefan
Category: javax / talking robots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-24 01:41:01
Source code size: 328 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 565 / 568
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)