puk
This commit is contained in:
parent
31515dba8d
commit
f7620b40f3
3
Lec13/go.mod
Normal file
3
Lec13/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.4
|
||||
18
Lec13/main.go
Normal file
18
Lec13/main.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
command := "addition"
|
||||
res := retFunc(command)
|
||||
fmt.Println("Result is ",res(10,30))
|
||||
fmt.Println("Type is %T",res)
|
||||
}
|
||||
|
||||
func retFunc (a string) func(a,b int) int {
|
||||
if a == "addition" {
|
||||
return func(a,b int) int {return a + b}
|
||||
} else {
|
||||
return func(a,b int) int {return a - b}
|
||||
}
|
||||
}
|
||||
3
Lec14/go.mod
Normal file
3
Lec14/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.4
|
||||
27
Lec14/main.go
Normal file
27
Lec14/main.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
A = 10
|
||||
B = 11
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
var constInt8 int8 = A
|
||||
var constString string = strconv.Itoa(A)
|
||||
|
||||
fmt.Println("constInt8 is ",constInt8)
|
||||
fmt.Println("constString is ",constString)
|
||||
|
||||
}
|
||||
|
||||
func checkConst() {
|
||||
if A == 10 {
|
||||
fmt.Printf("a is 10\n")
|
||||
}
|
||||
}
|
||||
3
Lec15/go.mod
Normal file
3
Lec15/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.4
|
||||
41
Lec15/main.go
Normal file
41
Lec15/main.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// var variable int = 30
|
||||
// var pointer *int = &variable
|
||||
|
||||
// fmt.Printf("Type of pointer %T\n",pointer)
|
||||
// fmt.Printf("Value of pointer %v\n",pointer)
|
||||
|
||||
// secondPtr := &pointer
|
||||
// fmt.Println("Pointer to pointer",secondPtr)
|
||||
|
||||
|
||||
// zeroPtr := new(int)
|
||||
// *zeroPtr += 40
|
||||
// fmt.Println("Address is ",*zeroPtr)
|
||||
|
||||
|
||||
// a := 10
|
||||
// c := a
|
||||
// b := &a
|
||||
// *b += 2
|
||||
|
||||
// c++
|
||||
// fmt.Printf("Val of A is %d and val of C is %d\n",a, c)
|
||||
// fmt.Printf("Val of A after changing ref is %d",a)
|
||||
|
||||
sample := 1
|
||||
// samplePtr := &sample
|
||||
fmt.Println("Sample val is",sample)
|
||||
kek(sample)
|
||||
fmt.Println("Sample val is",sample)
|
||||
|
||||
}
|
||||
|
||||
func kek(val int) {
|
||||
fmt.Println("Val of val is",val)
|
||||
val += 100
|
||||
}
|
||||
3
Lec16/go.mod
Normal file
3
Lec16/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.4
|
||||
15
Lec16/main.go
Normal file
15
Lec16/main.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
arr := [3]int{1,2,3}
|
||||
fmt.Println("Initial array is ", arr)
|
||||
mutation(&arr)
|
||||
fmt.Println("Modified array is ", arr)
|
||||
}
|
||||
|
||||
func mutation(arr *[3]int) {
|
||||
(*arr)[0] = 900
|
||||
(*arr)[2] = 1000
|
||||
}
|
||||
3
Lec17/go.mod
Normal file
3
Lec17/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module main.go
|
||||
|
||||
go 1.24.4
|
||||
3
Lec17/main.go
Normal file
3
Lec17/main.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package main
|
||||
|
||||
func main() { }
|
||||
Loading…
Reference in New Issue
Block a user