@@ -727,10 +727,10 @@ package main
727
727
import " fmt"
728
728
729
729
func main () {
730
- a := map [interface {} ]struct {}{1 : {}, 2 : {}, 3 : {}, 4 : {}}
731
- b := map [interface {} ]struct {}{4 : {}, 5 : {}, 6 : {}}
730
+ a := map [int ]struct {}{1 : {}, 2 : {}, 3 : {}, 4 : {}}
731
+ b := map [int ]struct {}{4 : {}, 5 : {}, 6 : {}}
732
732
b[7 ] = struct {}{}
733
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) map [interface {}]struct {} {
733
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) map [interface {}]struct {} {
734
734
union := map [interface {}]struct {}{}
735
735
for elt := range s1 {
736
736
union[elt] = struct {}{}
@@ -740,7 +740,7 @@ func main() {
740
740
}
741
741
return union
742
742
}(a, b))
743
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) map [interface {}]struct {} {
743
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) map [interface {}]struct {} {
744
744
intersection := map [interface {}]struct {}{}
745
745
for elt := range s1 {
746
746
if func () bool {
@@ -752,7 +752,7 @@ func main() {
752
752
}
753
753
return intersection
754
754
}(a, b))
755
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) map [interface {}]struct {} {
755
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) map [interface {}]struct {} {
756
756
difference := map [interface {}]struct {}{}
757
757
for elt := range s1 {
758
758
if !func () bool {
@@ -764,7 +764,7 @@ func main() {
764
764
}
765
765
return difference
766
766
}(a, b))
767
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) map [interface {}]struct {} {
767
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) map [interface {}]struct {} {
768
768
symmetric_difference := map [interface {}]struct {}{}
769
769
for elt := range s1 {
770
770
if !func () bool {
@@ -784,7 +784,7 @@ func main() {
784
784
}
785
785
return symmetric_difference
786
786
}(a, b))
787
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) bool {
787
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) bool {
788
788
for elt := range s1 {
789
789
if !func () bool {
790
790
_ , ok := s2[elt]
@@ -795,7 +795,7 @@ func main() {
795
795
}
796
796
return true
797
797
}(a, b))
798
- fmt.Println (func (s1 map [interface {} ]struct {}, s2 map [interface {} ]struct {}) bool {
798
+ fmt.Println (func (s1 map [int ]struct {}, s2 map [int ]struct {}) bool {
799
799
for elt := range s2 {
800
800
if !func () bool {
801
801
_ , ok := s1[elt]
@@ -2036,7 +2036,7 @@ package main
2036
2036
import " fmt"
2037
2037
2038
2038
func main () {
2039
- s := map [interface {} ]struct {}{1 : {}, 2 : {}, 3 : {}}
2039
+ s := map [int ]struct {}{1 : {}, 2 : {}, 3 : {}}
2040
2040
x := 1
2041
2041
fmt.Println (len (s))
2042
2042
fmt.Println (func () bool {
@@ -2116,7 +2116,7 @@ func main() {
2116
2116
b := " hello world"
2117
2117
fmt.Println (strings.Contains (b, " hello" ))
2118
2118
fmt.Println (!strings.Contains (b, " Hello" ))
2119
- c := map [interface {}] interface {} {" hello" : 1 , " world" : 2 }
2119
+ c := map [string ] int {" hello" : 1 , " world" : 2 }
2120
2120
fmt.Println (func () bool {
2121
2121
_ , ok := c[" hello" ]
2122
2122
return ok
@@ -2393,11 +2393,9 @@ package main
2393
2393
import " fmt"
2394
2394
2395
2395
var (
2396
- SITE = " https://www.google.com/"
2397
- NAME = []string {" Michael" , " Wayne" , " Phelps" }
2398
- KEYS = map [interface {}]interface {}{1 : 2 , 3 : 4 }
2399
- )
2400
- var (
2396
+ SITE = " https://www.google.com/"
2397
+ NAME = []string {" Michael" , " Wayne" , " Phelps" }
2398
+ KEYS = map [int ]int {1 : 2 , 3 : 4 }
2401
2399
AGE = 1000
2402
2400
BIRTH_YEAR = 2050
2403
2401
)
@@ -2851,13 +2849,13 @@ func main() {
2851
2849
if q := map [interface {}]struct {}{}; len (q) != 0 {
2852
2850
fmt.Println (q)
2853
2851
}
2854
- if r := map [interface {} ]struct {}{1 : {}, 2 : {}, 3 : {}}; len (r) != 0 {
2852
+ if r := map [int ]struct {}{1 : {}, 2 : {}, 3 : {}}; len (r) != 0 {
2855
2853
fmt.Println (r)
2856
2854
}
2857
2855
if s := map [interface {}]interface {}{}; len (s) != 0 {
2858
2856
fmt.Println (s)
2859
2857
}
2860
- if t := map [interface {}] interface {} {1 : 2 }; len (t) != 0 {
2858
+ if t := map [int ] int {1 : 2 }; len (t) != 0 {
2861
2859
fmt.Println (t)
2862
2860
}
2863
2861
}
@@ -3501,6 +3499,68 @@ func main() {
3501
3499
}
3502
3500
}
3503
3501
```
3502
+ ### timemodule
3503
+ #### Python
3504
+ ``` python
3505
+ import time
3506
+
3507
+ def main ():
3508
+ print (" Hello" )
3509
+ time.sleep(3 )
3510
+ print (" ... time!" )
3511
+
3512
+
3513
+ if __name__ == ' __main__' :
3514
+ main()
3515
+ ```
3516
+ #### Go
3517
+ ``` go
3518
+ package main
3519
+
3520
+ import (
3521
+ " fmt"
3522
+ " time"
3523
+ )
3524
+
3525
+ func main () {
3526
+ fmt.Println (" Hello" )
3527
+ time.Sleep (3 * time.Second )
3528
+ fmt.Println (" ... time!" )
3529
+ }
3530
+ ```
3531
+ ### exit
3532
+ #### Python
3533
+ ``` python
3534
+ import sys
3535
+
3536
+
3537
+ def main ():
3538
+ quit ()
3539
+ quit (1 )
3540
+ exit ()
3541
+ exit (1 )
3542
+ sys.exit()
3543
+ sys.exit(1 )
3544
+
3545
+
3546
+ if __name__ == ' __main__' :
3547
+ main()
3548
+ ```
3549
+ #### Go
3550
+ ``` go
3551
+ package main
3552
+
3553
+ import " os"
3554
+
3555
+ func main () {
3556
+ os.Exit (0 )
3557
+ os.Exit (1 )
3558
+ os.Exit (0 )
3559
+ os.Exit (1 )
3560
+ os.Exit (0 )
3561
+ os.Exit (1 )
3562
+ }
3563
+ ```
3504
3564
### algomajorityelement
3505
3565
#### Python
3506
3566
``` python
@@ -3581,48 +3641,33 @@ func main() {
3581
3641
}())
3582
3642
}
3583
3643
```
3584
- ### timemodule
3644
+ ### retroactive_composite_types
3585
3645
#### Python
3586
3646
``` python
3587
- import time
3588
-
3589
3647
def main ():
3590
- print (" Hello" )
3591
- time.sleep(3 )
3592
- print (" ... time!" )
3648
+ a = []
3649
+ a.append(3 )
3593
3650
3651
+ b = []
3652
+ b += a
3594
3653
3595
- if __name__ == ' __main__' :
3596
- main()
3597
- ```
3598
- #### Go
3599
- ``` go
3600
- package main
3654
+ c = {}
3655
+ c[" hello" ] = 1
3601
3656
3602
- import (
3603
- " fmt"
3604
- " time"
3605
- )
3657
+ d = {}
3658
+ d[1 ] = 2
3659
+ d[" gonna_be_an_interface" ] = " yup"
3606
3660
3607
- func main () {
3608
- fmt.Println (" Hello" )
3609
- time.Sleep (3 * time.Second )
3610
- fmt.Println (" ... time!" )
3611
- }
3612
- ```
3613
- ### exit
3614
- #### Python
3615
- ``` python
3616
- import sys
3661
+ e = set ()
3662
+ e.add(1 )
3617
3663
3664
+ f = [[]]
3665
+ f[0 ].append(1 )
3618
3666
3619
- def main ():
3620
- quit ()
3621
- quit (1 )
3622
- exit ()
3623
- exit (1 )
3624
- sys.exit()
3625
- sys.exit(1 )
3667
+ g = {}
3668
+ g[(1 , 2 )] = 3
3669
+
3670
+ print (a, b, c, d, e, f, g)
3626
3671
3627
3672
3628
3673
if __name__ == ' __main__' :
@@ -3632,15 +3677,25 @@ if __name__ == '__main__':
3632
3677
``` go
3633
3678
package main
3634
3679
3635
- import " os "
3680
+ import " fmt "
3636
3681
3637
3682
func main () {
3638
- os.Exit (0 )
3639
- os.Exit (1 )
3640
- os.Exit (0 )
3641
- os.Exit (1 )
3642
- os.Exit (0 )
3643
- os.Exit (1 )
3683
+ a := []int {}
3684
+ a = append (a, 3 )
3685
+ b := []int {}
3686
+ b = append (b, a...)
3687
+ c := map [string ]int {}
3688
+ c[" hello" ] = 1
3689
+ d := map [interface {}]interface {}{}
3690
+ d[1 ] = 2
3691
+ d[" gonna_be_an_interface" ] = " yup"
3692
+ e := map [int ]struct {}{}
3693
+ e[1 ] = struct {}{}
3694
+ f := [][]int {{}}
3695
+ f[0 ] = append (f[0 ], 1 )
3696
+ g := map [[2 ]int ]int {}
3697
+ g[[2 ]int {1 , 2 }] = 3
3698
+ fmt.Println (a, b, c, d, e, f, g)
3644
3699
}
3645
3700
```
3646
3701
0 commit comments