ZyX_I avatar ZyX_I committed 3b2d977

@/base64: Now using built-ins and() and or() if they are available

Comments (0)

Files changed (1)

plugin/frawor/base64.vim

 endif
 let s:F.base64={}
 "▶1 and                :: UInt, UInt → UInt
-function s:F.and(v1, v2)
-    let [v1, v2]=[a:v1, a:v2]
-    let list=[]
-    while v1 || v2
-        let [nv1, nv2]=[v1/2, v2/2]
-        call add(list, ((nv1*2!=v1)&&(nv2*2!=v2)))
-        let [v1, v2]=[nv1, nv2]
-    endwhile
-    let r=0
-    while !empty(list)
-        let r=(r*2) + remove(list, -1)
-    endwhile
-    return r
-endfunction
+if exists('*and')
+    let s:F.and=function('and')
+else
+    function s:F.and(v1, v2)
+        let [v1, v2]=[a:v1, a:v2]
+        let list=[]
+        while v1 || v2
+            let [nv1, nv2]=[v1/2, v2/2]
+            call add(list, ((nv1*2!=v1)&&(nv2*2!=v2)))
+            let [v1, v2]=[nv1, nv2]
+        endwhile
+        let r=0
+        while !empty(list)
+            let r=(r*2) + remove(list, -1)
+        endwhile
+        return r
+    endfunction
+endif
 "▶1 or                 :: UInt, UInt → UInt
-function s:F.or(v1, v2)
-    let [v1, v2]=[a:v1, a:v2]
-    let list=[]
-    while v1 || v2
-        let [nv1, nv2]=[v1/2, v2/2]
-        call add(list, ((nv1*2!=v1)||(nv2*2!=v2)))
-        let [v1, v2]=[nv1, nv2]
-    endwhile
-    let r=0
-    while !empty(list)
-        let r=(r*2) + remove(list, -1)
-    endwhile
-    return r
-endfunction
+if exists('*or')
+    let s:F.or=function('or')
+else
+    function s:F.or(v1, v2)
+        let [v1, v2]=[a:v1, a:v2]
+        let list=[]
+        while v1 || v2
+            let [nv1, nv2]=[v1/2, v2/2]
+            call add(list, ((nv1*2!=v1)||(nv2*2!=v2)))
+            let [v1, v2]=[nv1, nv2]
+        endwhile
+        let r=0
+        while !empty(list)
+            let r=(r*2) + remove(list, -1)
+        endwhile
+        return r
+    endfunction
+endif
 "▶1 base64.decode      :: b64str[, bytearray::Bool] → str | bytearray
 let s:cd64=map(split('|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\]^_`abcdefghijklmnopq',
             \              '\v.@='),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.