File: integer_cats.py

package info (click to toggle)
ats2-lang 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,064 kB
  • sloc: ansic: 389,637; makefile: 7,123; lisp: 812; sh: 657; php: 573; python: 387; perl: 365
file content (98 lines) | stat: -rw-r--r-- 2,784 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
######
#
# HX-2014-08:
# for Python code translated from ATS
#
######

######
#beg of [integer_cats.py]
######

############################################
#
def ats2pypre_abs_int0(x): return abs(x)
#
############################################
#
def ats2pypre_neg_int0(x): return ( -x )
def ats2pypre_neg_int1(x): return ( -x )
#
############################################
#
def ats2pypre_succ_int0(x): return (x + 1)
def ats2pypre_succ_int1(x): return (x + 1)
#
def ats2pypre_pred_int0(x): return (x - 1)
def ats2pypre_pred_int1(x): return (x - 1)
#
############################################
#
def ats2pypre_half_int0(x): return (x // 2)
def ats2pypre_half_int1(x): return (x // 2)
#
############################################
#
def ats2pypre_add_int0_int0(x, y): return (x + y)
def ats2pypre_add_int1_int1(x, y): return (x + y)
#
def ats2pypre_sub_int0_int0(x, y): return (x - y)
def ats2pypre_sub_int1_int1(x, y): return (x - y)
#
def ats2pypre_mul_int0_int0(x, y): return (x * y)
def ats2pypre_mul_int1_int1(x, y): return (x * y)
#
def ats2pypre_div_int0_int0(x, y): return (x // y)
def ats2pypre_div_int1_int1(x, y): return (x // y)
#
def ats2pypre_mod_int0_int0(x, y): return (x % y)
def ats2pypre_mod_int1_int1(x, y): return (x % y)
def ats2pypre_nmod_int1_int1(x, y): return (x % y)
#
############################################
#
def ats2pypre_lt_int0_int0(x, y): return (x < y)
def ats2pypre_lt_int1_int1(x, y): return (x < y)
#
def ats2pypre_lte_int0_int0(x, y): return (x <= y)
def ats2pypre_lte_int1_int1(x, y): return (x <= y)
#
def ats2pypre_gt_int0_int0(x, y): return (x > y)
def ats2pypre_gt_int1_int1(x, y): return (x > y)
#
def ats2pypre_gte_int0_int0(x, y): return (x >= y)
def ats2pypre_gte_int1_int1(x, y): return (x >= y)
#
def ats2pypre_eq_int0_int0(x, y): return (x == y)
def ats2pypre_eq_int1_int1(x, y): return (x == y)
#
def ats2pypre_neq_int0_int0(x, y): return (x != y)
def ats2pypre_neq_int1_int1(x, y): return (x != y)
#
############################################
#
def ats2pypre_compare_int0_int0(x, y):
  return -1 if (x < y) else (1 if (x > y) else 0)
#
############################################
#
def ats2pypre_max_int0_int0(x, y): return (max(x, y))
def ats2pypre_max_int1_int1(x, y): return (max(x, y))
#
def ats2pypre_min_int0_int0(x, y): return (min(x, y))
def ats2pypre_min_int1_int1(x, y): return (min(x, y))
#
############################################
#
# HX-2016-06
# The code is in print_cats.py:
#
# def ats2pypre_print_int(i):
#   return ats2pypre_fprint_int(sys.__stdout__, i)
# def ats2pypre_prerr_int(i):
#   return ats2pypre_fprint_int(sys.__stderr__, i)
# def ats2pypre_fprint_int(out, i): return ats2pypre_fprint_obj(out, i)
#
############################################

###### end of [integer_cats.py] ######