Giter VIP home page Giter VIP logo

blog's People

Contributors

ruandao avatar

Watchers

 avatar  avatar

blog's Issues

[12.09] mac 下的 alt option 键

解决掉一个十分头疼的问题了....
mac 下, alt 键, 默认是 option 键的... 然后用alt + 总是特殊字符, 没法使用alt 键....

解决办法, 打开终端 --> 偏好设置 -->
image

[12.02] [sicp 2.73]

a. Explain what was done above.

if the exp was number the derivative was 0.
if the exp was variable,
    if the exp was same with var, the derivative was 1,
    else the derivative was 0.
else use dispatch to get correspond operator and operands, execute it.

Why can't we assimilate the predicates number? and same-variable? into the data-directed dispatch?

???

[12.03] [sicp 2.76]

Exercise 2.76.
As a large system with generic operations evolves, new types of data objects or new operations may be needed.
For each of the three strategies -- generic operations with explicit dispatch, data-directed style, and message-passing-style -- describe the changes that must be made to a system in order to add new types or new operations.
Which organization would be most appropriate for a system in which new types must often be added?
Which would be most appropriate for a system in which new operations must often be added?

[12.09] [sicp 环境搭建]

一直都很懒, 希望把时间投入到学习中 (主要是, 之前其实配置过很多环境, 但是由于折腾(linux 的各种版本), 操作系统轮了好几回, 然后, 现在碰到东西, 都不想折腾, 只想用默认配置, 直接开学, 因为折腾的都会忘记...)
不过, sicp 用, DrRacket 有点卡....

于是准备用 emacs (之前也尝试过, 不过网上搜, 说用DrRacket 比较快速, 然后...)

网上找了,各种资料 关于 emacs 与sicp 的
然后发现这个最有用 通篇就这句话有价值哈

[11.14] 跳坑

今天忙活了一天, 主要是处理 babel 配置文件的坑

遇到的问题是 node_modules/babel-core/lib/transformation/file/options/option-manager.js:126 的报错 if (!option) this.log.error("Unknown option: " + alias + "." + key, Refe

各种搜索, 没有结果, 入坑的人太少了

然后, 有些心烦, 不加思考的各种删除, 重装, 搜索( node 都从我的系统轮回了下)
babel 也是删了好几个轮回, 一直以为是版本不对(官网也说放的最新版的会导致一些插件不能用), 后来意识到了应该是和 babel 有关的东西导致的, 然后想到修改 .babelrc 文件 恩, 注意到还有个 .babel.json 的家伙, 重命名 然后 react-native init XXXX 问题解决 KO!

推荐两个网站: 域名邮件转发我推荐的 哈, 后面那个正在开发中

[12.06] [sicp 2.86]

Exercise 2.86.
Suppose we want to handle complex numbers whose real parts, imaginary parts, magnitudes, and angles can be either ordinary numbers, rational numbers, or other numbers we might wish to add to the system.
Describe and implement the changes to the system needed to accommodate this.
You will have to define operations such as sine and cosine that are generic over ordinary numbers and rational numbers.

[15] 今天做了什么

react-native 跑起来

看了, 阮一峰变量的解构赋值, 字符串的扩展, 正则的扩展 , 感觉很多东西都是细节, 诡计, 并不那么在意, 还不如直白的东西, 更方便交流

看了, flex-box guide

[11.15] react native layout animation

恩, 直接在 setState 之前设置动画开启 LayoutAnimation.spring() 然后让动画自己玩, 这样大部分需要的动画都达到了, 等碰到具体需求再去深入挖掘, 切记解决需求, 逐步深入

[12.01] [sicp 2.72]

Exercise 2.72.
Consider the encoding procedure that you designed in exercise 2.68.
What is the order of growth in the number of steps needed to encode a symbol?
==> 最糟糕的情况是,完全二叉树, 高度为log(n); 最好的情况是, 每个节点只有一个左子节点, 这种情况频率是小于n/2
==> 啥, log(n) 貌似小于 n/2 啊
==> 好吧,这个是总的空间复杂度
==> 对于单个的时间复杂度的话,不确定, 这个没法得到平均时间复杂度,因为完全是根据输入的权重来生成的, 只能说平均值介于 log(n)< x < n/2
==> 有种复杂度计算不过关的感觉...!
Be sure to include the number of steps needed to search the symbol list at each node encountered.
To answer this question in general is difficult.
==> 深以为然
Consider the special case where the relative frequencies of the n symbols are as described in exercise 2.71, and give the order of growth (as a function of n) of the number of steps needed to encode the most frequent and least frequent symbols in the alphabet.
==> 看来有可能回答是正确的
==> 去参照下别人的
==> 我写的好像是访问的时间复杂度...
==> 貌似没错啊 ==> 是访问哈夫曼树的时间复杂度
==> 唔, 忘记考虑每次下降都要判断下左右子树的复杂度了...也就是要再*n
==> 就是说, 如果哈夫曼树是完全二叉树的话, 时间复杂度应该是nlog(n), 如果是一条线的这种的话,则是 n^2

[12.05] [sicp 2.82]

Exercise 2.82. Show how to generalize apply-generic to handle coercion in the general case of multiple arguments.
One strategy is to attempt to coerce all the arguments to the type of the first argument, then to the type of the second argument, and so on.
Give an example of a situation where this strategy (and likewise the two-argument version given above) is not sufficiently general. (Hint: Consider the case where there are some suitable mixed-type operations present in the table that will not be tried.)

[12.06] [sicp 2.89]

Exercise 2.89.
Define procedures that implement the term-list representation described above as appropriate for dense polynomials.

[12.01] [sicp 2.69] 生成哈夫曼树

sicp 2.69

恩, 新加的代码块, 再贴过来下

(define (generate-huffman-tree pairs)
  (successive-merge (make-leaf-set pairs)))

(define (successive-merge order-set)
  (define (successive-merge-1 x order-set)
    (if (null? order-set)
        x
        (successive-merge (adjoin-set (make-code-tree x (car order-set))
                                      (cdr order-set)))))
  (successive-merge-1 (car order-set) (cdr order-set)))

[12.06] [sicp 2.88]

Exercise 2.88.
Extend the polynomial system to include subtraction of polynomials.
(Hint: You may find it helpful to define a generic negation operation.)

[11.30] [sicp The decoding procedure] 如何正确的限定抽象大小

The decoding procedure

纠结于choose-branch 需要抽象成为单独的一个方法
但是

if (leaf? next-branch)
    (cons (symbol-leaf next-branch)
        (decode-1 (cdr bits) tree))
    (decode-1 (cdr bits) next-branch))

