Cambio indirizzo

January 10th, 2006

Il blog ora è qui.

Nuovo costruttore monomio

October 31st, 2005

Ho ottimizzato il costruttore del monomio. Ora non vengono automaticamente incluse le incognite di grado minore o uguale a 0 e il valore dell’attributo “degree” indica il grado complessivo del monomio.

def __init__(self, coefficient, **kwargs):
    self.letteralPart = dict()
    for unknown in kwargs:
        # Doesn't include in the dictionary the unknowns with
        # degree < = 0
        if kwargs[unknown] > 0:
            self.letteralPart[unknown] = kwargs[unknown]

    self.coefficient = Rational(coefficient)

    # Calculates the degree of the monomial
    self.degree = 0
    for unknownDegree in self.letteralPart.values():
        self.degree += unknownDegree

Piccoli monomi crescono

October 30th, 2005

La classe sta venendo su bene: ho fatto qualche modifica al costruttore, ho aggiunto il supporto all’addizione e alla sottrazione di monomi e ho scritto anche qualche test. Prima o poi la metterò on-line…

Monomi con Python

October 30th, 2005

Sto scrivendo una classe per gestire i monomi con Python. Questo è il costruttore:

class Monomial:
    """A class which provides some methods to manage monomials"""

    def __init__(self, coefficient, *args, **kwargs):
        """Build a list which has for first element the
        coefficient of the monomial and for second a dictionary
        that has for keys the unknown quantities and for values
        the grade of the unknown quantities.
        Example:
          >>> myMonomial = Monomial(3, x=1, y=3)
          >>> print myMonomial.structure()
          [3, {'x': 1, 'y': 2}]
          >>> print myMonomial
          3xy^2
         """
        self.letteralPart = {}
        self.coefficient = Rational(coefficient)
        self.monomial = [self.coefficient, self.letteralPart]
        for unknown in kwargs.items():
            ## unknown[0] -> letter of the unknown quantity
            ## unknown[1] -> grade of the unknown quantity
            self.letteralPart[unknown[0]] = unknown[1]

Frazioni con Python

October 30th, 2005

Segnalo questa libreria che estende i tipi di variabili presenti nella distrubuzione standard di Python.

Flock!

October 30th, 2005

Segnalo questo nuovo browser basato su Firefox. Ha un sacco di feature integrate, tipo l’editor di blog, l’interazione con servizi tipo del.icio.us e Flickr!.

Drag ‘n Drop coi CSS

October 29th, 2005

Ecco un utilissimo articolo per creare delle liste ordinabili con il drag ‘n drop degli elementi usando solo CSS e DOM del W3C.

WordPress VS Blogger

October 28th, 2005

Sto migrando da Blogger a WordPress. Ne vale la pena?