prefix

Common lisp: is there a less painful way to input math expressions?

房东的猫 提交于 2019-12-12 08:02:17
问题 I enjoy common lisp, but sometimes it is really painful to input simple math expressions like a(8b^2+1)+4bc(4b^2+1) (Sure I can convert this, but it is kind of slow, I write (+ () ()) first, and then in each bracket I put (* () ())...) I'm wondering if anyone here knows a better way to input this. I was thinking about writing a math macro, where (math “a(8b^2+1)+4bc(4b^2+1)”) expands to (+ (* a (1+ (* 8 b b))) (* 4 b c (1+ (* 4 b b)))) but parsing is a problem for variables whose names are

How to I get the first or last few characters of a string in a method chain?

一曲冷凌霜 提交于 2019-12-12 04:01:36
问题 If I use functional-style method chains for string manipulation, I can not use the usual machinery for getting the first or last few characters: I do not have access to a reference to the current string, so I can not compute indices. Example: [some, nasty, objects] .map( { $0.asHex } ) .joined() .<first 100> .uppercased() + "..." for a truncated debug output. So how to I implement <first 100> , or do I have to break the chain? 回答1: I don't know of any API that does this. Fortunately, writing

Read, then store, a prefix expression

烈酒焚心 提交于 2019-12-12 02:49:43
问题 thanks for reading. I really need some help here. I'm faced with a problem that involves me using a recursive method to store a user-input fully marked prefix expression. In this particular instance, numbers are identified with the symbol "n", while symbols and such are just as they are. So, for example, this: % 18 + 14 / ( 12 – 11 ) – 1183 % 17 Would be input into the command prompt as this: % n18 / n14 - n12 n11 % n1183 n17 Now, here's what I have for the processing of a completely

Building parse tree from prefixed expression in c

坚强是说给别人听的谎言 提交于 2019-12-12 02:15:43
问题 I'm trying to create a binary tree like this: link The input will be entered by the user as prefix and read as a string, then put in a binary tree. This is what I have so far: struct node{ char val; struct node *left; struct node *right; }; typedef struct node root; typedef root *tree; In main: void main(){ int i; tree tr; char* s; s=input(); //input function tr=create_empty_tree(); for(i=0;s[i]!='\0';i++){ tr=add_root(s[i],ab); } convert_infix(tr); } and this is the part I've been struggling

Prefix(polish) notation - evaluation c++

拥有回忆 提交于 2019-12-12 00:28:50
问题 I am looking for code wchich parses prefix expressions using recursion. Primarily in C++, but it can bee in other language, i will translate. Thanks. 回答1: It's really easy to do yourself (you just need a stack for the operators (and sometimes/optionally its first term)). But if you really don't want to do much work, here's a link: prefix notation string to int conversion If you need to use recursion, you basically use local variables in the function as individual elements in your stack. Eg.

Rename Files Based On Folder Name

纵饮孤独 提交于 2019-12-11 20:57:00
问题 I am using the following script to rename (prefix) files in subfolders with the string "Application". pushd "%temporarydirectory%" for /r %%j in (*) do ( rename "%%j" "Application - %%~nxj" ) Popd For example files in: C:\temp\Lodgements\10 Smith Street 10001.doc 10002.doc Are renamed to: Application - 10001.doc Application - 10002.doc What I would like to do is to change the script so that files are renamed (prefixed) with the name of the folder in which they are contained. For example files

When I run this, it states that the list constraints is unbound. Why is that?

与世无争的帅哥 提交于 2019-12-11 13:56:44
问题 (defun combinations (&rest lists) (if (car lists) (mapcan (lambda (inner-val)(mapcar (lambda (outer-val) (cons outer-val inner-val)) (car lists))) (apply #'combinations (cdr lists))) (list nil))) The combinations function creates all combinations of the names, charms and position for each baseball player. (defun main() (setq m-list (combinations '(Blacket Bluet Browning Greenfield Whitehall)'(four-lear-clover penny rabbit-foot ribbon silver-dollar) '(center- field first-base right-field short

selecting rows in a data.frame in which a certain column has values containing one of a set of prefixes

血红的双手。 提交于 2019-12-11 10:03:18
问题 I have a data.frame of the type: > head(engschools) RECTYPE LEA ESTAB URN SCHNAME TOWN PCODE 1 1 919 2028 138231 Alban City School n.a. E1 3RR 2 1 919 4003 138582 Samuel Ryder Academy St Albans AL1 5AR 3 1 919 2004 138201 Hatfield Community Free School Hatfield AL10 8ES 4 2 919 7012 117671 St Luke's School n.a BR3 7ET 5 1 919 2018 138561 Harpenden Free School Redbourn AL3 7QA 6 2 919 7023 117680 Lakeside School Welwyn Garden City AL8 6YN And a set of prefixes like this one: >head(prefixes) E

Lucene Prefix Search for Indexed data through Standard Analyzer

北战南征 提交于 2019-12-11 08:08:51
问题 I am creating index using Lucene 3.6.0 for Java. They are built using Standard Analyzer. Is there any way I can perform prefix search with lucene i.e. i want the results to start with the specified search string without changing the analyzer used for indexing? Many thanks 回答1: If you mean queries like "work*" to find "work", "worker", "working", etc. you can already perform those queries using text analyzed with the Standard Analyzer. documented here: http://lucene.apache.org/core/3_6_0

Database columns type prefix

那年仲夏 提交于 2019-12-11 03:29:48
问题 I’ve been developing solutions with databases for more than 11 years now, and it seems I’ve “developed” a rather controversial opinion about naming columns in my tables: I always give them a 3 or 4 character type prefix, i.e. intGroupID, nvcTitle, dtmCreated, bitPlayerHater, etc. I’ve worked with several other developers who all absolutely despised the old-school prefix convention. (yeah, I know, I didn’t invent anything here, I’m just refusing to give it up:) My primary reasoning is to