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.

Haskell || Funktionen wiederholen

Empfohlene Antworten

Veröffentlicht

Hallo Leute,

ein neues Problem hat sich ergeben. Ich hoffe jemand kann mir diesmal helfen.

Also ich will eine Funktion in Haskell oefters ausfuehren lassen. Da es ja wie bekannt ist in Haskell keine Schleifen gibt, stellt sich dies als Herausforderung fuer mich heraus.

Folgende Ausgangssituation:

Ich habe eine Funktion

rollup :: [a] -> [a]

rollup (x:xs) = xs ++ [x]

Die das erste Element aus einer Liste ans Ende stellt.

Beispiel:

>rollup [1,2,3,4]

[2,3,4,1]

Jetzt will ich durch Eingabe eines Integers die Anzahl der Stellen bestimmen, um die das Element versetzt werden soll.

Etwa so:

>rollup (2) [1,2,3,4]

[3,4,1,2]

Ich waere froh wenn mir jemand helfen koennte.

  • 7 Monate später...

>rollup (2) [1,2,3,4]

[3,4,1,2].


rollup 0 xs     = xs

rollup i (x:xs) = rollup (i-1) (xs ++ [x])

habs wieder nich gecheckt :) aber so ungefähr sollte dat tun... :)

greetings frogger

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.