0

ベクトルのリストを返す dfs メソッドがあります。ベクトルの長さに応じて要素を並べ替えるにはどうすればよいですか。

(define (dfs path) ;path store vector index, start from 0 
 (cond
 ((dfsStack' empty?)(newline))
  (else (set! currentPath (dfsStack' pop!))
      (findLast (car currentPath) 0)
      (checkUnvisited (cdr (vector-ref network lastNum)))

      (cond
        ((eq? lastName reach) ;reach point
         (duplicate path)          
         (dfs (+ path 1)) ;continue dfs to find next path         
         )
        ((and (not (eq? lastName reach))(eq? unvisited #t)) ;no more neighbours
         (dfs path)
         ) 
        ((and (not (eq? lastName reach))(eq? unvisited #f)) ;found the neighbours
         (pushStack lastNeighbours currentPath)
         (dfs path)
         )
        );//end cond
      )   
);//end cond
);//end dfs
4

1 に答える 1

1

前の質問と同じように、マージソートを使用したScheme Vector

lengthに置き換えるだけvector-lengthです。

于 2011-10-24T21:33:20.197 に答える