Search Results

Search found 488 results on 20 pages for 'lisp'.

Page 10/20 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Create a polynomial object from a number using change-class

    - by charlieb
    I have written a polynomial class along the lines described in SICP 2.5.3 (except using defclass). I would like to be able to seamlessly add and multiply polynomials and regular numbers but I can't make change-class accept a number. I tried to simplify the problem by changing class from an integer to a float: (change-class 4 'float) but that gave me the error: There is no applicable method for the generic function #<STANDARD-GENERIC-FUNCTION CHANGE-CLASS (7)> when called with arguments (4 #<BUILT-IN-CLASS FLOAT>). [Condition of type SIMPLE-ERROR] I get an error of the same form from (fyi): (change-class 4 'polynomial) I'm going to go ahead and implement a manual conversion but I would prefer to use the built-in clos facilities.

    Read the article

  • F# equivalent to Eval

    - by akaphenom
    Is there an F# equivalent to eval? My intent is to have my app load a small code sample from a file and essentially let file = "c:\mysample" let sample = loadFromFile file let results = eval(sample) I am new to F# and trying to figure out some of the limitations before I apply it to a project. Thank you

    Read the article

  • Emacs comment-region in C mode

    - by Kinopiko
    In GNU Emacs, is there a good way to change the comment-region command in C mode from /* This is a comment which extends */ /* over more than one line in C. */ to /* This is a comment which extends over more than one line in C. */ ? I have tried (setq comment-multi-line t) but this does not help. There is a section on multi-line comments in the Emacs manual, but it does not mention anything.

    Read the article

  • How do I make a module in PLT Scheme?

    - by kunjaan
    I tried doing this: #lang scheme (module duck scheme/base (provide num-eggs quack) (define num-eggs 2) (define (quack n) (unless (zero? n) (printf "quack\n") (quack (sub1 n))))) But I get this error: module: illegal use (not at top-level) in: (module duck scheme/base (provide num-eggs quack) (define num-eggs 2) (define (quack n) (unless (zero? n) (printf "quack\n") (quack (sub1 n))))) what is the correct way?

    Read the article

  • UVa #112 Tree Summing

    - by unclerojelio
    I'm working on UVa #112 Tree Summing. I have what I think should be a working solution but it is not accepted by the online judge due to a basic misunderstanding of the problem on my part. Consider the following inputs: -1 (-1()()) 77 (77(1()())()) or diagrammatically, the trees look like: -1 77 / \ / \ () () 1 () / \ () () According to at least two working solutions, the correct output for the above inputs is: yes no However, I don't understand why the second one should be 'no'. It looks to me like the rightmost path of the tree should give the proper sum. What am I missing?

    Read the article

  • Inserting mutable pairs into a mutable list

    - by Romelus
    How can I push a mutable pair onto a stack such that i'm only creating one stack. I have some code that works but creates lists within lists within lists.... Here is what I believe should work but throws an error. (define func (arg1 arg2 arg3) // Where arg3 is an empty list (mappend (mcons arg1 arg2) arg3)) The above code complains and says: "mcar: expects argument of type ; given ... Can anyone show me how I can get a result that looks like so,: (list (arg1 arg2) (arg# arg#) ...)

    Read the article

  • emacs: force ido-mode to forget history...

    - by Stephen
    Hi, I wonder if I can keep ido from not remembering my history and only show completions for files that are in the current directory when I am searching for a file. I understand that this history feature is useful at times, but I often end up editing the incorrect file because I think I am editing file called 'abc.txt' in the current directory but in fact I am editing the file by the same name in another one that I previously visited (often happens when there is not an 'abc.txt' in the current directory, as I mistakenly assume). From reading the ido.el file I thought to set in my .emacs file (also evaluated these expressions in running emacs instance): (custom-set-variables '(ido-enable-last-directory-history nil) '(ido-record-commands nil) ) and deleted a file called .ido.last in ~/, but still it remembers some previous files I've visited before making these changes. How can I purge my previous history, and I am not entirely sure what the difference between the two variables above are but seems to have done the trick to keep ido from remembering files I visit in the future? Thanks for your help!

    Read the article

  • Setting slime-enable-evaluate-in-emacs

    - by Tyler
    Hi, I am using SBCL with slime, and have the following code: (swank::eval-in-emacs '(with-current-buffer (slime-repl-buffer) (insert (propertize "foo" 'font-lock-face '(:foreground "red"))))) (print "here is some text") In general if I try to execute anything with swank:: prefixed to it emacs will give a security error, and this particular one tells me I need to set slime-enable-evaluate-in-emacs to true. Where is this value? I haven't been able to find a slime or swank config. & settings file. Thanks much.

    Read the article

  • running shell commands with gnu clisp

    - by Paul Nathan
    I'm trying to create a "system" command for clisp that works like this (setq result (system "pwd")) ;;now result is equal to /my/path/here I have something like this: (defun system (cmd) (ext:run-program :output :stream)) But, I am not sure how to transform a stream into a string. I've reviewed the hyperspec and google more than a few times.

    Read the article

  • How to return the output of a recursive function in Clojure

    - by Silanglaya Valerio
    Hi everyone! I'm new to functional languages and clojure, so please bear with me... I'm trying to construct a list of functions, with either random parameters or constants. The function that constructs the list of functions is already working, though it doesn't return the function itself. I verified this using println. Here is the snippet: (def operations (list #(- %1 %2) #(+ %1 %2) #(* %1 %2) #(/ %1 %2))) (def parameters (list \u \v \w \x \y \z)) (def parameterlistcount 6) (def paramcount 2) (def opcount 4) (defn generateFunction "Generates a random function list" ([] (generateFunction 2 4 0.5 0.6 '())) ([pc maxdepth fp pp function] (if (and (> maxdepth 0) (< (rand) fp)) (dotimes [i 2] (println(conj (generateFunction pc (dec maxdepth) fp pp function) {:op (nth operations (rand-int opcount))}))) (if (and (< (rand) pp) (> pc 0)) (do (dec pc) (conj function {:param (nth parameters (rand-int parameterlistcount))})) (conj function {:const (rand-int 100)}))))) Any help will be appreciated, thanks!

    Read the article

  • Pattern Matching in Scheme

    - by kunjaan
    How do I accept the following input? (list of 0 or more charcters and ends with 3) or (list of 1 or more characters 4 and 0 or more characters after 4) something like (match ( list 3)) -> #t (match ( list 1 2 3)) -> #t (match (list 1 2 3 4)) -> #t (match (list 1 2 3 4 5)) -> #t (match (list 4)) -> #f EDIT: THIS IS NOT MY HOMEWORK. I trying to write something like ELIZA from PAIP but I know only how to write a pattern that begins with a word.

    Read the article

  • Adding an element to a list in Scheme

    - by user272483
    I'm using R5RS Scheme and I just want to implement a function that returns the intersection of two given lists, but I can't do that because I cannot add an element to a list. Here is my code. How can I fix it? I'm really a beginner in Scheme - this is my first work using Scheme. thx in advance.. (define list3 '()) (define (E7 list1 list2) (cond ((null? list1) list3) ((member (car list1) list2) (append list3 (list (car list1)))) ) (cond ((null? list1) list3) ((not(null? list1)) (E7 (cdr list1) list2) ) ) ) (E7 '(4 5) '(3 4))

    Read the article

  • Is there any way to automatically close filename completetion buffers in Emacs?

    - by Rayne
    For example, when you open a file via C-x-C-f, you can TAB complete file names, and if there are more than one possible completions, it will pop open a completion buffer with a list of possible completions. The problem is, after you've opened the file, the window the buffer was in switches back to normal, but it doesn't close. Is there any way I can make those buffers close automatically after the file has been opened?

    Read the article

  • emacs exporting org file as PDF in batch mode

    - by Sid H
    I'm trying to export a bunch of org mode files to PDF using emacs in batch mode. So far, only export to html seems to work. When I export to html I see the following - U:\tmpd:\programs\emacs-23.1\bin\emacs.exe -batch --visit=Changelog.org --funcall org-export-as-html-batch OVERVIEW Exporting... Exporting... Saving file u:/tmp/Changelog.html... Wrote u:/tmp/Changelog.html HTML export done, pushed to kill ring and clipboard However, there is no function like org-export-as-pdf-batch and so I tried the following. U:\tmpd:\programs\emacs-23.1\bin\emacs.exe -batch --visit=Changelog.org -eval "(org-export-as-pdf \"Changelog.pdf\")" OVERVIEW Exporting to PDF... Exporting to LaTeX... Wrong type argument: number-or-marker-p, "Changelog.pdf" Any ideas on how to export to PDF? My org-mode version is 6.35i with on Emacs 23.1. I'm on WinXP.

    Read the article

  • Which tutorial on Clojure is best?

    - by Steve Rowe
    I'm interested in learning Clojure. The Getting Started page on Clojure.net is pretty minimal. Is there a good language introduction or tutorial out there? Which would you recommend? Answer: I have watched the videos on youtube called Intro to Clojure. I don't recommend those. They are a little too brief and don't give a lot of background. The talks by Clojure creater Rich Hickey. I am finding the "for Java developers" version very useful.

    Read the article

  • Regex Searching in Emacs

    - by Inaimathi
    I'm trying to write some Elisp code to format a bunch of legacy files. The idea is that if a file contains a section like "<meta name=\"keywords\" content=\"\\(.*?\\)\" />", then I want to insert a section that contains existing keywords. If that section is not found, I want to insert my own default keywords into the same section. I've got the following function: (defun get-keywords () (re-search-forward "<meta name=\"keywords\" content=\"\\(.*?\\)\" />") (goto-char 0) ;The section I'm inserting will be at the beginning of the file (or (march-string 1) "Rubber duckies and cute ponies")) ;;or whatever the default keywords are When the function fails to find its target, it returns Search failed: "[regex here]" and prevents the rest of evaluation. Is there a way to have it return the default string, and ignore the error?

    Read the article

  • Emacs 23.2 opens a new window for each compile error/warning navigated to

    - by Grant Limberg
    I've recently upgraded from Carbon Emacs (v22.3) to vanilla Emacs 23.2 (from http://www.emacsformacosx.com). On Carbon Emacs when compiling a project, The frame is split in two with the current source file/SConscript in the top window, and the compile output in the bottom window. I'd hit C-x ` to navigate to the first warning or error in the compile output and it would replace whatever was in the top window with the source file the error or warning is in. In Emacs 23.2, however, a 3rd window is opened causing two windows open in the top half of the frame (split vertically) and the compile output in the window of the bottom half of the frame. How do I tell Emacs to not open a new window and instead open the code in the the existing non-compiler output window in the frame? A little further clarification on the behavior that I just noticed. If I hit C-x ` while the buffer containing the source file or SConscript file is active, no new window is opened. It's only if I'm manually navigating through the *compilation* buffer and hitting enter on an error or warning, or mouse clicking on a warning when a third buffer window appears.

    Read the article

  • can I disable the "(Type e to repeat macro)" message in emacs?

    - by lindes
    Hi there, So, I've finally made the plunge, and have gotten to the state where I'm quite happy to have switched from vi and vim to emacs... I've been putting stuff in my .emacs file, learning how to evaluate things (not to mention becoming familiar with movement commands), etc. etc. etc. And now I have a problem with a require line in my .emacs file (a require statement*), which bombs out when I launch emacs (and generally fails to work). So, this lead me to the following situation: In the process of trying to debug the above situation, one of the steps I did was to open the file I was trying to require, and evaluate it bit by bit, using C-M-f and C-x C-e (and later just M-x eval-buffer), which all worked fine. But along the way of the section-by-section, I got tired of typing all those, and so I recorded a keyboard macro... C-x ( C-M-f C-x C-e C-x ) and then C-x e... which gave me a message in the minibuffer (I think I'm using the right name), saying (Type e to repeat macro). Which meant I could no longer see the resultant value of the evaluation of each section of code... which, while not critical in this case, I was liking having. Which leads me to the actual question: Is there a way to disable that message, and/or to cause the minibuffer to show multiple lines at once? I know about the *Messages* buffer, and that could have helped, I'm just wondering if there's a way to either disable that message, or otherwise make it coexist with other messages. Any suggestions? Thanks! lindes * - the problem at hand, which is not really my question, is that (require 'ruby-mode/ruby-mode) fails, even though emacs is definitely and successfully (per system call tracing) opening and reading the ruby-mode.el file. I presume this is because the provide line says just 'ruby-mode. I've found a solution for this, but if anyone can point me to any "best practices", I'd appreciate it.

    Read the article

  • Equivalence Classes

    - by orcik
    I need to write a program for equivalence classes and get this outputs... (equiv '((a b) (a c) (d e) (e f) (c g) (g h))) => ((a b c g h) (d e f)) (equiv '((a b) (c d) (e f) (f g) (a e))) => ((a b e f g) (c d)) Basically, A set is a list in which the order doesn't matter, but elements don't appear more than once. The function should accept a list of pairs (elements which are related according to some equivalence relation), and return a set of equivalence classes without using iteration or assignment statements (e.g. do, set!, etc.). However, set utilities such as set-intersection, set-union and a function which eliminates duplicates in a list and built-in functions union, intersection, and remove-duplicates are allowed. Thanks a lot! By the way, It's not a homework question. A friend of mine need this piece of code to solve smilar questions.

    Read the article

  • Add Keyboard Binding To Existing Emacs Mode

    - by Sean M
    I'm attempting my first modification of emacs. I recorded a little keyboard macro and had emacs spit it out as elisp, resulting in: (setq add-docstring "\C-rdef\C-n\C-a\C-m\C-p\C-i\C-u6\"\C-u3\C-b") (global-set-key "\C-c\C-d" 'add-docstring) Searching the emacs reference, though, revealed that C-c C-d is already bound in diff mode. I don't plan on using diff mode, but the future is unknowable and I'd like to not lay a trap for myself. So I'd like this keybinding to only operate in python mode, where it tries to help me add docstrings. In my /usr/share/emacs/23.whatever/list/progmodes, I found python.elc and python.el.gz. I unzipped python.el.gz and got a readable version of the elisp file. Now, though, the documentation becomes opaque to me. How can I add my key binding to the python mode, instead of globally? Is it possible, for bonus points, to apply the changes to python mode without restarting emacs or closing open files? It's the self-modifying editor, I figure there's a good chance that it's possible.

    Read the article

  • Scheme: what are the benefits of letrec?

    - by Ixmatus
    While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already defined function operating on arguments that remain static. An example of an old function using the defined function recurring on itself (nothing special): (define (substitute new old lat) (cond ((null? l) '()) ((eq? (car l) old) (cons new (substitute new old (cdr l)))) (else (cons (car l) (substitute new old (cdr l)))))) Now for an example of that same function but using letrec: (define (substitute new old lat) (letrec ((replace (lambda (l) (cond ((null? l) '()) ((eq? (car l) old) (cons new (replace (cdr l)))) (else (cons (car l) (replace (cdr l)))))))) (replace lat))) Aside from being slightly longer and more difficult to read I don't know why they are rewriting functions in the book to use letrec. Is there a speed enhancement when recurring over a static variable this way because you don't keep passing it?? Is this standard practice for functions with arguments that remain static but one argument that is reduced (such as recurring down the elements of a list)? Some input from more experienced Schemers/LISPers would help!

    Read the article

  • Inheritance classes in Scheme

    - by DreamWalker
    Now I research OOP-part of Scheme. I can define class in Scheme like this: (define (create-queue) (let ((mpty #t) (the-list '())) (define (enque value) (set! the-list (append the-list (list value))) (set! mpty #f) the-list) (define (deque) (set! the-list (cdr the-list)) (if (= (length the-list) 0) (set! mpty #t)) the-list) (define (isEmpty) mpty) (define (ptl) the-list) (define (dispatch method) (cond ((eq? method 'enque) enque) ((eq? method 'deque) deque) ((eq? method 'isEmpty) isEmpty) ((eq? method 'print) ptl))) dispatch)) (Example from css.freetonik.com) Can I implement class inheritance in Scheme?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >