Exemplo n.º 1
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel: example (jul 2017).
"""

from popeel import Popeel

Popeel.set_task(8)  # set the task: please peel 8 potatoes

Popeel.peel_1_potato()  # main operation, peels one potato from the basket

Popeel.refill_basket(
)  # go to the main store and fetch some potatoes with the basket

Popeel.discard_basket()  # returns potatoes from the basket to the main store

Popeel.enough_potatoes()  # Boolean: task achieved?

Popeel.is_basket_empty()  # Boolean: is Popeel's basket out of potatoes?

Popeel.go_sleep()  # Popeel is asleep from that point on
Exemplo n.º 2
0
from popeel import Popeel
popeeler = Popeel()
while popeeler.enough_potatoes():
    if popeeler.enough_potatoes():
        while not not popeeler.enough_potatoes():
            while not popeeler.enough_potatoes() or popeeler.enough_potatoes():
                popeeler.peel_1_potato()
        while popeeler.enough_potatoes():
            popeeler.refill_basket()
Exemplo n.º 3
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel with a variable: example (feb, oct 2017).
"""

from popeel import Popeel

p = Popeel() # will tell us how many potatoes are in the basket initially

p.set_task(8) # set the task: please peel 8 potatoes

p.peel_1_potato() # main operation, peels one potato from the basket

print(p.enough_potatoes()) # Boolean: task achieved?

print(p.is_basket_empty()) # Boolean: is Popeel's basket out of potatoes?

print(not p.is_basket_empty()) # Boolean: does Popeel still have potatoes in the basket?

p.refill_basket() # go to the main store and fetch some potatoes with the basket

p.discard_basket() # returns potatoes from the basket to the main store

p.go_sleep() # Popeel is asleep from that point on

Exemplo n.º 4
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 (feb 2017)
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Ignore this file if you want to contribute to Suverat.

One correct usage of Popeel.

Spoiler. 

Don't read this code.

Hidden in a different project (Suverat) and in some Dropbox so as to
avoid its visibility from the standard Popeel users.
"""

from popeel import Popeel

p = Popeel()
p.set_task(12)
while not p.enough_potatoes():
    if p.basket_is_empty():
        p.refill_basket()
    p.peel_1_potato()
p.discard_basket()
p.go_sleep()
Exemplo n.º 5
0
from popeel import Popeel

popeeler = Popeel()
if popeeler.enough_potatoes():
    popeeler.refill_basket()
else:
    while popeeler.enough_potatoes() or popeeler.is_basket_empty(
    ) and popeeler.enough_potatoes() and not popeeler.enough_potatoes():
        popeeler.refill_basket()
    if popeeler.basket_is_empty():
        while popeeler.enough_potatoes():
            popeeler.peel_1_potato()
            popeeler.refill_basket()
            popeeler.go_sleep()
        popeeler.peel_1_potato()