Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Baum

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

Ich habe folgende Aufgabestellung:

ich muss eine Funktion

filterE :: (v -> l -> v -> Bool) -> [LabeledEdge v l] -> [LabeledEdge v l]

schreiben, die aus einer Liste von beschrifteten Kanten diejenigen zurückgibt, für die die als erstes Argument übergebene

Funktion True zurückgibt.

Ich selbst habe so weit den Baum so dargestellt:

data LabeledGraph v l = Graph [LabeledEdge v l] deriving Show

data LabeledEdge v l = Edge v l v deriving Show

data ContactType = Friend | Business | Lover deriving Show

socialNetwork :: LabeledGraph String ContactType

socialNetwork =

Graph

[Edge "Carol" Friend "Alice",

Edge "Alice" Friend "Carol",

Edge "Carol" Friend "Fran",

Edge "Fran" Friend "Carol",

Edge "Fran" Business "Alice",

Edge "Alice" Business "Fran",

Edge "Eve" Business "Fran",

Edge "Fran" Business "Eve",

Edge "Alice" Business "Dave",

Edge "Dave" Business "Alice",

Edge "Alice" Lover "Bob",

Edge "Bob" Lover "Alice",

Edge "Eve" Friend "Bob",

Edge "Bob" Friend "Eve",

Edge "Bob" Freind "Dave",

Edge "Dave" Friend "Bob"]

filterE :: (v -> l -> v -> Bool) -> [LabledEdge v l] -> [LabledEdge v l]

filterE g (Graph x:xs) =

Kann mir da eine nen Tipp geben wie ich da weiter kommen kann.?!

Vielen Dank

Mal ohne es ausprobiert zu haben, müsste das doch so ähnlich sein:

filterE :: (v -> l -> v -> Bool) -> [LabledEdge v l] -> [LabledEdge v l]

filterE g [] = []

filterE g (Graph x:xs) = if (g x == True) then [x] ++ (filterE g xs) else filterE g xs

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.