Search Results

Search found 13378 results on 536 pages for 'natural language'.

Page 14/536 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Custom language - FOR loop in a clojure interpeter?

    - by Mark
    I have a basic interpreter in clojure. Now i need to implement for (initialisation; finish-test; loop-update) { statements } Implement a similar for-loop for the interpreted language. The pattern will be: (for variable-declarations end-test loop-update do statement) The variable-declarations will set up initial values for variables.The end-test returns a boolean, and the loop will end if end-test returns false. The statement is interpreted followed by the loop-update for each pass of the loop. Examples of use are: (run ’(for ((i 0)) (< i 10) (set i (+ 1 i)) do (println i))) (run ’(for ((i 0) (j 0)) (< i 10) (seq (set i (+ 1 i)) (set j (+ j (* 2 i)))) do (println j))) inside my interpreter. I will attach my interpreter code I got so far. Any help is appreciated. Interpreter (declare interpret make-env) ;; needed as language terms call out to 'interpret' (def do-trace false) ;; change to 'true' to show calls to 'interpret' ;; simple utilities (def third ; return third item in a list (fn [a-list] (second (rest a-list)))) (def fourth ; return fourth item in a list (fn [a-list] (third (rest a-list)))) (def run ; make it easy to test the interpreter (fn [e] (println "Processing: " e) (println "=> " (interpret e (make-env))))) ;; for the environment (def make-env (fn [] '())) (def add-var (fn [env var val] (cons (list var val) env))) (def lookup-var (fn [env var] (cond (empty? env) 'error (= (first (first env)) var) (second (first env)) :else (lookup-var (rest env) var)))) ;; for terms in language ;; -- define numbers (def is-number? (fn [expn] (number? expn))) (def interpret-number (fn [expn env] expn)) ;; -- define symbols (def is-symbol? (fn [expn] (symbol? expn))) (def interpret-symbol (fn [expn env] (lookup-var env expn))) ;; -- define boolean (def is-boolean? (fn [expn] (or (= expn 'true) (= expn 'false)))) (def interpret-boolean (fn [expn env] expn)) ;; -- define functions (def is-function? (fn [expn] (and (list? expn) (= 3 (count expn)) (= 'lambda (first expn))))) (def interpret-function ; keep function definitions as they are written (fn [expn env] expn)) ;; -- define addition (def is-plus? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '+ (first expn))))) (def interpret-plus (fn [expn env] (+ (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define subtraction (def is-minus? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '- (first expn))))) (def interpret-minus (fn [expn env] (- (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define multiplication (def is-times? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '* (first expn))))) (def interpret-times (fn [expn env] (* (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define division (def is-divides? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '/ (first expn))))) (def interpret-divides (fn [expn env] (/ (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define equals test (def is-equals? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '= (first expn))))) (def interpret-equals (fn [expn env] (= (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define greater-than test (def is-greater-than? (fn [expn] (and (list? expn) (= 3 (count expn)) (= '> (first expn))))) (def interpret-greater-than (fn [expn env] (> (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define not (def is-not? (fn [expn] (and (list? expn) (= 2 (count expn)) (= 'not (first expn))))) (def interpret-not (fn [expn env] (not (interpret (second expn) env)))) ;; -- define or (def is-or? (fn [expn] (and (list? expn) (= 3 (count expn)) (= 'or (first expn))))) (def interpret-or (fn [expn env] (or (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define and (def is-and? (fn [expn] (and (list? expn) (= 3 (count expn)) (= 'and (first expn))))) (def interpret-and (fn [expn env] (and (interpret (second expn) env) (interpret (third expn) env)))) ;; -- define print (def is-print? (fn [expn] (and (list? expn) (= 2 (count expn)) (= 'println (first expn))))) (def interpret-print (fn [expn env] (println (interpret (second expn) env)))) ;; -- define with (def is-with? (fn [expn] (and (list? expn) (= 3 (count expn)) (= 'with (first expn))))) (def interpret-with (fn [expn env] (interpret (third expn) (add-var env (first (second expn)) (interpret (second (second expn)) env))))) ;; -- define if (def is-if? (fn [expn] (and (list? expn) (= 4 (count expn)) (= 'if (first expn))))) (def interpret-if (fn [expn env] (cond (interpret (second expn) env) (interpret (third expn) env) :else (interpret (fourth expn) env)))) ;; -- define function-application (def is-function-application? (fn [expn env] (and (list? expn) (= 2 (count expn)) (is-function? (interpret (first expn) env))))) (def interpret-function-application (fn [expn env] (let [function (interpret (first expn) env)] (interpret (third function) (add-var env (first (second function)) (interpret (second expn) env)))))) ;; the interpreter itself (def interpret (fn [expn env] (cond do-trace (println "Interpret is processing: " expn)) (cond ; basic values (is-number? expn) (interpret-number expn env) (is-symbol? expn) (interpret-symbol expn env) (is-boolean? expn) (interpret-boolean expn env) (is-function? expn) (interpret-function expn env) ; built-in functions (is-plus? expn) (interpret-plus expn env) (is-minus? expn) (interpret-minus expn env) (is-times? expn) (interpret-times expn env) (is-divides? expn) (interpret-divides expn env) (is-equals? expn) (interpret-equals expn env) (is-greater-than? expn) (interpret-greater-than expn env) (is-not? expn) (interpret-not expn env) (is-or? expn) (interpret-or expn env) (is-and? expn) (interpret-and expn env) (is-print? expn) (interpret-print expn env) ; special syntax (is-with? expn) (interpret-with expn env) (is-if? expn) (interpret-if expn env) ; functions (is-function-application? expn env) (interpret-function-application expn env) :else 'error))) ;; tests of using environment (println "Environment tests:") (println (add-var (make-env) 'x 1)) (println (add-var (add-var (add-var (make-env) 'x 1) 'y 2) 'x 3)) (println (lookup-var '() 'x)) (println (lookup-var '((x 1)) 'x)) (println (lookup-var '((x 1) (y 2)) 'x)) (println (lookup-var '((x 1) (y 2)) 'y)) (println (lookup-var '((x 3) (y 2) (x 1)) 'x)) ;; examples of using interpreter (println "Interpreter examples:") (run '1) (run '2) (run '(+ 1 2)) (run '(/ (* (+ 4 5) (- 2 4)) 2)) (run '(with (x 1) x)) (run '(with (x 1) (with (y 2) (+ x y)))) (run '(with (x (+ 2 4)) x)) (run 'false) (run '(not false)) (run '(with (x true) (with (y false) (or x y)))) (run '(or (= 3 4) (> 4 3))) (run '(with (x 1) (if (= x 1) 2 3))) (run '(with (x 2) (if (= x 1) 2 3))) (run '((lambda (n) (* 2 n)) 4)) (run '(with (double (lambda (n) (* 2 n))) (double 4))) (run '(with (sum-to (lambda (n) (if (= n 0) 0 (+ n (sum-to (- n 1)))))) (sum-to 100))) (run '(with (x 1) (with (f (lambda (n) (+ n x))) (with (x 2) (println (f 3))))))

    Read the article

  • OK Programming language from USB stick with no installation

    - by tovare
    I'm looking for a compiler or interpreter for a language with basic math support and File IO which can be executed directly from a memorystick in either Linux or Windows. Built in functionality for basic datastructures and sorting/searching would be a plus. (I've read about movable python, but it only supports windows) Thank you

    Read the article

  • Which language should I learn?

    - by Alex
    I am already pretty good at PHP and now want to expand my knowledge to desktop programming.. which language would be: The one's I'm mainly looking into are: Java, C#, C++, Python 1) Easier to learn? 2) Most suitable for Making 3D games and applications with sockets? One more thing - Although I'm looking to code for Windows, I may also want to do a bit of programming for Mac OS after a while.

    Read the article

  • Design considerations for a multi-language web application

    - by gAMBOOKa
    I was asked by an interviewer today how I would implement Arabic as a second language into a PHP web application. I talked about choosing a unicode encoding for the database and the front-end, and designing RTL friendly user interface modules. And he didn't seem too happy with the answer. I don't really know anything about multi-lingual systems, how would you have answered that question?

    Read the article

  • How fast should an interpreted language be today?

    - by Tarbal
    Is speed of the (main/only viable) implementation of an interpreted programming language a criteria today? What would be the optimal balance between speed and abstraction? Should scripting languages completely ignore all thoughts about performance and just follow the concepts of rapid development, readability, etc.? I'm asking this because I'm currently designing some experimental languages and interpreters

    Read the article

  • Web Programming language for very large lists?

    - by behrk2
    Hello, In your experience, what is the best web programming language used to handle sorting and comparison of very large lists (ie tens of thousands of email addresses)? I am most familiar with PHP. I think that it could get the job done, but I'm unsure of other languages and if there might be a bettor suitor. Thanks!

    Read the article

  • What programming language to choose

    - by Pradeep
    We need to write a script that needs to process movies (using C-based ffmpeg) and also update our databases. Also there would be some thread programming to accomplish with a worker-manager design. I am thinking of writing this in Ruby is there any good language to do this, if so what is its primary advantage for choosing? We are based on the Mac platform. Thanks in advance.

    Read the article

  • is php language C?

    - by avon_verma
    Ok: I edited my question: I heared somewhere, that php language is written by C. So i have question: what happens for example when you run a function in php such as date("Ymd"); or file_get_contents("file.txt");? Does it translate that code to C and request to server, or does php do it? sorry i haven't a clue And if it does translate it and request, that means besically it is C? sorry for english Thank you, Anon Verma

    Read the article

  • Sub Language C#

    - by j-t-s
    Hi All I was just wondering, is it at all possible to create sort of like a "Sub-language" in C# OR C++? or would a better term be "Extension"? And can somebody please provide links/resources? Much appreciated! :) thanks jason

    Read the article

  • A more flexible and agile compiled language - possible?

    - by sdudo
    I have a short question that I have been thinking about for some time now so why shouldn't I ask it here on SO: Is it theoretically possible to create a compiled, yet more agile, flexible and rapid-development-friendly language? If so: Where would be the pros and cons? Why isn't there one yet?

    Read the article

  • How to add links that select the preferred language (CodeIgniter's Language Class)?

    - by janoChen
    I just finished this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ but now I want some links to change english to spanish I know how to change it by modifying the controller example.php: # Load language $this->lang->load('example', 'english'); But I can't figure out how to do that in the view file example.php What's the simplest and best way of doing this?

    Read the article

  • Are non Turing-complete languages considered programming languages at all?

    - by user1598390
    Reading a recent question: Is it actually possible to have a 'useful' programming language that isn't Turing complete?, I've come to wonder if non Turing-complete programming languages are considered programming languages at all. Since Turing-completeness means a language has to have variables to store values as well as control structures ( for, while )... Is a language that lacks these features considered a programming language ?

    Read the article

  • Which programming language to get into?

    - by user602479
    I'm ending my third term in a few weeks so I have some spare time coming up. I'd like to spend it seriously digging into programming. My problem: I'm not sure which language to begin with. Just to be clear, I don't want to start a language-y-compared-to-language-z discussion. There are a some other issues that play a major role. In my 5th term I'm going to be participating in a major practical course which will include either Java or C programming. It will take a lot of time and energy, as I found out while talking to a few students who passed the final exams (only 15% pass on their first try). Which practical course I will take is randomly decided. My skills so far are the absolute basics of Java and C programming. I know the different data types and how to handle them, objects, pointers, thread programming, etc. All of that is on a very low level, though. My question now is, what language should I start seriously practicing? Java: I did my first GUIs with this language. I'm familiar with Eclipse but I need a project to work on (which I don't have) to really keep me pushing. Besides that, I don't think it would help me if I have to do C in a year. C: As with Java, I can't think of a personal project to keep me working and keep me interested in programming. If I get assigned to Java in a year, this wouldn't give me any advantages either, would it? (No objects, etc.) Objective-C: I recently came up with this idea. I have a Mac; I'm not really familiar with Xcode but I have one or two personal projects I'd like to work on. Further, I would be working with objects (as in Java) and C language constructs which would both be great for this practical course in a year. What do you think I should begin with? Should I just stick to Java and hope for the best, force myself through C or start (nearly) completely from the beginning with Objective C? Maybe you folks could give me some good advice that would stop me from switching from one language to the next?

    Read the article

  • Database Design Question: GUID + Natural Numbers

    - by Alan
    For a database I'm building, I've decided to use natural numbers as the primary key. I'm aware of the advantages that GUID's allow, but looking at the data, the bulk of row's data were GUID keys. I want to generate XML records from the database data, and one problem with natural numbers is that I don't want to expose my database key's to the outside world, and allow users to guess "keys." I believe GUID's solve this problem. So, I think the solution is to generate a sparse, unique iD derived from the natural ID (hopefully it would be 2-way), or just add an extra column in the database and store a guid (or some other multibyte id) The derived value is nicer because there is no storage penalty, but it would be easier to reverse and guess compared to a GUID. I'm (buy) curious as to what others on SO have done, and what insights they have.

    Read the article

  • Language-agnostic term for typed things that need memory

    - by FredOverflow
    Is there an accepted general term that subsumes the concepts of variables, class instances and arrays? Basically "any typed thing that needs memory". In C++, such a thing is called an object, but I'm looking for a more language-agnostic term. § 1.8 The C++ object model 1 The constructs in a C++ program create, destroy, refer to, access, and manipulate objects. An object is a region of storage. [...] An object can have a name (Clause 3). An object has a storage duration (3.7) which influences its lifetime (3.8). An object has a type (3.9).

    Read the article

  • Moving a C# Program to a different language

    - by waiwai933
    I am currently in charge of the development of the second version of program that was created in Microsoft .NET C#. I'm not doing any actual programming, but I am writing the specification for the programmer. I'd like to take it off the .NET codebase, but since Joel said on his blog never to rewrite code, and he does provide good reasoning, I'm inclined to think carefully. So my question is, (1) Are there any easy ways to transition? (Languages like .NET C#) (2) Would you take it off .NET? (3) If so, what language would you use? The reason I want to take it off of .NET is as far as my understanding of .NET, it has to be installed on the client. I'd prefer not to inconvenience my customers when there's a better way.

    Read the article

  • Create a new embedded language using PHP

    - by dino beytar
    I am trying to develop an administration panel and I have a command line. When a user send a command like below, i need to recognize it using PHP. My aim is simplifying tasks in the admin panel. create page -attr1 90 -attr2 'page title'; or update category 90 -name 'Technology'; There are two main things: Verb and subject (ie. create page, update category) Attributes (can be both STRING and INT) and more complex example: create page -name EN:'Static Page' CA:'Staticna Stranica' -category 3,6,12,15; Where can I start to create this very small embedded language, or how can I do it well really? Clever answers, please.

    Read the article

  • Open Source Project & Language Selection

    - by James
    I'm getting ready to start an open-source project that will target .NET/Mono. For those who have started their own open source venture... Do you let the fact that a project is going to be open-source weigh on the decision of what language to use? For example. Most .NET open-source projects are written in C#. However, if you were more comfortable with VB.NET, Boo, Nemerle, etc... would you use it? What other considerations are there? This particular project will be a core library and application for geocaching. Similar to GSAK.

    Read the article

  • Scripting language to embed into a Java server application

    - by Alexey Kalmykov
    I want to make a business logic of server side Java application as a set of scripts. So I need from a scripting engine: Maximum Java interoperability (i.e. Spring framework) Script reloading and recompiling Easy DB access from scripting language Clear and simple syntax (some DSL capabilities would be nice to have), easy learning curve for non-hardcore developers Performance and stability I had some experience in the similar project with Rhino and it was pretty good. But I want to see if there is something better. Currently I'm looking into Groovy. JRuby and Jython are a bit more complex than I need for this task. Any other suggestion? What to take into consideration?

    Read the article

  • NSUserDefaults and default language used for I18N

    - by fedmest
    I have searched around a lot for this and found some answers that sounded quite like what I wanted but never worked. I simply need to have my iPhone app load NIBs and Localizable.strings that I decide (through user selection) rather than the ones that are established through the global iPhone/iPad settings. General consensus seems to be that this line [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"ro"] forKey:@"AppleLanguages"]; would do the trick (in this specific case, load the NIBs and Localizable.strings in ro.lproj) but I have not had such luck. It keeps on looking for the files in en.lproj or whatever language I chose in the Settings app. I have then tried adding this line [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"ro_RO"] forKey:@"AppleLocale"]; and to my great surprise, it worked! ...only once :-( then back to the same issue. Has anyone got any idea how to solve this issue? The aforementioned code was added at the very start of applicationDidFinishLaunching, which is before any NIBs or strings files should be loaded.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >