Search Results

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

Page 4/20 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Lisp data security/validation

    - by Wayne Werner
    This is really just a conceptual question for me at this point. In Lisp, programs are data and data are programs. The REPL does exactly that - reads and then evaluates. So how does one go about getting input from the user in a secure way? Obviously it's possible - I mean viaweb - now Yahoo!Stores is pretty secure, so how is it done?

    Read the article

  • Really minimum lisp

    - by Mgccl
    What is the minimum set of primitives required such that a language is Turing complete and a lisp variant? Seems like car, cdr and some flow control and something for REPL is enough. It be nice if there is such list. Assume there are only 3 types of data, integers, symbols and lists.(like in picolisp)

    Read the article

  • Hidden features of Emacs Lisp?

    - by anon
    What are some features of Emacs Lisp that you use to solve real problems? One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using bold title as the first line See also: Hidden features of Python Hidden features of Ruby Hidden features of Perl Hidden features of Java

    Read the article

  • lisp, differences in assignment functions

    - by johnc
    I'm pretty new to lisp, so apologies for what may be a simple question, Whilst I understand the difference between DEFVAR and DEFPARAMETER (defvar only sets undefined variables), and the LET is for local scope only, what is the is the use of SETF as opposed to the other, previously mentioned assignment functions?

    Read the article

  • a question on common lisp

    - by kostas
    Hello people, I'm getting crazy with a small problem here, I keep getting an error and I cant seem to figure out why, the code is supposed to change the range of a list, so if we give it a list with values (1 2 3 4) and we want to change the range in 11 to fourteen the result would be (11 12 13 14) the problem is that the last function called scale-list will give back an error saying: Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) anybody has a clue why? I use aquamacs as an editor thanks in advance ;;finds minimum in a list (defun minimum(list) (car (sort list #'<))) ;;finds maximum in a list (defun maximum(list) (car (sort list #'>))) ;;calculates the range of a list (defun range(list) (- (maximum list) (minimum list))) ;;this codes scales a value from a list (defun scale-value(list low high n) (+ (/ (* (- (nth (- n 1) list) (minimum list)) (- high low)) (range list)) low)) ;and this code is supposed to scale the whole list (defun scale-list(list low high n) (unless (= n 0) (cons (scale-value list low high n) (scale-list list low high (- n 1))))) (scale-list '(0.1 0.3 0.5 0.9) 20 30 4)

    Read the article

  • Overriding a function in Emacs Lisp

    - by scrapdog
    I would like to temporarily override the kill-new function. I have a way I want to reimplement kill-new that works in only in certain contexts, but I don't want to reimplement a special version of kill-region on top of that. (kill-new is called from kill-region) Since Emacs Lisp uses dynamic scoping, this should be possible, right? (On the other hand, it seems that this would be an unsafe thing to support, and it might make me a bit nervous knowing that it is possible...) I have experimented with using let and fset, but so far have found no way to get it to work as expected. So, hopefully someone can fill in the blank in the following pseudocode: (defun my-kill-new (string &optional replace yank-handler) (message "in my-kill-new!")) (defun foo () (some-form-that-binds-a-function (kill-new my-kill-new) (kill-region (point) (mark)))) What should some-form-that-binds-a-function be? Or am I barking up the wrong tree?

    Read the article

  • Clojure: Equivalent to Common Lisp READ function?

    - by jkndrkn
    Hi there. When I want to read in an S-expression stored in a file into a running Common Lisp program, I do the following: (defun load-file (filename) "Loads data corresponding to a s-expression in file with name FILENAME." (with-open-file (stream filename) (read stream))) If, for example, I have a file named foo.txt that contains the S-expression (1 2 3), the above function will return that S-expression if called as follows: (load-file "foo.txt"). I've been searching and searching and have not found an equally elegant solution in Clojure. Any ideas? Thanks!

    Read the article

  • In Lisp, Avoid "Cannot open load file" when using require

    - by Jesse
    I am working on a custom .emacs file that I will be able to use on several different computers. I would like to be able to load a mode if it exists on the system. If it does not exist I would like Emacs to stop showing the error: File error: Cannot open load file, X. For example: (require 'darkroom-mode) Results in: File error: Cannot open load file, darkroom-mode I am using file-exists-p to test if certain other files exist but for this test I would assume I need to search my load-path. I am new to Lisp so this is stumping me.

    Read the article

  • Help writing emacs lisp for emacs etags search

    - by user535707
    I'm looking for some help developing what I think should be an easy program. I want something similar to Emacs tags-search command, but I want to collect all search results into a buffer. (I want to see all results of M-,) I'm thinking this python style pseudo code should work, but I have no idea how to do this in emacs lisp? Any help would be greatly appreciated. def myTagsGrep(searchValue): for aFile in the tag list: result = grep aFile seachValue if len(result) > 0: print aFile # to the buffer print result # to the buffer I would like to be able to browse through the buffer with the same features tags-apropos does. Note that a similar question has been asked before: Is there a way to get emacs tag-search command to output all results to a buffer?

    Read the article

  • Clojure for a lisp illiterate

    - by dbyrne
    I am a lifelong object-oriented programmer. My job is primarily java development, but I have experience in a number of languages. Ruby gave me my first real taste of functional programming. I loved the features Ruby borrowed from the functional paradigm such as closures and continuations. Eventually, I graduated to Scala. This has been a great way to gradually learn to approach non-trivial problems in a functional manner. Now I am interested in Clojure. I know all the sexy features that make it enticing (software transactional memory, macros, etc.), but I just can't get used to "thinking in lisp". I've seen Rich Hickey's screencasts aimed at java programmers, but they are geared towards explaining language features and not approaching real world problems. I am looking for any advice or resources which have made this transition easier for others.

    Read the article

  • Could anyone tell me something about Scheme Common-Lisp and FASL File.

    - by Joe
    Does anyone could tell something about these file? As I know: 1. Common-Lisp and Scheme are both some lisp programming langue. 2. common-Lisp source file *.lisp can be compiled into binary file *.fasl which can be load faster than the source file. Q:Can the Scheme source code *.scm be compiled into some binary file that will be load faster than the source code? Thanks in advance joe

    Read the article

  • Slime: frame-source-location not implemented / is my sldb Backtrace output normal?

    - by Joel
    I'm debugging my Lisp code in Slime. When the debugger generates the Backtrace it's my understanting that I can hit 'v' on a frame to take me to the source. When I do this on the first (0 index) frame (or indeed any frame) I get frame-source-location not implemented Is this expected, am I missing anything? Edit1: In addition every single frame has "No Locals", is this to be expected too? Edit2: In fact, the whole backtrace output is pretty unintelligible. I'm new to Lisp, so I wasn't initially sure if this was expected or not - but I'm attaching a screenshot, hopefully someone can confirm for me if this looks 'normal':

    Read the article

  • Cadr of a list involving assoc function

    - by user3619045
    I have looked around on the net and cant find an answer to my query. I would really appreciate if someone could provide a good answer without down rating this post. In Lisp car, cdr are used on data mode like '(whatever here) which makes sense to me. Now, in the book Land of Lisp the author is explaining how to build a text engine and suddenly he uses the following description to make a function. (defun describe-location (location nodes) (cadr (assoc location nodes))) Can I ask why is he doing a cadr on a list and how come it provides a response and not an error? shouldn't it be a data mode i.e with a quote in front of the opening bracket '(whatever here)? and also why is he using assoc as in (assoc location nodes) and not (assoc 'garden *nodes*) Isn't the second correct way to use assoc ? I may be missing the big picture and as such would really appreciate someone explaining these key points please. Many thanks!

    Read the article

  • Help me write my LISP :) LISP environments, Ruby Hashes...

    - by MikeC8
    I'm implementing a rudimentary version of LISP in Ruby just in order to familiarize myself with some concepts. I'm basing my implementation off of Peter Norvig's Lispy (http://norvig.com/lispy.html). There's something I'm missing here though, and I'd appreciate some help... He subclasses Python's dict as follows: class Env(dict): "An environment: a dict of {'var':val} pairs, with an outer Env." def __init__(self, parms=(), args=(), outer=None): self.update(zip(parms,args)) self.outer = outer def find(self, var): "Find the innermost Env where var appears." return self if var in self else self.outer.find(var) He then goes on to explain why he does this rather than just using a dict. However, for some reason, his explanation keeps passing in through my eyes and out through the back of my head. Why not use a dict, and then inside the eval function, when a new "sub-environment" needs to be created, just take the existing dict and update the key/value pairs that need to be updated, and pass that new dict into the next eval? Won't the Python interpreter keep track of the previous "outer" envs? And won't the nature of the recursion ensure that the values are pulled out from "inner" to "outer"? I'm using Ruby, and I tried to implement things this way. Something's not working though, and it might be because of this, or perhaps not. Here's my eval function, env being a regular Hash: def eval(x, env = $global_env) ........ elsif x[0] == "lambda" then ->(*args) { eval(x[2], env.merge(Hash[*x[1].zip(args).flatten(1)])) } ........ end The line that matters of course is the "lambda" one. If there is a difference, what's importantly different between what I'm doing here and what Norvig did with his Env class? If there's no difference, then perhaps someone can enlighten me as to why Norvig uses the Env class. Thanks :)

    Read the article

  • Cocoa equivalent of the Carbon method getPtrSize

    - by Michael Minerva
    I need to translate the a carbon method into cocoa into and I am having trouble finding any documentation about what the carbon method getPtrSize really does. From the code I am translating it seems that it returns the byte representation of an image but that doesn't really match up with the name. Could someone give me a good explanation of this method or link me to some documentation that describes it. The code I am translating is in a common lisp implementation called MCL that has a bridge to carbon (I am translating into CCL which is a common lisp implementation with a Cocoa bridge). Here is the MCL code (#_before a method call means that it is a carbon method): (defmethod COPY-CONTENT-INTO ((Source inflatable-icon) (Destination inflatable-icon)) ;; check for size compatibility to avoid disaster (unless (and (= (rows Source) (rows Destination)) (= (columns Source) (columns Destination)) (= (#_getPtrSize (image Source)) (#_getPtrSize (image Destination)))) (error "cannot copy content of source into destination inflatable icon: incompatible sizes")) ;; given that they are the same size only copy content (setf (is-upright Destination) (is-upright Source)) (setf (height Destination) (height Source)) (setf (dz Destination) (dz Source)) (setf (surfaces Destination) (surfaces Source)) (setf (distance Destination) (distance Source)) ;; arrays (noise-map Source) ;; accessor makes array if needed (noise-map Destination) ;; ;; accessor makes array if needed (dotimes (Row (rows Source)) (dotimes (Column (columns Source)) (setf (aref (noise-map Destination) Row Column) (aref (noise-map Source) Row Column)) (setf (aref (altitudes Destination) Row Column) (aref (altitudes Source) Row Column)))) (setf (connectors Destination) (mapcar #'copy-instance (connectors Source))) (setf (visible-alpha-threshold Destination) (visible-alpha-threshold Source)) ;; copy Image: slow byte copy (dotimes (I (#_getPtrSize (image Source))) (%put-byte (image Destination) (%get-byte (image Source) i) i)) ;; flat texture optimization: do not copy texture-id -> destination should get its own texture id from OpenGL (setf (is-flat Destination) (is-flat Source)) ;; do not compile flat textures: the display list overhead slows things down by about 2x (setf (auto-compile Destination) (not (is-flat Source))) ;; to make change visible we have to reset the compiled flag (setf (is-compiled Destination) nil))

    Read the article

  • Permuting output of a tree of closures

    - by yan
    This a conceptual question on how one would implement the following in Lisp (assuming Common Lisp in my case, but any dialect would work). Assume you have a function that creates closures that sequentially iterate over an arbitrary collection (or otherwise return different values) of data and returns nil when exhausted, i.e. (defun make-counter (up-to) (let ((cnt 0)) (lambda () (if (< cnt up-to) (incf cnt) nil)))) CL-USER> (defvar gen (make-counter 3)) GEN CL-USER> (funcall gen) 1 CL-USER> (funcall gen) 2 CL-USER> (funcall gen) 3 CL-USER> (funcall gen) NIL CL-USER> (funcall gen) NIL Now, assume you are trying to permute a combinations of one or more of these closures. How would you implement a function that returns a new closure that subsequently creates a permutation of all closures contained within it? i.e.: (defun permute-closures (counters) ......) such that the following holds true: CL-USER> (defvar collection (permute-closures (list (make-counter 3) (make-counter 3)))) CL-USER> (funcall collection) (1 1) CL-USER> (funcall collection) (1 2) CL-USER> (funcall collection) (1 3) CL-USER> (funcall collection) (2 1) ... and so on. The way I had it designed originally was to add a 'pause' parameter to the initial counting lambda such that when iterating you can still call it and receive the old cached value if passed ":pause t", in hopes of making the permutation slightly cleaner. Also, while the example above is a simple list of two identical closures, the list can be an arbitrarily-complicated tree (which can be permuted in depth-first order, and the resulting permutation set would have the shape of the tree.). I had this implemented, but my solution wasn't very clean and am trying to poll how others would approach the problem. Thanks in advance.

    Read the article

  • uses for dynamic scope?

    - by Stephen
    Hi, I've been getting my hands wet with emacs lisp, and one thing that trips me up sometimes is the dynamic scope. Is there much of a future for it? Most languages I know use static scoping (or have moved to static scoping, like Python), and probably because I know it better I tend to prefer it. Are there specific applications/instances or examples where dynamic scope is more useful?

    Read the article

  • Emacs Lisp: how to set encoding for call-process

    - by RamyenHead
    I thought I knew how to set coding-system (or encoding): use process-coding-system-alist. Apparently, it's not working. ;; -*- coding: utf-8 -*- (require 'cl) (let ((process-coding-system-alist '("cygwin/bin/bash" . (utf-8-dos . utf-8-unix)))) (setq my-words (list "Lilo" "?_?" "_?" "?_" "?" "Stitch") my-cygwin-bash "C:/cygwin/bin/bash.exe" my-outbuf (get-buffer-create "*my cygwin bash echo test*") ) (with-current-buffer my-outbuf (goto-char (point-max)) (loop for word in my-words do (insert (concat "echo " word "\n")) (call-process my-cygwin-bash nil my-outbuf nil "-c" (concat "echo " word))) ) (display-buffer my-outbuf) ) Running the above code, the output is this: echo Lilo Lilo echo ?_? /usr/bin/bash: -c: line 0: unexpected EOF while looking for matching `"' /usr/bin/bash: -c: line 1: syntax error: unexpected end of file echo _? /usr/bin/bash: -c: line 0: unexpected EOF while looking for matching `"' /usr/bin/bash: -c: line 1: syntax error: unexpected end of file echo ?_ /usr/bin/bash: $'echo \346\267\205?': command not found echo ? /usr/bin/bash: -c: line 0: unexpected EOF while looking for matching `"' /usr/bin/bash: -c: line 1: syntax error: unexpected end of file echo Stitch Stitch Anything sent to cygwin in unicode is failing (MS Windows, Korean).

    Read the article

  • Common lisp gray streams

    - by Sid H
    Is there a tutorial on how to use gray streams? I want to create a class that reads from a file while looking for a specific set of bytes. My initial thought was to use gray streams, but could not find any starting information.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >