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

23
LINES

< > TinyBrain | #1001518 - l function (synonym of length), length of arrays, strings, lists, size of maps

JavaX fragment (include)

static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(bool[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); } static long l(File f) { ret f == null ? 0 : f.length(); }

static int l(Object o) {
  ret o instanceof S ? l((S) o)
    : o instanceof Map ? l((Map) o)
    : l((Collection) o); // incomplete
}

ifclass MultiSet
  static int l(MultiSet ms) { ret ms == null ? 0 : ms.size(); }
endif

ifclass Lisp
  static int l(Lisp l) { ret l == null ? 0 : l.size(); }
endif

Author comment

Began life as a copy of #1001516

download  show line numbers  debug dex   

Travelled to 5 computer(s): cfunsshuasjs, ddnzoavkxhuk, onxytkatvevr, tvejysmllsmz, wtqryiryparv

No comments. add comment

Snippet ID: #1001518
Snippet name: l function (synonym of length), length of arrays, strings, lists, size of maps
Eternal ID of this version: #1001518/7
Text MD5: e74e86883d061d08a5e905002b800b68
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-22 15:18:16
Source code size: 930 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 264 / 8147
Version history: 6 change(s)
Referenced in: [show]