/// <summary> /// returns items that match a certain condition, from oldest to newest. /// </summary> /// <param name="selector">a delegate to match items</param> /// <returns></returns> public IEnumerator <T> GetSelector(predicate selector) { foreach (var item in this) { if (selector(item)) { yield return(item); } } }
static void Main(string[] args) { //lamda for simple interest Func <decimal, decimal, decimal, decimal> o1 = (p, n, r) => { return((p * n * r) / 100); }; Console.WriteLine(o1(5000, 2, 4)); //lamda for Isgreater use predicate Predicate <int> o2 = (a) => { return(true); }; Console.WriteLine(o2(20)); //lamda for is greater use func Func <int, int, bool> o3 = (a, b) => { return(a > b); }; Console.WriteLine("isgreater using func===" + o3(50, 40)); //lamda for Getbasic salary of employee Program prg = new Program(); //getbsic salary Func <object, decimal> o5 = (p) => { Program p1 = new Program(); return(p1.basic); }; Console.WriteLine("basic salary==" + o5(1000)); //lamda for iseven function use func Func <int, bool> o4 = (int a) => { return(a % 2 == 0); }; //lamda foriseven using predicate predicate <int> o7 = (a) => { return(a % 2 == 0); }; console.WriteLine("iseven predicate" + o7(12)); Console.WriteLine("is even=" + o4(12)); //lamda function for basic is greater than 10k Func <object, bool> o6 = (p) => { Program g = new Program(); return(g.isgreaterthantenK); }; Console.WriteLine("isgreaterthan ten k===" + o6(1000)); }
static ArrayList Find (predicate p, ArrayList source) { ArrayList result = new ArrayList (); foreach (object a in source){ if (p (a)) result.Add (a); } return result; }
static ArrayList Find(predicate p, ArrayList source) { ArrayList result = new ArrayList(); foreach (object a in source) { if (p(a)) { result.Add(a); } } return(result); }
public void Order(predicate pr) { int temp; for (int i = 0; i < ar.Length - 1; i++) { for (int j = i + 1; j < ar.Length; j++) { if (pr(ar[i], ar[j])) { temp = ar[i]; ar[i] = ar[j]; ar[j] = temp; } } } }
public LinkedList <T> Filter(predicate tester) { var returnList = new LinkedList <T>(); ListElement <T> testedElement = elements.firstElement.next; while (testedElement != elements.lastElement) { if (tester(testedElement.value)) { returnList.AddAfter(testedElement.value); returnList.MoveUp(); } testedElement = testedElement.next; } return(returnList); }
public Unitoken AddNewToken(predicate p) { Vector3 mouseWorldPos = mCamera.ScreenToWorldPoint(Input.mousePosition); float h = mouseWorldPos.x; float v = mouseWorldPos.y; Vector3 mouseDelta = new Vector3(h, v, 0); //transform.position = mouseDelta; Unitoken newToken = Instantiate(unitokenPrefab, Vector3.zero, Quaternion.identity, transform.parent).GetComponent <Unitoken>(); newToken.transform.position = Vector3.zero; newToken.transform.name = "Unitoken"; newToken.Initialize(p.property, Vector3.zero, p.URI); ArcMapManager.Instance.AddTokenToList(newToken); return(newToken); }
public CharInfo getClosestToMe(predicate p) { CharInfo closest = null; Vector3 myPos = transform.position; float closestDist = 0; foreach (var v in allChars) { if (v == this) { continue; } float dist = myPos.dist(v.transform.position); if (closest == null || dist < closestDist) { if (p(v)) { closest = v; closestDist = dist; } } } return(closest); }
public static List <Tile> FindPath( Tile[,] grid, Tile start, Tile target, predicate isTraversable ) { List <Node> openSet = new List <Node>(); HashSet <Node> closedSet = new HashSet <Node>(); openSet.Add(start); int iterations = 0; while (openSet.Count > 0 && iterations < maxIterations) { Node node = openSet[0]; // Find node with lowest fCost foreach (Node openedNode in openSet) { if ( openedNode.fCost < node.fCost || // If fCosts are equal, check hCosts: (openedNode.fCost == node.fCost && openedNode.hCost < node.hCost) ) { node = openedNode; } } openSet.Remove(node); closedSet.Add(node); // Path is found if (node == target) { return(RetracePath(start, node)); } // Iterate over neighbors foreach (Node neighbor in node.GetNeighbors(grid)) { if (closedSet.Contains(neighbor) || !isTraversable(node, neighbor)) { continue; } float gCost = neighbor.gCost + node.GetDistance(neighbor); if (gCost < neighbor.gCost || !openSet.Contains(neighbor)) { neighbor.gCost = gCost; neighbor.hCost = neighbor.GetDistance(target); neighbor.parent = node; if (!openSet.Contains(neighbor)) { openSet.Add(neighbor); } } } iterations++; } return(new List <Tile>()); }
public List <predicate> GetPredicates(string resourceURI) { TripleStore store = new TripleStore(); List <predicate> predicates = new List <predicate>(); // PREFIX dbpedia: <http://dbpedia.org/resource/> // PREFIX foaf: <http://xmlns.com/foaf/0.1/> // PREFIX dc: <http://purl.org/dc/elements/1.1/> // PREFIX mo: <http://purl.org/ontology/mo/> //Create a Parameterized String SparqlParameterizedString queryString = new SparqlParameterizedString(); //Add a namespace declaration queryString.Namespaces.AddNamespace("dbpedia", new Uri("http://dbpedia.org/resource/")); queryString.Namespaces.AddNamespace("foaf", new Uri(" http://xmlns.com/foaf/0.1/")); queryString.Namespaces.AddNamespace("dc", new Uri("http://purl.org/dc/elements/1.1/")); queryString.Namespaces.AddNamespace("mo", new Uri("http://purl.org/ontology/mo/")); queryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#")); Debug.Log("Added NameSpaces"); /* queryString.CommandText = " CONSTRUCT { ?album dc:creator dbpedia:The_Beatles ."; * queryString.CommandText += " ?track dc:creator dbpedia:The_Beatles . }"; * queryString.CommandText += " WHERE { dbpedia:The_Beatles foaf:made ?album ."; * queryString.CommandText += " ?album mo:record ?record ."; * queryString.CommandText += "?record mo:track ?track . }"; */ queryString.CommandText = "SELECT DISTINCT ?property ?value WHERE {<" + resourceURI + "> ?property ?value . filter ( ?property in ( rdf:type) ) } LIMIT 5"; SparqlQueryParser sparqlparser = new SparqlQueryParser(); SparqlQuery query = sparqlparser.ParseFromString(queryString); Debug.Log("Created query string"); SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("https://dbpedia.org/sparql"), "http://dbpedia.org"); Debug.Log("Created Endpoint"); //Get the Query processor ISparqlQueryProcessor processor = new RemoteQueryProcessor(endpoint); Debug.Log("Created Processor"); try{ object results = processor.ProcessQuery(query); Debug.Log("Processing Query"); if (results is SparqlResultSet) { SparqlResultSet rset = (SparqlResultSet)results; string msg = rset.Count + " results:"; Debug.Log(msg); //Print out the Results int cnt = 0; foreach (SparqlResult r in rset) { cnt++; msg = "#" + cnt + ": " + r.ToString(); //r.Variables string targetLabel = r.ToString(); List <string> values = new List <string>(); foreach (string x in r.Variables) { values.Add(r.Value(x).ToString()); } predicate predicate = new predicate { property = values[1], value = values[0] }; predicates.Add(predicate); //Debug.Log(values.Count); } } else if (results is IGraph) { //CONSTRUCT/DESCRIBE queries give a IGraph IGraph resGraph = (IGraph)results; Debug.Log("\n" + "IGraph results:\n"); Debug.Log(resGraph.IsEmpty); int cnt = 0; foreach (Triple t in resGraph.Triples) { string msg = "Triple #" + ++cnt + ": " + t.ToString(); Debug.Log(msg); //Do whatever you want with each Triple } } else { //If you don't get a SparqlResutlSet or IGraph something went wrong //but didn't throw an exception so you should handle it here string msg = "ERROR, or no results"; Debug.Log(msg); } }catch (RdfQueryException queryEx) { //There was an error executing the query so handle it here Debug.Log(queryEx.Message); if (queryEx.InnerException != null) { Console.WriteLine("Inner exception: {0}", queryEx.InnerException); } } return(predicates); }
public void SetPredicate(predicate x) { myPredicate = x; myText.text = x.property; Label = x.property; }
public static extern int XPeekIfEvent( [In] Display *display, [Out] XEvent *event_return, [In] predicate predicate, [In] XPointer arg );
Class304 class = arg_8B_0.FindLast(predicate);
var(predicate, error) = GetLastImpactUpdateFetchPredicate(productLine);
: Set <TModelBase>().AnyAsync(predicate, token)));