문제

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))
도움이 되었습니까?

해결책

아니오, 당신은 할 수 없습니다.첫째, Apple은 필요한 앱의 소스 코드에 액세스 할 수 없습니다.또한 Apple은 API를 수정할 수 있도록 API를 제공하지 않습니다.데이터에 액세스 할 수 있습니다 (노래 자체) 그래서 실제로 다른 것을 원한다면, 자신의 앱을 작성해야합니다.

다른 팁

I think I see your problem. There are two ways to add an element to a list.

The first way would be actually adding it:

(define (intersect list1 list2)
  (define newlist list2)
  (do ((iter1 list1 (cdr iter1)))
    (not (null? iter1))
    (if (not (member (car iter1) newlist))
        (set! newlist (cons (car iter1) newlist)))))

(You'll probably have to look up the definition of do if you really want to use this.)

You may notice that that's quite ugly. That's because no one actually does it this way. Instead, you have to realize that calling a function creates a new variable as well. Try this:

(define (intersect list1 list2)
  (cond ((null? list1) list2)
        ((member (car list1) list2) (intersect (cdr list1) list2))
        (else (intersect (cdr list1) (cons (car list1) list2)))))

If you're familiar with algorithms, you'll notice that the code I just wrote is quite slow, but it illustrates the point: in each case, you do a little bit of work and then call your function again. If you're having trouble seeing why this works, run this function instead on your example:

(define (intersect list1 list2)
  (display list1) (display " ") (display list2) (newline)
  (cond ((null? list1) list2)
        ((member (car list1) list2) (intersect (cdr list1) list2))
        (else (intersect (cdr list1) (cons (car list1) list2)))))

이 코드를 사용해보십시오 ..

function ShowModal() {
    ExecuteOrDelayUntilScriptLoaded(function () {
        var options = {
            url: 'servername/webpart.aspx',
            tite: 'Add Vendor',
            width: 800,
            height: 475,
            allowMaximize: true,
            showClose: true,
            dialogReturnValueCallback: scallback
        };
        SP.UI.ModalDialog.showModalDialog(options);
    }, 'sp.js');
 }

 function scallback(dialogResult, returnValue) {
      if (dialogResult == SP.UI.DialogResult.OK) {
           SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
      }
.

소스 : sp.ui.modaldialog.refresh 페이지에서대화 자체?

You're better off using set operations from srfi-1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top