mirror of
https://github.com/pocketpy/pocketpy
synced 2026-03-23 21:50:17 +00:00
Compare commits
No commits in common. "24428793fc097b79e75c89350ac4d07f20755eac" and "82b4fff934e22fa37f0e6bce43d541ef2e04c6ca" have entirely different histories.
24428793fc
...
82b4fff934
@ -60,18 +60,16 @@ def filter(f, iterable):
|
|||||||
if f(i):
|
if f(i):
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
class zip:
|
def zip(a, b):
|
||||||
def __init__(self, *iterables):
|
a = iter(a)
|
||||||
self.iterables = [iter(it) for it in iterables]
|
b = iter(b)
|
||||||
|
while True:
|
||||||
def __iter__(self):
|
try:
|
||||||
return self
|
ai = next(a)
|
||||||
|
bi = next(b)
|
||||||
def __next__(self):
|
except StopIteration:
|
||||||
result = []
|
break
|
||||||
for it in self.iterables:
|
yield ai, bi
|
||||||
result.append(next(it))
|
|
||||||
return tuple(result)
|
|
||||||
|
|
||||||
def reversed(iterable):
|
def reversed(iterable):
|
||||||
a = list(iterable)
|
a = list(iterable)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -2301,9 +2301,6 @@ static Error* _compile_f_args(Compiler* self, FuncDecl* decl, bool is_lambda) {
|
|||||||
int state = 0; // 0 for args, 1 for *args, 2 for k=v, 3 for **kwargs
|
int state = 0; // 0 for args, 1 for *args, 2 for k=v, 3 for **kwargs
|
||||||
Error* err;
|
Error* err;
|
||||||
do {
|
do {
|
||||||
// allow trailing comma
|
|
||||||
if(!is_lambda && curr()->type == TK_RPAREN) break;
|
|
||||||
|
|
||||||
if(state >= 3) return SyntaxError(self, "**kwargs should be the last argument");
|
if(state >= 3) return SyntaxError(self, "**kwargs should be the last argument");
|
||||||
if(match(TK_MUL)) {
|
if(match(TK_MUL)) {
|
||||||
if(state < 1)
|
if(state < 1)
|
||||||
|
|||||||
@ -156,17 +156,6 @@ def f(a,
|
|||||||
|
|
||||||
assert f(1, 2) == 3
|
assert f(1, 2) == 3
|
||||||
|
|
||||||
|
|
||||||
# https://github.com/pocketpy/pocketpy/issues/458
|
|
||||||
def f(
|
|
||||||
x: int,
|
|
||||||
y: int,
|
|
||||||
):
|
|
||||||
return x + y
|
|
||||||
|
|
||||||
assert f(1, 2) == 3
|
|
||||||
|
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# f(a=1)
|
# f(a=1)
|
||||||
# exit(1)
|
# exit(1)
|
||||||
|
|||||||
@ -381,21 +381,6 @@ for x, y in zip(d, e):
|
|||||||
# verify that original order and values are retained.
|
# verify that original order and values are retained.
|
||||||
assertEqual(x is y, True)
|
assertEqual(x is y, True)
|
||||||
|
|
||||||
# https://github.com/pocketpy/pocketpy/issues/447
|
|
||||||
names = ["Alice", "Bob", "Charlie"]
|
|
||||||
ages = [25, 30, 35]
|
|
||||||
cities = ["NY", "LA", "SF"]
|
|
||||||
result = []
|
|
||||||
for name, age, city in zip(names, ages, cities):
|
|
||||||
result.append((name, age, city))
|
|
||||||
assertEqual(result, [("Alice", 25, "NY"), ("Bob", 30, "LA"), ("Charlie", 35, "SF")])
|
|
||||||
|
|
||||||
cities.pop()
|
|
||||||
result = []
|
|
||||||
for name, age, city in zip(names, ages, cities):
|
|
||||||
result.append((name, age, city))
|
|
||||||
assertEqual(result, [("Alice", 25, "NY"), ("Bob", 30, "LA")])
|
|
||||||
|
|
||||||
########### test repr#############
|
########### test repr#############
|
||||||
d = deque(range(200))
|
d = deque(range(200))
|
||||||
e = eval(repr(d))
|
e = eval(repr(d))
|
||||||
|
|||||||
@ -187,27 +187,10 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
}
|
}
|
||||||
|
|
||||||
#run-button {
|
#run-button {
|
||||||
padding-left: 20px;
|
padding-left: 10px;
|
||||||
padding-right: 20px;
|
padding-right: 10px;
|
||||||
padding-bottom: 1px;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #007bff;
|
|
||||||
color: #ffffff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
outline: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
#run-button:hover,
|
|
||||||
#run-button:focus {
|
|
||||||
background-color: #0056b3;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
#run-button:active {
|
|
||||||
background-color: #004085;
|
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
||||||
transform: translateY(1px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#code-editor.hljs {
|
#code-editor.hljs {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user