却不抽象为单独的一个方法

想了想, 感觉是 choose-branch 能够用一句话说清楚(选择分支), 但是后面这个却不能(根据是否是叶子节点,决定是否提取字符,来构建字符串;还是推延到到下个分支)

[11.30] [sicp 2.65]

Use the results of exercise 2.63 and 2.64 to give O(n) implementations of union-set and intersection-set for sets implemented as (balanced) binary trees.

[12.03] SICP Message passing

message passing 不就是闭包吗...

data-directed 需要将操作打标签存到表中, 然后根据数据带有的标签, 在表中找到操作, 应用到数据上
message passing 则是将数据放进闭包里, 然后将要进行的操作名称传进去, 根据操作名称, 在闭包里面找到对应的操作, 接着将操作应用到自带的数据上, 返回结果

data-directed 需要一个 dispatch 表, 后续处理中,可以通过修改 dispatch 表, 修改默认操作, 苹果的 Objective-c 就是这样的, 嗯, 貌似是动态类型的原型
message passing 闭包带着数据和相应的操作,在飘. 似乎像静态类型的原型

[12.01] [sicp 2.68] 编码

sicp 2.68

thinking, you need care about the border situation of the changeable variable of the recursive function

想法, 当你定义递归函数的时候, 你需要考虑,在递归过程中发生变化的变量的边界情况

[11.27] react native 碰到一个问题, update state后, render 内容没有跟着变化

_handlerOnChangeText(text) {
    console.log(text, this.state);
    if (text.endsWith(',')) {
        const content = text.split(',')[0];
        if (content.length > 0) {
            this.state.tags.push(content)
        };
        console.log('update state with value: ""');
        return this.setState({newTagValue: ''});
    };
    // console.log('update state with value: ', text);
    // this.setState({newTagValue: text});
}

render(): ReactElement {

    var tags = this.state.tags.map((tag) => <Text>{tag}</Text>)
    console.log('in render', this.state);
    // alert(JSON.stringify(this.state));
    return (
        <View style={designTagsBar.container}>
            {tags}
            <TextInput 
                    ref="tagInput"
                    style={designTagsBar.input} 
                    onKeyPress={this._handlerKeyPress.bind(this)}
                    onChangeText={this._handlerOnChangeText.bind(this)}
                    value={this.state.newTagValue}
            />
            <Text>标签(记得 ',' 哦){this.state.newTagValue}</Text>
        </View>
    );
}

恩, 问题在于, 输入 ',' 后, state值已经变为 '' 但是TextInput 的输入框里面还是之前的内容, 没有变成 '' 值, 就是说 value={this.state.newTagValue} 没有起作用

嗯, log 出来的是 in render Object {tags: Array[5], newTagValue: ""} 也就是说在 render 阶段, state 是已经变化的, 但是 新的value 并没有把 输入框的内容更新掉

[12.05] [sicp 2.83]

Exercise 2.83. Suppose you are designing a generic arithmetic system for dealing with the tower of types shown in figure 2.25: integer, rational, real, complex. For each type (except complex), design a procedure that raises objects of that type one level in the tower. Show how to install a generic raise operation that will work for each type (except complex).

[2015.11.13] 重新开始写博客哈

