Skip to content

Multilingual library for various utility features

Notifications You must be signed in to change notification settings

Toma400/Lapis_Tower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lapis

Lapis is multilingual mini-library directed at four languages: Odin, Nim, Ruby and Go. It is made purely out of necessity of simplifying some basic features that are missing in those languages, or are made in a way that makes them annoying.

How to use Lapis

Lapis is not the same for all languages, as it is made to supply them with language-specific set of tools that were not available at the time.

Therefore, you can look at the table to see features Lapis adds:

Language Features Description
Odin ✤ gets (?str) ✤ Python-like input, returning string value
✤ puts (?str) ✤ Terminal output
Go ✤ Gets ( ) ✤ Pure input, without print provided
✤ Getsb (str) ✤ Python-like input, returning string value
✤ Puts (str) ✤ Terminal output from string
Nim ✤ conc (OrderedTable
    [int, string] )
✤ Returns string from given string table
✤ ti (str) ✤ Shortcut conversion of string to int
✤ ts (int) ✤ Shortcut conversion of int to string
Ruby ✤ gets! (?str) ✤ Updated gets which prints given optional string
Zig TBA TBA

Odin

Write following import on top of everything:

import "lapis"

then, in scope you want to use Lapis functionalities, write scope importing:

using lapis

Now, you are able to use all features from the library. To showcase that, here is short example which prints code inputted by user:

package main

import "lapis"

main :: proc() {
    using lapis
    sth := lapis.gets("Please provide text:")
    lapis.puts(sth)
}

Nim

To use library in Nim, add simple import call on top (example assume that you use Lapis in the same directory as your main .nim file):

import lapis

var some_int = 5
var some_tb = {1: "Here I see ", 2: ts(some_int), 3: " monsters!"}.toOrderedTable

echo conc(some_tb)

Ruby

In Ruby, you can use this code on top of the file, which will direct Ruby to the folder with lapis.rb file:

require_relative "lapis/lapis.rb"

However, if you want to bring the file out of the folder, to be neighbouring to the script you write in, you can do that and slightly modify import statement:

require_relative "./lapis.rb"

Go

In Go, import statement are rather complicated. Assuming you put Lapis in folder, so structure of the file looks like this:

project_dir
  |
  |--- lapis
  |      \--- lapis.go
  |
  \--- main.go

You need to write such import in main.go:

import (
  "test/lapis"
)

Where test is name of our go.mod package, so edit it accordingly. Then, we can use Lapis functions as such:

lapis.Puts("Hello!")
a := lapis.Gets()
b := lapis.Getsb("Please provide some words: ")

Mind that Golang requests functions imported to be capitalised, so for it to work properly you need to use them in such way.

About

Multilingual library for various utility features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published