func query(address: String) -> String {
let url = URL(string: address)
let semaphore = DispatchSemaphore(value: 0)
var result: String = ""
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elm - Friendly functional programming for the Web | |
Intro | |
==== | |
- I'm just learning | |
- Evan Czaplicki, Harvard, programming for the Web doesn't have to be painful | |
- Ideas from academia | |
- Rocks the FP community boat by making ideas approachable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
m := make(map[int]int) | |
m[1] = 0 | |
for k, v := range m { | |
m[k + k] = v | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const backoff = (maxRetries, delayFunction) => | |
attempts => attempts | |
.zip(Rx.Observable.range(1, maxRetries), (a, idx) => idx) | |
.delayWhen(idx => Rx.Observable.timer(delayFunction(idx))); | |
// usage | |
const withIncrementalBackoff = observable.retryWhen(backoff(3, nRetry => nRetry * 1000)); | |
const withExponentialBackoff = observable.retryWhen(backoff(3, nRetry => nRetry * nRetry * 1000)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func query(address: String) -> String { | |
let url = URL(string: address) | |
let semaphore = DispatchSemaphore(value: 0) | |
var result: String = "" | |
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in | |
result = String(data: data!, encoding: String.Encoding.utf8)! |
Tagir Magomedov:
Напиши функцию на C#, которая выполняет поиск пути во взвешенном ориентированном графе.
ChatGPT:
Для поиска кратчайшего пути во взвешенном ориентированном графе, одним из популярных алгоритмов является алгоритм Дейкстры. Вот пример реализации алгоритма Дейкстры на C#:
using System;
OlderNewer