Search Results

Search found 4 results on 1 pages for 'carles araguz'.

Page 1/1 | 1 

  • Is this a good implementation of a loop in Prolog?

    - by Carles Araguz
    First of all, let me tell you that this happens to be the first time I ask something here, so if it's not the right place to do so, please forgive me. I'm developing a rather complex software that has a Prolog core implementing a FSM. Since I don't want it to stop (ever), I'm trying to write a good loop-like predicate that would work using Prolog's recursion. After a few unsuccessful tries (mainly because of stack problems) I ended up having something similar to this: /* Finite State Transition Network */ transition(st0,evnt0,st1). transition(st1,evnt1,st2). transition(st2,evnt2,st0). fsm_state(state(st0),system(Energy,ActivePayloads),[]) :- /* ... */ transition(st0,evnt0,NextState), !, fsm_state(state(NextState),system(Energy,ActivePayloads),[]). fsm_state(state(st1),system(Energy,ActivePayloads),[]) :- /* ... */ transition(st1,evnt1,NextState), !, fsm_state(state(NextState),system(Energy,ActivePayloads),[0,1,2]). fsm_state(state(st2),system(Energy,ActivePayloads),[P|Params]) :- /* ... */ transition(st2,evnt2,NextState), !, fsm_state(state(NextState),system(Energy,ActivePayloads),[]). start :- Sys = system(10,[]), fsm_state(state(s0),Sys,[]). Is this a good approach?

    Read the article

  • Any example on how to implement the new VerificationController and the KNOWN_TRANSACTIONS_KEY constant?

    - by Carles Estevadeordal
    I've been looking at implementing the new VerificationController to verify in-App-Purchases: http://developer.apple.com/library/ios/#releasenotes/StoreKit/IAP_ReceiptValidation/_index.html And I wonder if there is some example anywhere en how to validate a transaction, since it seems that the - (BOOL)verifyPurchase:(SKPaymentTransaction *)transaction; is not enough and it has to be implemented internally to verify the purchase when the data form the server is received. Another question is if anyone has a clue on what the KNOWN_TRANSACTIONS_KEY is and how to fill it, is it just the product id of the purchase?

    Read the article

  • Django ORM dealing with MySQL BIT(1) field

    - by Carles Barrobés
    In a Django application, I'm trying to access an existing MySQL database created with Hibernate (a Java ORM). I reverse engineered the model using: $ manage.py inspectdb > models.py This created a nice models file from the Database and many things were quite fine. But I can't find how to properly access boolean fields, which were mapped by Hibernate as columns of type BIT(1). The inspectdb script by default creates these fields in the model as TextField and adds a comment saying that it couldn't reliably obtain the field type. I changed these to BooleanField but it doesn't work (the model objects always fetch a value of true for these fields). Using IntegerField won't work as well (e.g. in the admin these fields show strange non-ascii characters). Any hints of doing this without changing the database? (I need the existing Hibernate mappings and Java application to still work with the database).

    Read the article

  • Good real-world uses of metaclasses (e.g. in Python)

    - by Carles Barrobés
    I'm learning about metaclasses in Python. I think it is a very powerful technique, and I'm looking for good uses for them. I'd like some feedback of good useful real-world examples of using metaclasses. I'm not looking for example code on how to write a metaclass (there are plenty examples of useless metaclasses out there), but real examples where you have applied the technique and it was really the appropriate solution. The rule is: no theoretical possibilities, but metaclasses at work in a real application. I'll start with the one example I know: Django models, for declarative programming, where the base class Model uses a metaclass to fill the model objects of useful ORM functionality from the attribute definitions. Looking forward to your contributions.

    Read the article

1