Create Basic Catalog System with Prolog - prolog

So we have an assignment to create a catalog system wherein we are supposed to add, edit, delete records of books in a system we created and compute for the total number of items recorded.
the information recorded or inputted should include the name of the author and the title of the book for example. Still cant wrap my head around how to do it and really need help. so far this code all I've got for now.
I wanted to know how exactly to do this task as i have no idea how to continue on this.
menu:- repeat,
write('Online Public Catalog System'),nl,
write('[1]Add Records'),nl,
write('[2]Edit Records'),nl,
write('[3]Delete Records'),nl,
write('[4]Display and Calculate for books'),nl,
write('[5]Exit'),nl,
write('Choose from the select menu'),nl,
read(Choice),Choice>0, Choice =<2,
doit(Choice), Choice=2, !.
doit(1):-
writeln('Input name of author:'),readln(M),
writeln('Input title of Book:'),readln(C),
record(book([C]),author([M])).
doit(2):-
write('To edit an existing book, please enter the Title and Author: '),nl,
read(T,A),
update([T,A]|books).

Related

MailChimp: Dynamic merge tag when only initial know for first name

We want to use the first name merge tag in our template. However for some small percentage of the audience we only have an initial and not the actual first name. Therefore the campaign would look like "Dear X" instead of "Dear Xavier" for example.
We want these to appear as "Dear Supporter". I know I could do this with an import and update the fields for the ones I have identified. However I do not want to run this every day for new signups.
Is there a way to create a conditional merge tag that results in the first name being used when the length is more than 1 and if the length of the first name is 0 or 1 then "Supporter" is used? Is this possible in MailChimp?
Thanks in advance!

Algorithm for translating MLB play-by-play records into descriptive text

I'm trying to collect a dataset that could be used for automatically generating baseball articles.
I have play-by-play records of MLB games from retrosheet.org that I would like to be written out to plain text, as those that could possibly appear as part of a recap news article.
Here are some examples of the play-by-play records:
play,2,0,semim001,32,.CBFFFBBX,9/F
play,2,0,phegj001,01,FX,S7/G
play,2,0,martn003,01,CX,3/G
play,2,1,youne003,00,,NP
The following is what I would like to achieve:
For the first example
play,2,0,semim001,32,.CBFFFBBX,9/F,
I want it to be written out as something like:
"semim001 (Marcus Semien) was on three balls and two strikes in the second inning as the away player. He hit the ball into play after one called strike, one ball, three fouls, and another two balls. The fly ball was caught by the right outfielder."
The plays are formatted in the following way:
The first field is the inning, an integer starting at 1.
The second field is either 0 (for visiting team) or 1 (for home team).
The third field is the Retrosheet player id of the player at the plate.
The fourth field is the count on the batter when this particular event (play) occurred. Most Retrosheet games do not have this information, and in such cases, "??" appears in this field.
The fifth field is of variable length and contains all pitches to this batter in this plate appearance and is described below. If pitches are unknown, this field is left empty, nothing is between the commas.
The sixth field describes the play or event that occurred.
Explanations for all the symbols in the fifth and sixth field can be found on this Retrosheet page.
With Python 3, I've been able to format all the info of invariable length into a formatted sentence, which is all but the last two fields. I'm having difficulty in thinking of an efficient way to unparse (correct me if this is the wrong term to use here) the fifth and sixth fields, the pitches and the events that occurred, due to their variable length and wide variety of things that can occur.
I think I could write out all the rules based on the info on the Retrosheet website, but I'm looking for suggestions for a smarter way to do this. I wrote natural language processing as tags, hoping this could be a trivial problem in that field. Any pointers will be greatly appreciated!

Prolog text game printing descriptions duplicate output

I'm working on a text based adventure game in prolog. I'm trying to define something that prints out all the adjacent rooms and their descriptions, except when I try to use it it is printing duplicate items and their descriptions.
The definitions for adjacent_rooms is as follows:
adjacent_rooms(Location):-
is_connected(Location, AdjacentLocation),
name(AdjacentLocation, AdjacentName),
short_desc(AdjacentLocation, AdjacentDescription),
write(AdjacentName), write(': '), write(AdjacentDescription),nl,fail.
adjacent_rooms(_).
Below is the output when I call adjacent_rooms(bedroom).
?- adjacent_rooms(bedroom).
Your Bedroom's Closet: A cozy little room used for storing your valuables
Your Bedroom's Closet:
: A cozy little room used for storing your valuables
:
Hallway: Long pathway that has pictures hanging on wall
Hallway:
: Long pathway that has pictures hanging on wall
What is causing duplicate names and descriptions to be printed? Thanks.

Drop-down validation list created dynamically

In range A1 I have a drop-down validation list. Based on the user's selection from that list I would like to dynamically create a new drop-down validation list in range C1.
For instance, in A1 the list contains:
A
B
C
So if the user selects A from the list, the new list in C1 contains:
1) Annoying Orange
2) Angry Birds
3) Arbitrary Sample
If the user selects B, the new list contains:
1) Bloated Code
2) Better Left Unsaid
3) Bad Attempt
etc
Easy enough to do using VBA. But in GAS.... I have absolutely no idea of how to even start :/
The Apps Script API for data validation was just released:
http://googleappsdeveloper.blogspot.com/2013/08/answering-another-top-request-data.html
You could follow the example in the accepted answer to Google spreadsheet Script Create Data Validation in certain range.
... up until last week, it would have worked. Unfortunately, the Data Validation class and related Range methods getDataValidation() and setDataValidation() have disappeared.
Your only avenue at this point is to visit Issue 2958 and star it, so you receive updates if & when the API is refreshed.

Magento charity coupon code + then ask for which charity (2 step discount for Round Table)

We have a special couponcode 10% off, 3 monhts valid.
Now the 10% goes to charity. And we use the couponcode to identify that it is in fact for charity BUT alas someone has thought up that everybody can decide for themselves which chairt it is. So ....
We need a couponcode that works (check!)
But when entered somewhere there should be an extra box asking for the "charity name"
Options I can think off is directly at coupon input, or add addressfiled (but only when coupon)
Anyone know how to do this easily? or with sme code?
Just create a coupon code for each charity and replace the coupon entrance input with a select box that lists your codes or make a additional select-box that pre-fills the coupon field with right code ?

Resources