This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import pygame | |
from pygame.locals import * | |
class SpinningCircle(pygame.surface.Surface): | |
''' | |
Class which make a spinning circle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nickname = r'[\w\x5b-\x60\x7b-\x7d]+' | |
username = r'[-+~=^]?[^@\s]+' | |
hostname = r'(?:\w|\d)+(?:[-.=](?:\w|\d)+)*' | |
mask = r'([\w\x5b-\x60\x7b-\x7d]+)(?:(?:!([-+~=^]?[^@\s]+))?@((?:\w|\d)+(?:[-.=](?:\w|\d)+)*))?' | |
servername = r'(?:\w|\d)+(?:[-.](?:\w|\d)+)*' | |
prefix = r'[\w\x5b-\x60\x7b-\x7d]+(?:(?:![-+~=^]?[^@\s]+)?@(?:\w|\d)+(?:[-.=](?:\w|\d)+)*)?|(?:\w|\d)+(?:[-.](?:\w|\d)+)*' | |
command = r'[A-Z]+|[0-9]{3}' | |
parametres = r'[^:]+' | |
trailing = r':(.+)' | |
message = r'^(?::([\w\x5b-\x60\x7b-\x7d]+(?:(?:![-+~=^]?[^@\s]+)?@(?:\w|\d)+(?:[-.=](?:\w|\d)+)*)|(?:\w|\d)+(?:[-.](?:\w|\d)+)*)\s)?([A-Z]+|[0-9]{3})(?: ([^:]+))?(?: :(.+))?$' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import pygame | |
import itertools | |
from pygame.locals import * | |
NULLCHAR = '\0' | |
BACKSPACE = '\b' | |
LEFT = '\1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
BUSYMSG = '\033[1;34m[\033[1;m\033[1;36mBUSY\033[1;m\033[1;34m]\033[1;m' | |
DONEMSG = '\033[1;34m[\033[1;m\033[1;35mDONE\033[1;m\033[1;34m]\033[1;m' | |
FAILMSG = '\033[1;34m[\033[1;m\033[1;31mFAIL\033[1;m\033[1;34m]\033[1;m' | |
def showstatus(message=None, length=50): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import ceil | |
class Range(object): | |
''' | |
Range(start, stop, step) returns the arithmetic progression | |
of numbers, whose lenght is ceil((stop - start) / step) and | |
whose form [start, start + (step * 1), ..., start + (step * | |
(len(obj) - 1)]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define range | |
(case-lambda | |
((stop) (range 0 stop 1)) | |
((start stop) (range start stop 1)) | |
((start stop step) (list 'range start stop step)))) | |
(define range? | |
(lambda (obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In memoria della programmazione funzionale, che qui giace | |
import sys | |
import tty | |
import termios | |
def write(string): | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define expr-operator | |
(lambda (expr) | |
(car (cdr expr)))) | |
(define expr-operand1 | |
(lambda (expr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
class TuringMachine(object): | |
''' | |
This class implements Turing Machine developed by Alan | |
Turing in 1936. It has to receive two arguments: an | |
iterable object for the initial configuration of the | |
infinite tape and a list of 5-elements tuple for the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-syntax lambda-curried | |
(syntax-rules () | |
((_ (a ...) b ...) | |
(letrec | |
((curry (lambda (func . passed-args) | |
(if (>= (length passed-args) (length '(a ...))) | |
(apply func passed-args) | |
(lambda new-args | |
(apply curry (cons func (append passed-args new-args)))))))) | |
(curry (lambda (a ...) b ...)))))) |
NewerOlder