我正在学习Emacs Lisp,我遇到了这个十年前的帖子,说在某些时候Guile(Scheme)将取代Emacs Lisp,或者Emacs将被Guile重写.
https://web.archive.org/web/20081201143448/http://sanpietro.red-bean.com/guile/guile/old/3114.html
我想知道这是否还有可能,并且开发人员是否应该尝试用这个来编写Elisp?最初的目标是让Guile向后兼容Elisp,但似乎开发Scheme是更好的选择.
我想在页面底部添加一行"All Rights Reserved ...".我尝试使用绝对定位,但当窗口调整到较小的高度时,这不能按预期工作.
我怎样才能实现这个简单的目标?
我想.unique()在迭代器上定义一个方法,使我能够迭代而不重复.
use std::collections::HashSet;
struct UniqueState<'a> {
seen: HashSet<String>,
underlying: &'a mut Iterator<Item = String>,
}
trait Unique {
fn unique(&mut self) -> UniqueState;
}
impl Unique for Iterator<Item = String> {
fn unique(&mut self) -> UniqueState {
UniqueState {
seen: HashSet::new(),
underlying: self,
}
}
}
impl<'a> Iterator for UniqueState<'a> {
type Item = String;
fn next(&mut self) -> Option<String> {
while let Some(x) = self.underlying.next() {
if !self.seen.contains(&x) {
self.seen.insert(x.clone());
return Some(x);
}
}
None
}
} …Run Code Online (Sandbox Code Playgroud) 有两个不等于运算符 - !=和<>.
他们之间有什么区别?我听说!=比其他字符串更有效率.任何人都可以对此声明作出定性评论.
我正在使用centos,我将python2.7交替安装到默认的python中.我可以用pip安装我想要的所有模块,但是我无法安装scipy.当我在做的时候
sudo /usr/local/bin/pip2.7 install scipy
Run Code Online (Sandbox Code Playgroud)
它正在下载它,但后来我有这个错误消息:
blas_mkl_info:
libraries mkl,vml,guide not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib']
NOT AVAILABLE
openblas_info:
libraries not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64/atlas', '/usr/lib64/sse2', '/usr/lib64', '/usr/lib']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64/atlas', '/usr/lib64/sse2', '/usr/lib64', '/usr/lib']
NOT AVAILABLE
/usr/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1521: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section …Run Code Online (Sandbox Code Playgroud) 我有这些课程:
class Family(object):
__slot__ = ['father', 'var1']
def __init__(self, father, var1 = 1):
self.father, self.var1 = father var1
class Father(object):
__slots__ = ['var2']
def __init__(self, var2 = ''):
self.var2 = var2
father = Father()
family = Family(father = father)
Run Code Online (Sandbox Code Playgroud)
我想腌制"家庭"对象.所以我需要覆盖__getstate__和__setstate__
"家庭"和"父亲"类.
你能告诉我一个有效的方法吗?(我使用的原因__slots__是因为我有很多对象而且我正在努力节省内存)
给定一个对象列表,我不想要许多键:
[{
"name": "Alice",
"group": "Admins",
"created": "2014"
}, {
"name": "Bob",
"group": "Users",
"created": "2014"
}]
Run Code Online (Sandbox Code Playgroud)
如何过滤这些对象以仅包含我想要的键?
[{
"name": "Alice"
}, {
"name": "Bob"
}]
Run Code Online (Sandbox Code Playgroud)
我已经尝试jq '.[].name'但是提取值,而不是保留对象.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 123, in <module>
from . import cbook
ImportError: cannot import name cbook
Run Code Online (Sandbox Code Playgroud)
我找不到解决方案,有人可以帮忙吗?
这按预期工作
def outer_func():
from time import *
print time()
outer_func()
Run Code Online (Sandbox Code Playgroud)
我可以在上下文中定义嵌套函数,并从其他嵌套函数中调用它们:
def outer_func():
def time():
return '123456'
def inner_func():
print time()
inner_func()
outer_func()
Run Code Online (Sandbox Code Playgroud)
我甚至可以导入个别功能:
def outer_func():
from time import time
def inner_func():
print time()
inner_func()
outer_func()
Run Code Online (Sandbox Code Playgroud)
但是,这会引发SyntaxError: import * is not allowed in function 'outer_func' because it contains a nested function with free variables:
def outer_func():
from time import *
def inner_func():
print time()
inner_func()
outer_func()
Run Code Online (Sandbox Code Playgroud)
我知道这不是最佳做法,但为什么不起作用?
我现在正通过MELPA和Marmalade尽可能多地安装,我使用git管理我的〜/ .emacs.d.但是,我有git ignore*.elc文件.
这意味着当我在一个系统上安装一个软件包然后开始使用另一个系统时,git pull只给我*.el文件.使用这些文件通常比使用*.elc慢.
我尝试将以下内容添加到〜/ .emacs.d/init.el中:
;; load the packages we've installed. Note that package-install
;; byte-compiles the packages, but .elc is ignored by git so we force recompilation here
(byte-recompile-directory (expand-file-name "~/.emacs.d/elpa") 0)
(package-initialize)
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不等于package.el完成的编译.例如,如果我安装emacs-eclim,package.el不会编译emacs-eclim/company-emacs-eclim.el,我收到以下错误:
Leaving directory `/home/wilfred/.emacs.d/elpa'
Compiling file /home/wilfred/.emacs.d/elpa/emacs-eclim-20130310.1237/company-emacs-eclim.el at Mon Mar 11 15:40:01 2013
Entering directory `/home/wilfred/.emacs.d/elpa/emacs-eclim-20130310.1237/'
company-emacs-eclim.el:35:1:Error: Cannot open load file: eclim
Warning: reference to free variable `multiple-cursors-mode'
Warning: reference to free variable `mc--read-char'
Warning: assignment to free variable `mc--read-char'
Warning: reference …Run Code Online (Sandbox Code Playgroud)