Files

bltings.src
  • //Max Function
  • list.max = function
  • return self[0:].sort[-1]
  • end function
  • map.max = function
  • Items = self.values
  • return self.indexes[Items.indexOf(Items.max)]
  • end function
  • //MaxIndex Function
  • list.maxIndex = function
  • return self.indexOf(self.max)
  • end function
  • //Min Function
  • list.min = function
  • return self[0:].sort[0]
  • end function
  • map.min = function
  • Items = self.values
  • return self.indexes[Items.indexOf(Items.max)]
  • end function
  • //MinIndex Function
  • list.minIndex = function
  • return self.indexOf(self.min)
  • end function
  • //Delete Function
  • list.delete = function(item)
  • if self.indexOf(item) != null then self.remove(self.indexOf(item))
  • return self
  • end function
  • //DeleteAll Function
  • list.deleteAll = function(item)
  • if self.indexOf(item) == null then return self
  • while self.indexOf(item) != null
  • self.delete(item)
  • end while
  • return self
  • end function
  • //Set Function
  • list.set = function
  • Values = []
  • for i in self
  • if Values.indexOf(i) == null then Values.push(i)
  • end for
  • return Values
  • end function
  • //Count Function
  • list.count = function(item)
  • return self.len - self[0:].deleteAll(item).len
  • end function
  • map.count = function(item)
  • return str(self[item]).len
  • end function
  • //Mean Function
  • list.mean = function
  • return sum(self) / self.len
  • end function
  • //Median Function
  • list.median = function
  • if self.len % 2 == 0 then
  • x = self.len / 2
  • return sum(self[0:]).sort[x : x + 1] / 2
  • end if
  • return self[0:].sort[floor(round(self.len / 2))]
  • end function
  • //Mode Function
  • list.mode = function
  • Items = self[0:].set
  • Counts = []
  • for i in Items
  • Counts.push(Items.count(i))
  • end for
  • return Counts[Counts.maxIndex]
  • end function
  • //ApplyFunction Function
  • list.applyFunction = function(func)
  • for i in range(self.len - 1)
  • self[i] = func(self[i])
  • end for
  • return self
  • end function
  • //Factors Function
  • factors = function(value)
  • Temp = []
  • for i in range(1, floor(sqrt(value)) + 1)
  • if value % i == 0 then Temp.push([i, floor(value / i)])
  • end for
  • Factors = []
  • for pair in Temp
  • for item in pair
  • Factors.push(item)
  • end for
  • end for
  • return Factors.set.sort
  • end function
  • number.factors = function
  • return factors(self)
  • end function
  • //FactorsPrime Function
  • factorsPrime = function(number)
  • Factors = [1]
  • while not isPrime(number)
  • number = floor(number / Factors[-1])
  • for i in factors(number)
  • if isPrime(i) then
  • Factors.push(i)
  • break
  • end if
  • end for
  • end while
  • return Factors[1:]
  • end function
  • number.factorsPrime = function
  • return factorsPrime(self)
  • end function
  • //IsPrime Function
  • isPrime = function(number)
  • if number == 1 then return false
  • return factors(number).len == 2
  • end function
  • number.isPrime = function
  • return isPrime(self)
  • end function
  • //GreatestCommonFactor Function
  • greatestCommonFactor = function(Values)
  • Items = Values[0:]
  • for i in range(Items.len - 1)
  • Items[i] = factors(Items[i])
  • end for
  • FactorAmounts = []
  • for item in Items
  • FactorAmounts.push(item.len)
  • end for
  • smallest = Items[FactorAmounts.minIndex]
  • Items.delete(smallest)
  • Data = []
  • for small in smallest
  • Temp = []
  • for item in Items
  • if item.indexOf(small) != null then Temp.push(true)
  • end for
  • if Temp.len > 0 then
  • if Temp.count(true) == Items.len then Data.push(small)
  • end if
  • end for
  • return Data.max
  • end function
  • //Decimal to Percent Function
  • decimalpercent = function(value)
  • return value * 100
  • end function
  • number.decimalpercent = function
  • return self * 100
  • end function
  • //Percent to Decimal Function
  • percentdecimal = function(value)
  • return value / 100
  • end function
  • number.percentdecimal = function
  • return self / 100
  • end function
  • //Percent to Multiplier Function
  • percentmultiplier = function(value)
  • return percentdecimal(value) + 1
  • end function
  • number.percentmultiplier = function
  • return percentdecimal(self) + 1
  • end function
  • //Multiplier to Percent Function
  • multiplierpercent = function(value)
  • return decimalpercent(value - 1)
  • end function
  • number.multiplierpercent = function
  • return decimalpercent(self - 1)
  • end function
  • //Decimal to Fraction Function
  • decimalfraction = function(value)
  • value = str(value).split("\.")
  • if value.len == 0 then return value[0]
  • denominator = 10 ^ value[1].len
  • numerator = value[1].to_int + (value[0].to_int * denominator)
  • factor = greatestCommonFactor([numerator, denominator])
  • numerator = floor(numerator / factor)
  • denominator = floor(denominator / factor)
  • return numerator + "/" + denominator
  • end function
  • number.decimalfraction = function
  • return decimalfraction(self)
  • end function
  • //Decimal to Base Function
  • decimalToBase = function(value, base)
  • digits = []
  • while value > 0
  • digits.push(floor(value % base))
  • value = floor(value / base)
  • end while
  • digits.reverse
  • return digits
  • end function
  • //Hex Function
  • hex = function(value)
  • dectohex = function(n)
  • if n < 10 then return n else return char(n + 87)
  • end function
  • return decimalToBase(value, 16).applyFunction(@dectohex).join("")
  • end function
  • //Binary function
  • bin = function(value)
  • return decimalToBase(value, 2).join("")
  • end function
  • //Binary function
  • oct = function(value)
  • return decimalToBase(value, 8).join("")
  • end function
  • //Capitalize Function
  • string.capitalize = function(self)
  • return self[0].upper + self[1:]
  • end function
  • //RFill Function
  • string.rfill = function(amount, filler = "0")
  • return self + filler * [0, amount - self.len].max
  • end function
  • //LFill Function
  • string.lfill = function(amount, filler = "0")
  • return filler * [0, amount - self.len].max + self
  • end function
  • //Format Function
  • string.format = function(Variables)
  • x = 0
  • while not self.indexOf("{}") == null
  • i = self.indexOf("{}")
  • self = self[0:i] + Variables[x] + self[i + 2:]
  • x = x + 1
  • end while
  • return self
  • end function
  • //Group Function
  • string.group = function(groupsize)
  • strings = []
  • for i in range(0, str(self).len, groupsize)
  • strings.push(str(self)[i : [i + groupsize, str(self).len].min])
  • end for
  • return strings
  • end function
  • //All Function
  • all = function(Values)
  • for item in Values
  • if not item then return false
  • end for
  • return true
  • end function
  • list.all = function
  • return all(self)
  • end function
  • //Any Function
  • any = function(Values)
  • for item in Values
  • if item then return true
  • end for
  • return false
  • end function
  • list.any = function
  • return any(self)
  • end function
  • //Folder Count Function
  • foldercount = function(folder)
  • if is_folder(file) then return file.get_folders.len else return null
  • end function
  • //File Count Function
  • filecount = function(folder)
  • if is_folder(file) then return file.get_files.len else return null
  • end function
  • //Open Ports Function
  • open_ports = function(router)
  • ports = []
  • for port in router.used_ports
  • if not port.is_closed then ports.push(port)
  • end for
  • return ports
  • end function
  • //Closed Ports Function
  • closed_ports = function(router)
  • ports = []
  • for port in router.used_ports
  • if port.is_closed then ports.push(port)
  • end for
  • return ports
  • end function
  • //File Hash Function
  • filehash = function(file)
  • return md5(file.get_content)
  • end function
  • //Folder Hash Function
  • folderhash = function(folder)
  • content = ""
  • for folder in folder.get_folders
  • content = "{}:{}".format([content,folder.path])
  • end for
  • for file in folder.get_files
  • content = "{}:{}".format([content,file.path])
  • end for
  • return md5(content)
  • end function
  • //String to List Function
  • string.list = function
  • stringlist = []
  • for i in self
  • stringlist.push(i)
  • end for
  • return stringlist
  • end function
  • //Base to Decimal Function
  • baseToDecimal = function(value, base)
  • valuestring = value.list
  • valuestring.reverse
  • for i in range(valuestring.len - 1)
  • valuestring[i] = to_int(valuestring[i])
  • if typeof(valuestring[i]) == "string" then valuestring[i] = valuestring[i].code - 87
  • end for
  • for i in range(0, valuestring.len - 1)
  • valuestring[i] = valuestring[i] * (base ^ i)
  • end for
  • return sum(valuestring)
  • end function
  • //Has Item Function
  • list.hasItem = function(item)
  • return self.indexOf(item) != null
  • end function