scheme

Find main diagonal in matrix - Scheme

醉酒当歌 提交于 2019-12-02 03:50:22
I need to extract the main diagonal from a square matrix (1 2 3) (4 5 6) -> (1 5 9) (7 8 9) I have the following code and I need to replace the ... with the appropriate functions. (define (diag m) (if (null? m) '() (cons (... m) (diag (map ... (... m)))))) Input: (diag '((1 2 3) (4 5 6) (7 8 9))) Output: (1 5 9) Any ideas? Thank you! So you are asking, given you have the list '((1 2 3) (4 5 6) (7 8 9)) how do I get the value 1 from it? Then you are asking given the same list, how do I get ((4 5 6) (7 8 9)) from it. Then given that result how do I make a new list using map that only takes the

E4A写的app,点按钮,直接进入抖音指定用户界面

牧云@^-^@ 提交于 2019-12-02 03:27:29
今天在网上看到有一个人,直接进抖音某个指定用户的界面,一般模拟的方式,要先通过搜索的方式,再选用户,点进去 但是这样操作,不大友好,也影响速度 最理想的方式,是通过 "无障碍",直接控制抖音进入指定的界面 一般要先分析抖音app的,用apkTool反编译出 AndroidManifest.xml文件 然后分析xml代码,找到相应的 intent-filter 在他的AndroidManifest.xml中应该注册了一个相应的scheme来接收参数并且跳转到用户页面的那个activity里面去 清单文件里面的intent过滤器自定义的data数据 然后再写了个HTML 打开这个这个HTML就可以了 刚开始用 https 开头,但是打开时,会有一个打开方式的提示 后来经过指点,用“snssdk1128://user/profile/102630827178” 用抖音唯一的 scheme 就可以了 用 E4A 打开指定网址()这个方法就可以了 ===================================================================== Android 中通过网页中的链接打开自己的APP 转自: https://blog.csdn.net/qq_40441190/article/details/83059437 页面需求:最近遇见一个需求

Sorting list of pairs by the second element of the pairs in scheme

陌路散爱 提交于 2019-12-02 03:26:57
I have procedure in scheme which give me a list of pairs and I need to sort descending this list by the second element of the pairs. Like this: ((1 . 1) (2 . 3) (3 . 2)) --> ((2 . 3) (3 . 2) (1 . 1)) ((1 . 1) (x . 3) (2 . 1) (3 . 1)) --> ((x . 3) (1 . 1) (2 . 1) (3 . 1)) ((1 . 3) (3 . 4) (2 . 2)) --> ((3 . 4) (1 . 3) (2 . 2)) I have no idea how I should use sorting for this. Just use the built-in sort procedure: (define (sort-desc-by-second lst) (sort lst (lambda (x y) (> (cdr x) (cdr y))))) (sort-desc-by-second '((1 . 1) (2 . 3) (3 . 2))) => '((2 . 3) (3 . 2) (1 . 1)) The trick here is

In Racket, if an unquoted pair is constructed with the dot notation, is it possible to use a variable or an expression value for the second element?

时间秒杀一切 提交于 2019-12-02 03:26:22
In Racket, the following works: (+ . [1 2]) ; => 3 { define a + } (a . [1 2]) ; => 3 However, i see no way to define b to be the (1 2) list so as to get (+ . b) and (a . b) to return 3 . Is it possible? Sure, just use apply : (define a +) (define b '(1 2)) (apply a b) ; => 3 (apply + b) ; => 3 Óscar López How about this ... without using apply but using eval . But seriously, using apply is a better idea in this case, there's nothing wrong with it ( eval is evil though, see the documentation to understand the last part with the namespace): (define a +) (define b '(1 2)) ; executing in the

How to do this length≤1 more than once?

大憨熊 提交于 2019-12-02 03:22:39
问题 I've spent a day reading page 166's length≤1 in the book The Little Schemer ; there's the following code: (((lambda (mk-length) (mk-length mk-length)) (lambda (mk-length) (lambda (l) (cond ((null? l) 0) (else (add1 ((mk-length eternity) (cdr l)))))))) l) where l is (apples) and eternity is as follows: (define eternity (lambda (x) (eternity x))) Page 166 (4th ed.) states that: When we apply mk-length once, we get length≤1 And then Could we do this more than once? But I do not know how to do

Get the middle elements from List in scheme

喜你入骨 提交于 2019-12-02 02:55:29
I'm new to scheme , can someone please give me ideas on how to get , "the middle element from a list?" Here's my solution. It's based on a tortoise-and-hare algorithm (which is used in any kind of list traversal where you need to detect circular lists), so it doesn't do any more work than a sane list traversal has to do anyway. :-) (define (middle-elements lst) (if (null? lst) '() (let loop ((tortoise lst) (hare (cdr lst))) (cond ((eq? tortoise hare) #f) ((null? hare) (list (car tortoise))) ((null? (cdr hare)) (list (car tortoise) (cadr tortoise))) (else (loop (cdr tortoise) (cddr hare)))))))

scheme continuation inside a for-each

二次信任 提交于 2019-12-02 02:43:34
问题 I'm currently studying Scheme for a course at my university, while looking at some exercises I got stuck on this particular one. Professor has yet to answer my previous mails therefore I have more chances to receive an answer here faster. Given this code (define (list-iter-cc lst) (call/cc (lambda (return) (for-each (lambda (x) (call/cc (lambda (next-step) (return (cons x next-step))))) lst) 'end))) I have to use it to write the iter macro whose syntax is (iter <a variable symbol> in <a list>

Xcodebuild稳定性测试go脚本

穿精又带淫゛_ 提交于 2019-12-02 02:20:41
简单封装下xcodebuild test命令,写一个执行xcode测试的go程序,可以设定单case执行次数,也可以二次组装调用进行多个case的测试,代码如下: package main import ( "flag" "fmt" "os/exec" "strings" ) func qnegTestRunner(workspacePath string, scheme string, targetMethod string) (testResult int) { targets := strings.Split(targetMethod, "/") className := targets[1] methodName := targets[2] var err error var cmd *exec.Cmd var result []byte commandString := fmt.Sprintf("xcodebuild test -workspace %s -scheme %s -destination 'platform=iOS Simulator,name=iPhone 7,OS=12.2' -only-testing:%s", workspacePath, scheme, targetMethod) cmd = exec.Command("/bin/bash", "

Sort a list in scheme

此生再无相见时 提交于 2019-12-02 02:20:27
问题 I want to create function which sorts list. For example I have this list: x1, x2, x3 .... xn or 1, 2, 3, 4, 5, 6 I want to display the numbers in this order: x1, xn, x2, xn-1 or 1, 6, 2, 5, 3, 4 Can you help me to write this example? 回答1: Usually when we talk about sorting, we refer to ordering the items by some characteristic of the item contents, not the item position in the list. I would call your situation permuting, but perhaps some people might dispute that usage, too. :-) Here's how

scheme continuation inside a for-each

空扰寡人 提交于 2019-12-02 02:11:56
I'm currently studying Scheme for a course at my university, while looking at some exercises I got stuck on this particular one. Professor has yet to answer my previous mails therefore I have more chances to receive an answer here faster. Given this code (define (list-iter-cc lst) (call/cc (lambda (return) (for-each (lambda (x) (call/cc (lambda (next-step) (return (cons x next-step))))) lst) 'end))) I have to use it to write the iter macro whose syntax is (iter <a variable symbol> in <a list> <code>) example: (iter x in '(1 2 3) (display x) (newline)) Since I couldn't understand list-iter-cc i