A scripting language that is strongly typed and dynamic language with a simple and well-known syntax, implementing basic compiler techniques that can be used as a reference to teach students or helps enthusiastic programmers to know how backend implementation of a programming language works. The main aim of this language is to provide all the essential features that a modern programming language offers while keeping the code is as minimal as possible.It's also extendable through its Java-Wolf APIs.
Factioral of a num:
#declaring function
func fact(n){
if n<=1 {
return 1
}
return n*fact(n-1)
}
# Getting input from user
n = integer(input())
#Calling and printing fact function
print(fact(n))
QuickSort:
func quickSort(a,l,r){
if l>=r {return ;}
pIndex, i, piv = l, l, r
while i<r{
if a[piv] > a[i]{
a[i], a[pIndex] = a[pIndex], a[i]
pIndex = pIndex + 1
}
i = i+1
}
a[pIndex], a[piv] = a[piv], a[pIndex]
quickSort(a, l, pIndex-1)
quickSort(a, pIndex+1, r)
}
a = [7, 5, 3, 13, 56, 4, 27, 8, 29, 45]
quickSort(a, 0, a.length()-1)
print(a)
KMP(pattern matching algorithm):
func kmpAlgo(text, pattern){
M, N = len(text), len(pattern)
lps = [0]
i, length = 1, 0
N = len(pattern)
while i < N{
if pattern[i] == pattern[length] {
lps.append(length+1)
i , length = i + 1, length + 1
}elif length != 0 {
length = lps[i-1]
}else{
lps.append(0)
i = i+1
}
}
i, length = 0, 0
while i < M{
if text[i] == pattern[length] {
i , length = i + 1, length + 1
}elif length != 0 {
length = lps[i-1]
}else{
i = i+1
}
if length == N {
return i-length
}
}
}
text = input("Enter text: ")
pattern = input("Enter pattern to search: ")
index = kmpAlgo(text, pattern)
print("Text: ",text)
print("Pattern: ", pattern)
print("Pattern found at : ", index)