困死了, 一晚没睡, 折腾 nodejs 准备把 es6 学习下, 然后 reactjs, react-native
人太迟钝了, 进程也晚别人太多, 加油 && 积累

[12.04] [sicp 2.77]

Describe in detail why this works.
As an example, trace through all the procedures called in evaluating the expression (magnitude z) where z is the object shown in figure 2.24.
In particular, how many times is apply-generic invoked?
What procedure is dispatched to in each case?

[12.05] [sicp 2.84]

Exercise 2.84. Using the raise operation of exercise 2.83, modify the apply-generic procedure so that it coerces its arguments to have the same type by the method of successive raising, as discussed in this section. You will need to devise a way to test which of two types is higher in the tower. Do this in a manner that is compatible with the rest of the system and will not lead to problems in adding new levels to the tower.

[12.06] [sicp 2.85]

Exercise 2.85.
This section mentioned a method for "simplifying" a data object by lowering it in the tower of types as far as possible.
Design a procedure drop that accomplishes this for the tower described in exercise 2.83.
The key is to decide, in some general way, whether an object can be lowered.
For example, the complex number 1.5 + 0i can be lowered as far as real, the complex number 1 + 0i can be lowered as far as integer, and the complex number 2 + 3i cannot be lowered at all.
Here is a plan for determining whether an object can be lowered:
Begin by defining a generic operation project that "pushes" an object down in the tower.
For example, projecting a complex number would involve throwing away the imaginary part. Then a number can be dropped if, when we project it and raise the result back to the type we started with, we end up with something equal to what we started with.
Show how to implement this idea in detail, by writing a drop procedure that drops an object as far as possible.
You will need to design the various projection operations and install project as a generic operation in the system.
You will also need to make use of a generic equality predicate, such as described in exercise 2.79.
Finally, use drop to rewrite apply-generic from exercise 2.84 so that it "simplifies" its answers.

[12.11] [sicp 2.92]

Exercise 2.92.
By imposing an ordering on variables, extend the polynomial package so that addition and multiplication of polynomials works for polynomials in different variables. (This is not easy!)

[12.06] [sicp 2.87]

Exercise 2.87.
Install =zero? for polynomials in the generic arithmetic package.
This will allow adjoin-term to work for polynomials with coefficients that are themselves polynomials.

[11.24] react native jsx 遇到的问题

恩, 报错:

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `SearchInput`

恩, 几经折腾, 发现是 jsx 写在不同方法里面, 如果是复杂对象(jsx) 那么会报错, 譬如:

renderClearBtn() {

    return (
        <Touchablehighlight onPress={this._pressClearBtn.bind(this)} 
                                                style={designSearchInput.clearBtnStyle}>
            <Image source={require('./cancel.png')} />
        </Touchablehighlight>
    );
}

render() {
    var clearBtn = this.props.content.length > 0 ? this.renderClearBtn() : <View />
    return (
        <LinearGradient start={[0.0, 0.0]} end={[0.0,0.0]} 
                                        colors={['#775F3A', '#897866']}
                                        style={[designSearchInput.containerStyle, this.props.style]} >
            <Image source={require('./search.png')}
                            style={designSearchInput.searchIcoStyle} />
            <TextInput style={designSearchInput.textInputStyle}
                                    onChangeText={this.onChangeText.bind(this)}
                                    value={this.props.content} />

            {clearBtn}
        </LinearGradient>
    );

�但是, 这样写, 却没有错?

    renderClearBtn() {
    return <View></View>
    return <View><Touchablehighlight onPress={this._pressClearBtn.bind(this)} style={designSearchInput.clearBtnStyle}><Image source={require('./cancel.png')} /></Touchablehighlight></View>
}

why?

[11.29] 恩, 先做简单的

恩, 推动项目前进, 不要陷入到细节中

sicp我推荐的 给完成掉, 如果有时间就把 csapp 也kill掉

[12.02] 番茄时钟

想了下, 觉得番茄时钟的重点在于 那5分钟, 你必须彻底的释放刚才的注意力, 充分的做一件别的事, 譬如从脑力活动 ==> 体力活动(十分耗费体力的, 让自己能够汗流浃背的运动, 而且是在5分钟内完成)

[12.05] [sicp 2.81]

a. With Louis's coercion procedures installed, what happens if apply-generic is called with two arguments of type scheme-number or two arguments of type complex for an operation that is not found in the table for those types? For example, assume that we've defined a generic exponentiation operation:

(define (exp x y) (apply-generic 'exp x y))

and have put a procedure for exponentiation in the Scheme-number package but not in any other package:

;; following added to Scheme-number package
(put 'exp '(scheme-number scheme-number)
    (lambda (x y) (tag (expt x y)))) ; using primitive expt

What happens if we call exp with two complex numbers as arguments?

会陷入递归中...死循环

[12.06] [sicp 2.90]

本来想要让add-terms 复用的, 结果卡在make-term 上, 依赖于具体的细节, 只能让add-termsdense 里面和 spare 里面各自都重复一遍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.