comparison src/lib/Utils.luan @ 17:7230c821c368

push fixes
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 Nov 2024 14:44:35 -0700
parents 2da10ece826f
children 7ea33179592a
comparison
equal deleted inserted replaced
16:82b55186a4a0 17:7230c821c368
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local type = Luan.type or error() 3 local type = Luan.type or error()
4 local ipairs = Luan.ipairs or error() 4 local ipairs = Luan.ipairs or error()
5 local pairs = Luan.pairs or error()
5 local set_metatable = Luan.set_metatable or error() 6 local set_metatable = Luan.set_metatable or error()
6 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
7 8
8 9
9 local Utils = {} 10 local Utils = {}
46 else 47 else
47 return {[obj]=true} 48 return {[obj]=true}
48 end 49 end
49 end 50 end
50 51
52 function Utils.set_to_list(set)
53 local list = {}
54 for k, v in pairs(set) do
55 if v then
56 list[#list+1] = k
57 end
58 end
59 return list
60 end
61
62 function Utils.is_in_list(el,list)
63 for _, v in ipairs(list) do
64 if v == el then
65 return true
66 end
67 end
68 return false
69 end
70
51 return Utils 71 return Utils