swi-prolog [lists] - prolog

Hey i was working on this little method i guess you call them messing around trying to get my grip on swi-prolog before I have my big project assigned in a week or so at university. Its pretty obvious what it does say i say "colors(yellow,F). it will give me banana, lemon and so on...
colors(C,F):-fruits(F,C)
Now my question is i know i can use list_to_set(F, (something else)), to make the output into one list instead of having to hit ';' to get all of the fruits. THOUGH... is there anyway i can incorporate the list making into the actual method?
cheers!

Okay found out how to:
colors(C,F):-findall(C,fruits(F,C),C).
simple enough, just had to stick it in there. Thanks Anyways!

Related

Maya 'merge' the list of shapes, polyBridge, Extrudes etc

Couldn't come up with a good way of googling this..
I'm working on a 3d model in Maya and it's getting slow. At first I couldn't find what it was, but I'm suspecting it's all of the polyBrideEdge, pCubeShape and whatnot. Since I was duplicating one part and repeated that a couple times; there's quite a lot of them.
Here's a screenshot of what I mean: http://imgur.com/a/TQr0e
Nevermind, I found it! For anyone wondering: you select one of the nodes with the same type in your attribute editor and click 'hide'. This will group them together I suppose and name it 'polyUniteX'. It might not be the best way or the right way, but this has fixed any performance issues I had prior to doing this.

How to make a power point presentation like this

maybe this is not the correct forum where to post this question, but i've serched for two weeks in the web, without results.
I need to make a kind of power point presentation, something like this - do know which program can i use?
Thank you
I think, that tool used for this prezentation can be find on
http://prezi.com/
This is called infographics and you can use website like visual.ly/
Then, you have to do your own effects

How do I get a short code in India?

I am developing an application that requires the use of a short code, but I can't seem to figure out where to get one. I need one in India, but when I look for one, there are plenty of companies that rent keywords to use in their short code, but I can't find anyway to get my own short code. Once again, I want my own short code, not a keyword in someone else's. Can someone point me in the right direction?
Better you contact Service providers like vodafone, Airtel, relaince...
Just by googling I came across this, May be This be of some help

How to detect if an element exists in Watir

I'm relatively new to Watir but can find no good documentation (examples) regarding how to check if an element exists. There are the API specs, of course, but these make precious little sense to me if I don't find an example.
I've tried both combinations but nothing seems to work...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists
then...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists?
then...
If anyone has a concrete suggestion as per how to implement this, please help! Thanks!
It seems you are missing a comma between parameters.
Should be
if browser.image(:src, "/media/images/icons/reviewertools/editreview.jpg").exists?
Also you can find this page useful in future to know what attributes are supported.
The code you posted should work just fine.
Edit: Oops, wrong. As Katmoon pointed out, there is a missing comma.
browser.image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
One problem you may get caught up in is if the browser variable you specified is actually an element that doesn't exist.
e.g.
b = Watir::IE.start(ipAddress)
b.frame(:name, "doesntExist).image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
The above code will throw a Watir::UnknownFrameException. You can get around this by first verifying the frame exists or by surrounding the code in a begin/rescue block.
Seems like you are using it correctly. Here is an old RDoc of Watir.
Does it not work because Watir cannot find it? Hard to tell because there is no source or link to the page that is being tested. I think that I only use image.exists?. In general, errors that come from when the image exists but is not found are:
The how is not compatible with the element type. There is a cheatsheet to help you see which object types can be found with different attributes here.
The what is not correct. You may have to play with that a little bit. Consider trying a regex string to match it such as browser.image(:src, /editreview.jpg/). As a last resort, maybe use element_by_xpath, but there are maintenance costs with that.
The location is not correct. Maybe the element is in a frame or something like that. browser.frame("detail").image(:src, /editreview.jpg/).
Try those, but please let me know what worked. One more thing, what are you checking for? If it's part of the test criteria, you can handle it that way. If you need to click on it, then forget the .exists? and just click on it. Ruby will let you know if it's not there. If you need it to be grace, learn about begin/rescue.
Good luck,
Dave

Detecting misspelled words

I have a list of airport names and my users have the possibility to enter one airport name to select it for futher processing.
How would you handle misspelled names and present a list of suggestions?
Look up Levenshtein distances to match a correct name against a given user input.
http://norvig.com/spell-correct.html
does something like levenshtein but, because he doesnt go all the way, its more efficient
Employ spell check in your code. The list of words should contain only correct spellings of airports.
This is not a great way to do this. You should either go for a control that provides auto complete option or a drop down as someone else suggested.
Use AJAX if your technology supports.
I know its not what you asked, but if this is an application where getting the right airport is important (e.g. booking tickets) then you might want to have a confirmation stage to make sure you have the right one. There have been cases of people getting tickets for the wrong Sydney, for instance.
It may be better to let the user select from the list of airport names instead of letting them type in their own. No mistakes can be made that way.
While it won't help right away, you could keep track of typos, and see which name they finally enter when a correct name is entered. That way you can track most common typos, and offer the best options.
Adding to Kevin's suggestion, it might be a best of both worlds if you use an input box with javascript autocomplete. such as jquery autocomplete
edit: danish beat me :(
There may be an existing spell-check library you can use. The code to do this sort of thing well is non-trivial. If you do want to write this yourself, you might want to look at dictionary trie's.
One method that may work is to just generate a huge list of possible error words and their corrections (here's an implementation in Python), which you could cache for greater performance.

Resources