Merge pull request #2 from viniciusfdasilva/dev

Dev
This commit is contained in:
Vinicius Silva 2023-12-22 23:55:43 -03:00 committed by GitHub
commit 506b9ce468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 128 additions and 23 deletions

View File

@ -1,20 +0,0 @@
import math
const pi = math.pi
pub fn main()
{
// Por padrão os valores são criados como imutável
immutable := pi
println('${immutable}')
// Para se tornar variável basta inserir a palavra reservada 'mut'
mut mutable := 23.2
print('${mutable}\n')
mutable = pi
print('${mutable}\n')
}

59
03_variables/types.v Normal file
View File

@ -0,0 +1,59 @@
const min_i8 := i8(-128)
const max_i8 := i8(127)
const min_i16 := i16(-32768)
const max_i16 := i16(32767)
const min_i32 := i32(-2147483648)
const max_i32 := i32(2147483647)
const min_i64 := i64(-9223372036854775807 - 1)
const max_i64 := i64(9223372036854775807)
const mix_u8 := u8(0)
const mix_u16 := u16(0)
const mix_u32 := u32(0)
const mix_u64 := u64(0)
const max_u8 := u8(127)
const max_u16 := u16(32767)
const max_u32 := u32(2147483647)
const max_u64 := u64(9223372036854775807)
fn main()
{
mut integer := int(20)
mut flt32 := f32(2)
mut flt64 := f64(3)
println(flt32)
println(flt64)
println(integer)
println(min_i8)
println(max_i8)
println(min_i16)
println(max_i16)
println(min_i32)
println(max_i32)
println(min_i64)
println(max_i64)
println(min_u8)
println(max_u8)
println(min_u16)
println(max_u16)
println(min_u32)
println(max_u32)
println(min_u64)
println(max_u64)
}

43
03_variables/values.v Normal file
View File

@ -0,0 +1,43 @@
import math
const pi = math.pi
pub fn main()
{
// Por padrão os valores são criados como imutável
immutable := pi
println('${immutable}')
// Para se tornar variável basta inserir a palavra reservada 'mut'
mut mutable := 23.2
print('${mutable}\n')
mutable = pi
print('${mutable}\n')
a, c, d := 3, 2, 5
mut i, mut j := 'Hi', 'Hello'
println("${a} ${c} ${d}")
println("${i} ${j}")
mut greet := 'Here'
greet = greet + ' there and Everywhere'
println("${greet}")
greet += ' Hope yout have a great day!'
println("${greet}")
mut is_false := false
mut is_true := true
println(is_false)
println(is_true)
}

26
04_comments/main.v Normal file
View File

@ -0,0 +1,26 @@
/*
multiply accepts two integers arguments namely x and y
It then performs multiplication of input arguments and
return the product which is again a type of integer as
specified in the function signature
x is an input argumento accepts values of type of int
y is an input argument accepts values of type of int
multiply functions returns the result of type int which
is a multiplication of input arguments x and y
*/
fn multiply(x int, y int) int
{
return x * y
}
// main function callable by operating system
pub fn main()
{
println("Hello world")
println(multiply(2,4))
}

View File

@ -1,6 +1,3 @@
pub fn main() {
println('oi')
}