Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: MAUDE

  1. #1
    Junior Member bassie's Avatar
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Exclamation MAUDE

    So I've been asked to implement a linked list in java using the following maude specification:


    Below is a Maude specification of ‘Sorted Lists’: lists of integers in increasing order.

     
    mod SORTED-LIST is
        protecting INT .
     
        sort SortedList .
     
        op empty : -> SortedList .
        op add : Int SortedList -> SortedList .
        op insert : Int SortedList -> SortedList .
     
        vars I J : Int .
        var L : SortedList .
     
        eq insert(I, empty) = add(I, empty) .
        cq insert(I, add(J, L)) = add(I, add(J,L)) if I <= J .
        cq insert(I, add(J, L)) = add(J, insert(I, L)) if I > J .
    endm

    What I would like to know, is what is the difference is between add and insert!?

    Apparently they need to be implemented as two separate methods, but apart from this maude specification and the description above it, there is no other information available.

    thanks!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MAUDE

    what is the difference is between add and insert!?
    For hints you could read the API doc for existing Java SE classes.
    One difference could be add(aNode) goes at the end, insert(aNode, afterNode) would insert aNode after afterNode.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    bassie (January 6th, 2013)

  4. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MAUDE

    what is the difference is between add and insert!?
    For hints you could read the API doc for existing Java SE classes.
    One difference could be add(aNode) goes at the end, insert(aNode, afterNode) would insert aNode after afterNode.
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    bassie (January 6th, 2013)

  6. #4
    Junior Member bassie's Avatar
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: MAUDE

    Thanks Norm, found out that for this particular problem add is defined as a constructor in the Node class.

  7. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MAUDE

    add is defined as a constructor in the Node class.
    That's a contradiction. The constructor to the Node class would be Node. add would be a method.
    Normally the Node class is very simple. I don't know what an add() method in a Node class would do.
    The add() method would be in the linked list class.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #6
    Junior Member bassie's Avatar
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: MAUDE

    Ye that's what I thought, and I can't remember where I read it now but it said somewhere that the add operation itself should be implemented as a Node constructor, with the add functions in it but I guess it would still be called Node(). I'll have to have a look again tomorrow...

    Is Maude quite commonly used amongst java programmers as a specification language? I really don't like it and it definitely annoys me more than it helps..

  9. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MAUDE

    I've never heard of Maude. I've been out of school for a long time.
    If you don't understand my answer, don't ignore it, ask a question.