Is there a existing implementation in C/c++/java to convert first order logic to CNF ?
It might be more efficient to use something like: Boolean Normal Form
For implementation, I recommend doing it yourself for something simple like this. An efficient method has psuedo code + explanation here
Related
I am used to something like NOT in specifying conditions - but perhaps it will only allow distinct positive conditions? e.g. If the user is not anonomous
There isn't a not operator in the gherkin syntax. As #orde has said in the comments, you just have to write a negative step definition that checks for what you want.
One thing that can make this a little nicer to use is knowing that you can write steps using the 'But' keyword instead of only using 'And'
Given I have set something up
When I do something
Then something positive should happen
And some other thing should happen
But some negative thing should not happen
Not a huge difference but sounds nicer.
As Dave McNulla has said you can write your steps to take 'is | is not' if you want to reuse them.
I am having two for loops. One nested in another. I want to iterate on a single Object and change a property in it with another value, something like this:
for(i=0;i<items.length;<i++){
obj.changeThisAttribute = "abc";
for(j=0;j<items.anotherobj.length;j++){
items.anotherobj.changeThisAttribute = "dyz";
}
}
return items;
Is there any better way of doing this? I have read about Async.map and think that it will be a good solution however there is no good example of the same. Please suggest a running example or any alternative way of achieving this.
You're not performing anything asynchronous here so there is no point in async.map.
Unless this is very CPU intensive (looks fine! profile, how many objects do you have?) , your code looks fine.
It's readable, straightforward and simple, no need to look for alternative ways.
(I'm assuming your inner loop goes through items[i].anotherobj and not items.anotherobj though)
I would like to provide a Clojurescript implementation of vector based on Javascript Typed Arrays, which supports assoc, replace etc. I think I want to do that (maybe there's a better way, or maybe someone's done it ?). Presumably I'd use deftype, but what protocols should I provide "concretions" for ?
Let's see what the built-in vectors implement. You can view the source here, on github.
Looks like it's: Object, IWithMeta, IMeta, IStack, ICollection, IEmptyableCollection, ISequential, IEquiv, IHash, ISeqable, ICounted, IIndexed, ILookup, IMapEntry, IAssociative, IVector, IReduce, IKVReduce, IFn, IEditableCollection and IReversible.
That's a lot, but since each one defines one or at most two methods, it isn't that much work. Plus, you could leave some of them unimplemented, like IEditableCollection which is only used for transients or IReduce which is for the new reducers functions.
You don't even have to make your new data structure work exactly like a built-in Vector, either. You could have it implement all the sequential stuff and not worry about the map stuff, for example, though of course then it would be less convenient than a normal Vector.
I have a CString that I'd like to break up much the way a php explode() would do, I haven't seen anything like this in C++. Does anybody have an easy way to split up a string into substrings given the separator character?
There's no direct equivalent, but the Tokenize method is similar, and can be used as the basis of function to work like PHP's explode.
I didn't find it on their doc http://www.sqlite.org/lang_corefunc.html
So just want to get confirm or options here.
From Instr, Locate or Splite it seems no, but you can implement your own
I think you will have to write your
own user defined function to do this.
The SQL standard defines a POSITION()
function that returns the position of
one string within another, but sqlite
doesn't implement it. It should be
fairly simple to provide your own
function to do this. You can look at
the standard functions in func.c for
some examples of using the custom
function API routines (the same
routines are used to define all the
standard functions; sum, round,
substr, etc.).