我有嵌套列表((“ H”“ E”“ L”“ L”“ O”)(“ T”“ H”“ I”“ S”)(“ I”“ S”)(“ A “)(” T“” E“” S“” T“)))我想使用替代将列表中的每个字符串替换为另一个字符串,但是它不起作用我的代码是:
(substitute "H" "W" paragraph)
段落是嵌套列表的名称。
答案 0 :(得分:4)
使用SUBST
:
struct GameView: View {
@State var locationManager: LocationManager
var body: some View {
MapView(locationManager: $locationManager)
}
}
struct MapView: UIViewRepresentable {
@Binding var locationManager: LocationManager
func makeUIView(context: Context) -> GMSMapView{ ... }
func updateUIView(_ mapView: GMSMapView, context: Context) { ... }
}
class LocationManager: NSObject, CLLocationManagerDelegate, ObservableObject {
var didChange = PassthroughSubject<LocationManager, Never>()
var lastKnownLocation: CLLocation {
didSet {
// Propagate the update to the observers.
didChange.send(self)
print("Finished propagating lastKnownLocation to the observers.")
}
}
...
}
如果您需要修改列表,请使用CompletableFuture<List<String>> completableFuture =
CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url1))
.thenCombine(CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url2)),
//.thenCombine(CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url3)),
(s1, s2) -> List.of(s1,s2));
//(s1, s2, s3) -> List.of(s1, s2, s3));
并将结果分配回原始变量:
(setq new-list (subst "W" "H" old-list :test #'string=))